public class Configuration extends Object implements IHierarchyParent
Modifier and Type | Field and Description |
---|---|
static String |
_rcsid |
protected List<ConfigurationNode> |
children |
protected static String |
JSON_ATTRIBUTE |
protected static String |
JSON_CHILDREN |
protected static String |
JSON_TYPE |
protected static String |
JSON_VALUE |
protected boolean |
readOnly |
protected String |
rootNodeLabel |
Constructor and Description |
---|
Configuration()
Constructor.
|
Configuration(String rootNodeLabel)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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(String type)
Create a new child node of the appropriate type and class.
|
boolean |
equals(Object o)
Do a comparison
|
ConfigurationNode |
findChild(int index)
Get child n.
|
void |
fromJSON(String json)
Read from JSON.
|
void |
fromXML(InputStream xmlstream)
Read from an XML binary stream.
|
void |
fromXML(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,
String key,
Object x)
Process a JSON object
|
protected void |
processObject(String key,
Object x)
Process a JSON object
|
protected ConfigurationNode |
readNode(String key,
org.json.JSONObject object)
Read a node from a json object
|
protected ConfigurationNode |
readNode(XMLDoc doc,
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.
|
String |
toJSON()
Get as JSON.
|
String |
toString()
Construct a human-readable string
|
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,
Object parent,
ConfigurationNode node)
Write a specification node.
|
public static final String _rcsid
protected static final String JSON_ATTRIBUTE
protected static final String JSON_VALUE
protected static final String JSON_CHILDREN
protected static final String JSON_TYPE
protected String rootNodeLabel
protected List<ConfigurationNode> children
protected boolean readOnly
public Configuration()
public Configuration(String rootNodeLabel)
rootNodeLabel
- is the root node label to use.protected Configuration createNew()
protected ConfigurationNode createNewNode(String type)
protected void clearOuterNodes()
protected void addOuterNode(ConfigurationNode node)
node
- is the node that was just read.protected void removeOuterNode(ConfigurationNode node)
node
- is the node that was just removed.protected Configuration createDuplicate(boolean readOnly)
public void makeReadOnly()
public String toXML() throws ManifoldCFException
ManifoldCFException
public String toJSON() throws ManifoldCFException
ManifoldCFException
protected static void writeNode(XMLDoc doc, Object parent, ConfigurationNode node) throws ManifoldCFException
doc
- is the document.parent
- is the parent.node
- is the node.ManifoldCFException
protected static void writeNode(org.json.JSONWriter writer, ConfigurationNode node, boolean writeKey, boolean writeSpecialKey) throws ManifoldCFException
writer
- is the JSON writer.node
- is the node.writeKey
- is true if the key needs to be written, false otherwise.ManifoldCFException
public void fromXML(String xml) throws ManifoldCFException
xml
- is the input XML.ManifoldCFException
public void fromJSON(String json) throws ManifoldCFException
json
- is the input JSON.ManifoldCFException
protected void processObject(String key, Object x) throws ManifoldCFException
ManifoldCFException
protected ConfigurationNode readNode(String key, org.json.JSONObject object) throws ManifoldCFException
ManifoldCFException
protected void processObject(ConfigurationNode cn, String key, Object x) throws ManifoldCFException
ManifoldCFException
public void fromXML(InputStream xmlstream) throws ManifoldCFException
xmlstream
- is the input XML stream. Does NOT close the stream.ManifoldCFException
protected void initializeFromDoc(XMLDoc doc) throws ManifoldCFException
ManifoldCFException
protected ConfigurationNode readNode(XMLDoc doc, Object object) throws ManifoldCFException
doc
- is the document.object
- is the object.ManifoldCFException
public int getChildCount()
getChildCount
in interface IHierarchyParent
public ConfigurationNode findChild(int index)
findChild
in interface IHierarchyParent
index
- is the child number.public void removeChild(int index)
removeChild
in interface IHierarchyParent
index
- is the child to remove.public void addChild(int index, ConfigurationNode child)
addChild
in interface IHierarchyParent
index
- is the position to add the child.child
- is the child to add.public void clearChildren()
clearChildren
in interface IHierarchyParent