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 class
The node is named by the specified attribute.static class
Do some more reasonable error handling.static class
This describes a node of the XML treestatic interface
static class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionelements()
static void
elements
(XmlTree.Node n, Vector v) Given a node description, return the value, if any.static String
getFile
(InputStream in) static String
Given a node descriptor, return the result.getRoot()
getTags()
boolean
isEmpty()
The current object state is the "default"; "save" does not need to write out any state.keys()
void
keys
(XmlTree.Node n, String prefix, String delim, Vector v) void
load
(InputStream in) Recreate the object from the ascii representation stored as a Properties format file.static void
Find all nodes that match a glob pattern, starting at the root.void
match
(XmlTree.Node node, StringTokenizer st, Vector results) Find all nodes that match a glob pattern, starting at any node.void
Replace the XmlTree with new markup.void
save
(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.boolean
setAttribute
(String name, String key, String value) boolean
void
setComparator
(XmlTree.NodeName nodeName) Set the class that determines a node's name.void
set the node delimiter.boolean
void
void
set the name of this treevoid
Add an element to the tag process list.void
Set the list of tags to processint
size()
toString()
Print a treevoid
toString
(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:
elements
in classDictionary
-
elements
-
keys
- Specified by:
keys
in 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:
get
in 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:
put
in classDictionary
-
remove
- Specified by:
remove
in classDictionary
-
size
public int size()- Specified by:
size
in classDictionary
-
isEmpty
public boolean isEmpty()Description copied from interface:PropertiesCacheManager.Saveable
The current object state is the "default"; "save" does not need to write out any state.- Specified by:
isEmpty
in interfacePropertiesCacheManager.Saveable
- Specified by:
isEmpty
in classDictionary
-
load
Description copied from interface:PropertiesCacheManager.Saveable
Recreate the object from the ascii representation stored as a Properties format file.- Specified by:
load
in interfacePropertiesCacheManager.Saveable
- Throws:
IOException
-
save
Description copied from interface:PropertiesCacheManager.Saveable
Create an ascii representation of this object in a Java Properties format.- Specified by:
save
in interfacePropertiesCacheManager.Saveable
- Throws:
IOException
-
main
-
getFile
- Throws:
IOException
-
getFile
- Throws:
IOException
-