|
|||||||||
| Home >> All >> org >> enhydra >> xml >> [ dom overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.enhydra.xml.dom
Class DOMTraversal

java.lang.Objectorg.enhydra.xml.dom.DOMTraversal
- public class DOMTraversal
- extends java.lang.Object
Class that traverse a DOM tree or subtree, calling handler methods for each node. It is up to the handler methods to make a decision on processing child and element nodes by explictly calling the methods to continue the traversal. This is gives the handler more control and actually kept the code simpler for both this class and the client.
While DOM traversal is straight-forward, traversing the LazyDOM while avoiding expansion made things tricker. This class, and the derived class for the LazyDOM, handles these special cases.
| Nested Class Summary | |
static interface |
DOMTraversal.Handler
Interface for node callback object. |
| Field Summary | |
static int |
ALL_ATTRIBUTES
Option flag to indicate that unspecified attributes should be included. |
protected int |
fDepth
Current traversal tree depth |
protected DOMTraversal.Handler |
fHandler
Handler object for the traversal |
protected int |
fOptions
Options controlling the traversal. |
protected boolean |
fProcessingAttribute
Are we processing an attribute or its children? |
static int |
SORT_ATTRIBUTES
Option flag to indicate that attributes should be sorted before calling the handlers. |
| Constructor Summary | |
DOMTraversal(DOMTraversal.Handler handler,
int options)
Constructor. |
|
DOMTraversal(int options)
Default constructor, set handler later. |
|
| Method Summary | |
int |
getDepth()
Get the current depth in the DOM tree that is being traversed. |
static DOMTraversal |
getTraverser(DOMTraversal.Handler handler,
int options,
org.w3c.dom.Node node)
Factory method to create a traverser based on the type of a document. |
private void |
processAttr(org.w3c.dom.Attr attr)
Process an Attr node. |
void |
processAttributes(org.w3c.dom.Element element)
Process the attributes of an element. |
private void |
processAttrsSorted(org.w3c.dom.NamedNodeMap attrMap)
Process attributes, sorted by name. |
private void |
processAttrsUnsorted(org.w3c.dom.NamedNodeMap attrMap)
Process attributes in the order that they occur. |
void |
processChildren(org.w3c.dom.Node node)
Process the children of a node. |
void |
processDocumentType(org.w3c.dom.Document document)
Process a DocumentType attribute of a Document node, if it exists. |
void |
processDocumentTypeContents(org.w3c.dom.DocumentType documentType)
Process the contents of a DocumentType node, |
boolean |
processingAttribute()
Are we currently processing an attribute node or its descendents? |
private void |
processNamedNodeMap(org.w3c.dom.NamedNodeMap nodeMap)
Process contents of a NamedNodeMap. |
protected void |
processNode(org.w3c.dom.Node node)
Processing based on node type. |
void |
setHandler(DOMTraversal.Handler handler)
Set the handler. |
void |
traverse(org.w3c.dom.Node root)
Traverse a DOM tree or subtree. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
SORT_ATTRIBUTES
public static final int SORT_ATTRIBUTES
- Option flag to indicate that attributes should be sorted before calling
the handlers.
- See Also:
- Constant Field Values
ALL_ATTRIBUTES
public static final int ALL_ATTRIBUTES
- Option flag to indicate that unspecified attributes should be included.
- See Also:
- Constant Field Values
fHandler
protected DOMTraversal.Handler fHandler
- Handler object for the traversal
fOptions
protected int fOptions
- Options controlling the traversal.
fDepth
protected int fDepth
- Current traversal tree depth
fProcessingAttribute
protected boolean fProcessingAttribute
- Are we processing an attribute or its children?
| Constructor Detail |
DOMTraversal
public DOMTraversal(DOMTraversal.Handler handler, int options)
- Constructor.
DOMTraversal
public DOMTraversal(int options)
- Default constructor, set handler later.
| Method Detail |
setHandler
public void setHandler(DOMTraversal.Handler handler)
- Set the handler.
traverse
public void traverse(org.w3c.dom.Node root)
- Traverse a DOM tree or subtree.
getDepth
public final int getDepth()
- Get the current depth in the DOM tree that is being traversed.
processingAttribute
public final boolean processingAttribute()
- Are we currently processing an attribute node or its descendents?
processChildren
public void processChildren(org.w3c.dom.Node node)
- Process the children of a node.
processAttributes
public void processAttributes(org.w3c.dom.Element element)
- Process the attributes of an element.
processDocumentType
public void processDocumentType(org.w3c.dom.Document document)
- Process a DocumentType attribute of a Document node, if it exists.
processDocumentTypeContents
public void processDocumentTypeContents(org.w3c.dom.DocumentType documentType)
- Process the contents of a DocumentType node,
processAttrsSorted
private void processAttrsSorted(org.w3c.dom.NamedNodeMap attrMap)
- Process attributes, sorted by name.
processAttrsUnsorted
private void processAttrsUnsorted(org.w3c.dom.NamedNodeMap attrMap)
- Process attributes in the order that they occur.
processNamedNodeMap
private void processNamedNodeMap(org.w3c.dom.NamedNodeMap nodeMap)
- Process contents of a NamedNodeMap.
processAttr
private void processAttr(org.w3c.dom.Attr attr) throws java.lang.Exception
- Process an Attr node.
processNode
protected void processNode(org.w3c.dom.Node node)
- Processing based on node type. All nodes go through here.
getTraverser
public static DOMTraversal getTraverser(DOMTraversal.Handler handler, int options, org.w3c.dom.Node node)
- Factory method to create a traverser based on the type of
a document.
|
|||||||||
| Home >> All >> org >> enhydra >> xml >> [ dom overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.enhydra.xml.dom.DOMTraversal