Class XmlTree
java.lang.Object
java.util.Dictionary
sunlabs.brazil.sunlabs.XmlTree
- All Implemented Interfaces:
PropertiesCacheManager.Saveable
Create a tree representation of an xml file whose parts may be
referenced as a dictionary. This is currently "read only".
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe node is named by the specified attribute.static classDo some more reasonable error handling.static classThis describes a node of the XML treestatic interfacestatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionelements()static voidelements(XmlTree.Node n, Vector v) Given a node description, return the value, if any.static StringgetFile(InputStream in) static StringGiven a node descriptor, return the result.getRoot()getTags()booleanisEmpty()The current object state is the "default"; "save" does not need to write out any state.keys()voidkeys(XmlTree.Node n, String prefix, String delim, Vector v) voidload(InputStream in) Recreate the object from the ascii representation stored as a Properties format file.static voidFind all nodes that match a glob pattern, starting at the root.voidmatch(XmlTree.Node node, StringTokenizer st, Vector results) Find all nodes that match a glob pattern, starting at any node.voidReplace the XmlTree with new markup.voidsave(OutputStream out, String header) Create an ascii representation of this object in a Java Properties format.Find a node in the tree by name, starting at the root.search(XmlTree.Node node, StringTokenizer st) Find a node in the tree by name, starting under any node.booleansetAttribute(String name, String key, String value) booleanvoidsetComparator(XmlTree.NodeName nodeName) Set the class that determines a node's name.voidset the node delimiter.booleanvoidvoidset the name of this treevoidAdd an element to the tag process list.voidSet the list of tags to processintsize()toString()Print a treevoidtoString(XmlTree.Node node, StringBuffer sb, int level)
-
Constructor Details
-
XmlTree
public XmlTree()Make an empty tree. -
XmlTree
Given an XML string, build the tree.- Throws:
IllegalArgumentException
-
-
Method Details
-
setIdent
-
getRoot
-
setTag
Add an element to the tag process list. Once a Process tag is defined, only tags defined are processed. All other tags are treated as singletons -
setTags
Set the list of tags to process -
getTags
-
setPrefix
set the name of this tree -
setDelim
set the node delimiter. -
setDflt
-
setComparator
Set the class that determines a node's name. This may be used to change the way nodes are named in an arbitrary fashion. -
toString
-
toString
-
replace
Replace the XmlTree with new markup.- Parameters:
src- : the xml data- Throws:
XmlTree.IllegalXmlException
-
setAttribute
-
setCdata
-
search
Find a node in the tree by name, starting at the root.- Parameters:
s- The node pathname- Returns:
- The node, if found, or null
-
search
Find a node in the tree by name, starting under any node. -
match
-
match
Find all nodes that match a glob pattern, starting at any node. -
elements
- Specified by:
elementsin classDictionary
-
elements
-
keys
- Specified by:
keysin classDictionary
-
keys
-
get
Given a node description, return the value, if any. Descriptions are of the form: [prefix].name.[suffix] where : [prefix] is the name of the tree "." is the current delimiter, name is the path name of a node in the tree [suffix] specifies which part of the node to return as a string. See getpart() for the list of valid suffixes.- Specified by:
getin classDictionary
-
getPart
Given a node descriptor, return the result. XXX not done modifiers: cdata: return cdata tag: the name index: which tag within whis parent attributes: the list of attribute names children: the list of children childCount: the number of children.value the value for attribute glob nodes matching the glob pattern all all nodes under this one -
put
- Specified by:
putin classDictionary
-
remove
- Specified by:
removein classDictionary
-
size
public int size()- Specified by:
sizein classDictionary
-
isEmpty
public boolean isEmpty()Description copied from interface:PropertiesCacheManager.SaveableThe current object state is the "default"; "save" does not need to write out any state.- Specified by:
isEmptyin interfacePropertiesCacheManager.Saveable- Specified by:
isEmptyin classDictionary
-
load
Description copied from interface:PropertiesCacheManager.SaveableRecreate the object from the ascii representation stored as a Properties format file.- Specified by:
loadin interfacePropertiesCacheManager.Saveable- Throws:
IOException
-
save
Description copied from interface:PropertiesCacheManager.SaveableCreate an ascii representation of this object in a Java Properties format.- Specified by:
savein interfacePropertiesCacheManager.Saveable- Throws:
IOException
-
main
-
getFile
- Throws:
IOException
-
getFile
- Throws:
IOException
-