org.apache.manifoldcf.core.interfaces
Class Configuration

java.lang.Object
  extended by org.apache.manifoldcf.core.interfaces.Configuration
All Implemented Interfaces:
IHierarchyParent
Direct Known Subclasses:
ConfigParams, ManifoldCFConfiguration, Specification

public class Configuration
extends java.lang.Object
implements IHierarchyParent

This class represents XML configuration information, in its most basic incarnation.


Field Summary
static java.lang.String _rcsid
           
protected  java.util.ArrayList children
           
protected static java.lang.String JSON_ATTRIBUTE
           
protected static java.lang.String JSON_CHILDREN
           
protected static java.lang.String JSON_TYPE
           
protected static java.lang.String JSON_VALUE
           
protected  boolean readOnly
           
protected  java.lang.String rootNodeLabel
           
 
Constructor Summary
Configuration()
          Constructor.
Configuration(java.lang.String rootNodeLabel)
          Constructor.
 
Method Summary
 void addChild(int index, ConfigurationNode child)
          Add child at specified position.
protected  void addOuterNode(ConfigurationNode node)
          Note the addition of a new outer node.
 void clearChildren()
          Clear children.
protected  void clearOuterNodes()
          Note the removal of all outer nodes.
protected  Configuration createDuplicate(boolean readOnly)
          Create a duplicate.
protected  Configuration createNew()
          Create a new object of the appropriate class.
protected  ConfigurationNode createNewNode(java.lang.String type)
          Create a new child node of the appropriate type and class.
 boolean equals(java.lang.Object o)
          Do a comparison
 ConfigurationNode findChild(int index)
          Get child n.
 void fromJSON(java.lang.String json)
          Read from JSON.
 void fromXML(java.io.InputStream xmlstream)
          Read from an XML binary stream.
 void fromXML(java.lang.String xml)
          Read from XML.
 int getChildCount()
          Get child count.
 int hashCode()
          Calculate a hash code
protected  void initializeFromDoc(XMLDoc doc)
           
 void makeReadOnly()
          Make the configuration read-only
protected  void processObject(ConfigurationNode cn, java.lang.String key, java.lang.Object x)
          Process a JSON object
protected  void processObject(java.lang.String key, java.lang.Object x)
          Process a JSON object
protected  ConfigurationNode readNode(java.lang.String key, org.json.JSONObject object)
          Read a node from a json object
protected  ConfigurationNode readNode(XMLDoc doc, java.lang.Object object)
          Read a configuration node from XML.
 void removeChild(int index)
          Remove child n.
protected  void removeOuterNode(ConfigurationNode node)
          Note the removal of an outer node.
 java.lang.String toJSON()
          Get as JSON.
 java.lang.String toXML()
          Get as XML
protected static void writeNode(org.json.JSONWriter writer, ConfigurationNode node, boolean writeKey, boolean writeSpecialKey)
          Write a JSON specification node.
protected static void writeNode(XMLDoc doc, java.lang.Object parent, ConfigurationNode node)
          Write a specification node.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rcsid

public static final java.lang.String _rcsid
See Also:
Constant Field Values

JSON_ATTRIBUTE

protected static final java.lang.String JSON_ATTRIBUTE
See Also:
Constant Field Values

JSON_VALUE

protected static final java.lang.String JSON_VALUE
See Also:
Constant Field Values

JSON_CHILDREN

protected static final java.lang.String JSON_CHILDREN
See Also:
Constant Field Values

JSON_TYPE

protected static final java.lang.String JSON_TYPE
See Also:
Constant Field Values

rootNodeLabel

protected java.lang.String rootNodeLabel

children

protected java.util.ArrayList children

readOnly

protected boolean readOnly
Constructor Detail

Configuration

public Configuration()
Constructor.


Configuration

public Configuration(java.lang.String rootNodeLabel)
Constructor.

Parameters:
rootNodeLabel - is the root node label to use.
Method Detail

createNew

protected Configuration createNew()
Create a new object of the appropriate class.

Returns:
the newly-created configuration object.

createNewNode

protected ConfigurationNode createNewNode(java.lang.String type)
Create a new child node of the appropriate type and class.

Returns:
the newly-created node.

clearOuterNodes

protected void clearOuterNodes()
Note the removal of all outer nodes.


addOuterNode

protected void addOuterNode(ConfigurationNode node)
Note the addition of a new outer node.

Parameters:
node - is the node that was just read.

removeOuterNode

protected void removeOuterNode(ConfigurationNode node)
Note the removal of an outer node.

Parameters:
node - is the node that was just removed.

createDuplicate

protected Configuration createDuplicate(boolean readOnly)
Create a duplicate.


makeReadOnly

public void makeReadOnly()
Make the configuration read-only


toXML

public java.lang.String toXML()
                       throws ManifoldCFException
Get as XML

Returns:
the xml corresponding to these Configuration.
Throws:
ManifoldCFException

toJSON

public java.lang.String toJSON()
                        throws ManifoldCFException
Get as JSON.

Returns:
the json corresponding to this Configuration.
Throws:
ManifoldCFException

writeNode

protected static void writeNode(XMLDoc doc,
                                java.lang.Object parent,
                                ConfigurationNode node)
                         throws ManifoldCFException
Write a specification node.

Parameters:
doc - is the document.
parent - is the parent.
node - is the node.
Throws:
ManifoldCFException

writeNode

protected static void writeNode(org.json.JSONWriter writer,
                                ConfigurationNode node,
                                boolean writeKey,
                                boolean writeSpecialKey)
                         throws ManifoldCFException
Write a JSON specification node.

Parameters:
writer - is the JSON writer.
node - is the node.
writeKey - is true if the key needs to be written, false otherwise.
Throws:
ManifoldCFException

fromXML

public void fromXML(java.lang.String xml)
             throws ManifoldCFException
Read from XML.

Parameters:
xml - is the input XML.
Throws:
ManifoldCFException

fromJSON

public void fromJSON(java.lang.String json)
              throws ManifoldCFException
Read from JSON.

Parameters:
json - is the input JSON.
Throws:
ManifoldCFException

processObject

protected void processObject(java.lang.String key,
                             java.lang.Object x)
                      throws ManifoldCFException
Process a JSON object

Throws:
ManifoldCFException

readNode

protected ConfigurationNode readNode(java.lang.String key,
                                     org.json.JSONObject object)
                              throws ManifoldCFException
Read a node from a json object

Throws:
ManifoldCFException

processObject

protected void processObject(ConfigurationNode cn,
                             java.lang.String key,
                             java.lang.Object x)
                      throws ManifoldCFException
Process a JSON object

Throws:
ManifoldCFException

fromXML

public void fromXML(java.io.InputStream xmlstream)
             throws ManifoldCFException
Read from an XML binary stream.

Parameters:
xmlstream - is the input XML stream. Does NOT close the stream.
Throws:
ManifoldCFException

initializeFromDoc

protected void initializeFromDoc(XMLDoc doc)
                          throws ManifoldCFException
Throws:
ManifoldCFException

readNode

protected ConfigurationNode readNode(XMLDoc doc,
                                     java.lang.Object object)
                              throws ManifoldCFException
Read a configuration node from XML.

Parameters:
doc - is the document.
object - is the object.
Returns:
the specification node.
Throws:
ManifoldCFException

getChildCount

public int getChildCount()
Get child count.

Specified by:
getChildCount in interface IHierarchyParent
Returns:
the count.

findChild

public ConfigurationNode findChild(int index)
Get child n.

Specified by:
findChild in interface IHierarchyParent
Parameters:
index - is the child number.
Returns:
the child node.

removeChild

public void removeChild(int index)
Remove child n.

Specified by:
removeChild in interface IHierarchyParent
Parameters:
index - is the child to remove.

addChild

public void addChild(int index,
                     ConfigurationNode child)
Add child at specified position.

Specified by:
addChild in interface IHierarchyParent
Parameters:
index - is the position to add the child.
child - is the child to add.

clearChildren

public void clearChildren()
Clear children.


hashCode

public int hashCode()
Calculate a hash code

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Do a comparison

Overrides:
equals in class java.lang.Object