|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--nankin.zheng.gatem.model.DOMTree
DOMTree supports some frequently-used operations on an org.w3c.dom.Node object. It uses org.w3c.dom.Node and org.w3c.dom.NodeList as its proxy.
NOTE: this class is planned to be replaced by Apache Jakarta Commons Digester package.
Field Summary | |
private org.w3c.dom.Node |
root
The root of the current subtree. |
Constructor Summary | |
|
DOMTree(java.io.InputStream fin)
Constructor, read and parse an xml file to a tree. |
private |
DOMTree(org.w3c.dom.Node node)
Private constructor, create a DOMTree object directly by root. |
Method Summary | |
DOMTree |
getElement(int index,
java.lang.String tagname)
Get by index the element with the given tag name. |
int |
getElementCount(java.lang.String tagname)
How many elements (of the given tag name) are there among its all direct children. |
java.lang.String |
getTextValue()
Get the first text value of the node. |
private boolean |
isElement(org.w3c.dom.Node node,
java.lang.String tagname)
Whether the node is an element (with a given tag name). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private org.w3c.dom.Node root
Constructor Detail |
public DOMTree(java.io.InputStream fin) throws GameException
GameException
- if any IO or parse error occured.private DOMTree(org.w3c.dom.Node node) throws GameException
GameException
- if node is null.Method Detail |
private boolean isElement(org.w3c.dom.Node node, java.lang.String tagname)
node
- node to be verified.tagname
- tag name to be verified (null means that tag name will not be verified).
public int getElementCount(java.lang.String tagname)
tagname
- tag name of the element (null means that tag name will not be verified).
public DOMTree getElement(int index, java.lang.String tagname) throws GameException
NOTE that this method will never return null.
index
- index of elements.tagname
- tag name.
GameException
- if index is out of bound or element is not found.public java.lang.String getTextValue()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |