|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--bill.util.xml.SimpleXML
Class in charge of creating an XML document. This is a simplistic implementation, i.e. you will find no mention if DOM or SAX. It stores it's data primarily in Vectors, not Node or Document objects. Useful for creating XML documents in a reasonably straight forward manner and it can dump the XML out in a properly formed String format.
Inner Class Summary | |
class |
SimpleXML.SimpleXMLBuilder
This class is used to assist in the creation of a SimpleXML class instance from an XML string. |
Constructor Summary | |
SimpleXML()
Default constructor. |
|
SimpleXML(FileReader reader)
Constructor that uses a file as it's input source. |
|
SimpleXML(SimpleXML xml)
A copy constructor. |
|
SimpleXML(String xml)
Constructor that takes a valid XML document as input to create our internal XML representation structure. |
Method Summary | |
static void |
addChild(SimpleXMLObject target,
SimpleXMLObject child)
Adds the specified node as a child to the target node. |
void |
addChild(String target,
SimpleXMLObject child)
Adds the specified node as a child to the target XPath's node. |
boolean |
childHasAValue(String path)
Checks if any of the children of the specified node have a value. |
String |
getElementValue(String path)
Retrieves the value of the object at the specified XPath name in the XML document. |
SimpleXMLObject |
getObject(String path)
Retrieves the object at the specified XPath name in the XML document. |
SimpleXMLObjectList |
getObjectList(String path)
Retrieves the object list at the specified XPath name in the XML document. |
SimpleXMLObject |
getRoot()
Returns the object that is the root node of the XML document. |
boolean |
isValidXPath(String path)
Checks to see if the specified XPath has been defined in the XML structure. |
static void |
mergeChildren(SimpleXMLObject target,
SimpleXMLObject source)
Adds the children of the source node to the children of the target node. |
void |
mergeChildren(String target,
SimpleXMLObject source)
Adds the children of the source node to the children of the target node. |
void |
removePath(String path)
Removes the specified XPath from the XML document. |
void |
removePath(String path,
boolean allInstances)
Removes the specified XPath from the XML document. |
String |
toXML()
Dumps out the object in valid XML string representation. |
SimpleXMLObject |
updatePath(String path,
String value)
Updates (or adds if necessary) the specified path name in the XML document to assign it the indicated value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public SimpleXML()
public SimpleXML(String xml)
xml
- The valid XML document to use.public SimpleXML(SimpleXML xml)
xml
- The instance to make a copy of.public SimpleXML(FileReader reader)
reader
- Handle to the input file.Method Detail |
public static void addChild(SimpleXMLObject target, SimpleXMLObject child)
target
- The node to add the child node to.child
- The node to be added as a child.public void addChild(String target, SimpleXMLObject child)
target
- The XPath of the node to add the child node to.child
- The node to be added as a child.public static void mergeChildren(SimpleXMLObject target, SimpleXMLObject source)
target
- The node to add the child nodes to.source
- The node to take the children out of.public void mergeChildren(String target, SimpleXMLObject source)
target
- The XPath of the node to add the child nodes to.source
- The node to take the children out of.public void removePath(String path)
path
- The XPath to remove from the XML document.public void removePath(String path, boolean allInstances)
path
- The XPath to remove from the XML document.allInstances
- Indicates if all instances of the leaf node of
the XPath should be removed in cases where there are multiple occurrences
of them and a specific instance is not specified.public SimpleXMLObject updatePath(String path, String value)
null
is passed as the value, than
nothing will happen.path
- The XPath of the node to be updated or created.value
- The value to assign to the node.public SimpleXMLObject getRoot()
public SimpleXMLObjectList getObjectList(String path)
path
- The XPath of the list to be retrieved.public SimpleXMLObject getObject(String path)
path
- The XPath of the node to be retrieved.public boolean isValidXPath(String path)
path
- The XPath to check for.true
if the XPath has been defined in the
XML structure (regardless of whether it has a value), otherwise returns
false
.public boolean childHasAValue(String path)
path
- The XPath into the XML to check for children with values.true
if at least one child has a value,
otherwise returns false
.public String getElementValue(String path)
path
- The XPath of the node to retrieve the value of.public String toXML()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |