Package org.gjt.xpp.impl.pullnode
Class PullNode
- java.lang.Object
-
- org.gjt.xpp.impl.tag.Tag
-
- org.gjt.xpp.impl.tag.StartTag
-
- org.gjt.xpp.impl.node.Node
-
- org.gjt.xpp.impl.pullnode.PullNode
-
- All Implemented Interfaces:
XmlNode,XmlPullNode,XmlStartTag,XmlTag
public class PullNode extends Node implements XmlPullNode
Allows node tree to be constructed on demand. When PullNode is constructed and method setPullPasrser() is executed (or constructor with PullParser arg is called) node is assumend to be incomplete and children will be retrieved on demand (pulled) including automatic creation of sub pull nodes. If no pull parser is associated (it is null) this class must work like regular XmlNode...- Author:
- Aleksander Slominski
-
-
Field Summary
Fields Modifier and Type Field Description protected intdepthprotected XmlPullParserpp-
Fields inherited from class org.gjt.xpp.impl.node.Node
children, childrenCount, declaredNs, declaredNsEnd, declaredPrefixes, defaultNamespaceUri, EMPTY_ENUMERATION, oneChild, parent, prefix2Ns
-
-
Constructor Summary
Constructors Constructor Description PullNode(XmlPullParser pp)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendChild(java.lang.Object child)java.util.Enumerationchildren()This is not recommened method to pull children when node is not finished (use readNextChild() instead) as Enumeration interface does not allow to throw XmlPullParserException so any parsing exeption is wrapped into RuntimeException making code more messy...java.lang.ObjectgetChildAt(int pos)intgetChildrenCount()it will reconsruct whole subtree to get count ...intgetChildrenCountSoFar()if unfinished it returns actual number of children...XmlPullParsergetPullParser()Get parser that is use to build this node tree and this pull node becomes finished - the caller is responsibile to move pull parser state to the end tag of this node (or parent pull node will be left in unconsistent state!!!!).voidinsertChildAt(int pos, java.lang.Object child)booleanisFinished()Is pull parsing of node finished.XmlNodenewNode()context sensitive factory method to create the same type of nodeXmlPullNodenewPullNode(XmlPullParser pp)protected voidprintFields(java.lang.StringBuffer buf)Print this class state into StringBuffer element namevoidreadChildren()Read all reminaing children up to end tag.java.lang.ObjectreadNextChild()This is preferred method to pull children (children() requires .wrapping object Enumeration).voidremoveChildAt(int pos)voidremoveChildren()Removes all children - every child that was implementing XmlNode will have set parent to null.voidreplaceChildAt(int pos, java.lang.Object child)voidresetPullNode()PullNode stays in finished state.voidsetPullParser(XmlPullParser pp)Reset pull node to use pull parser.voidskipChildren()java.lang.StringtoString()Return string representation of start tag including name and list of attributes.-
Methods inherited from class org.gjt.xpp.impl.node.Node
addDeclaredNamespaces, addNamespaceDeclaration, ensureChildrenCapacity, ensureDeclaredNamespacesCapacity, equals, getDeclaredNamespaceLength, getDefaultNamespaceUri, getParentNode, getQNameLocal, getQNameUri, namespace2Prefix, newNode, prefix2Namespace, readDeclaredNamespaceUris, readDeclaredPrefixes, removeDeclaredNamespaces, resetNode, setDefaultNamespaceUri, setParentNode
-
Methods inherited from class org.gjt.xpp.impl.tag.StartTag
addAttribute, addAttribute, ensureAttributesCapacity, getAttributeCount, getAttributeLocalName, getAttributeNamespaceUri, getAttributePrefix, getAttributeRawName, getAttributeValue, getAttributeValueFromName, getAttributeValueFromRawName, isAttributeNamespaceDeclaration, removeAttributeByName, removeAttributeByRawName, removeAttributes, resetStartTag
-
Methods inherited from class org.gjt.xpp.impl.tag.Tag
getLocalName, getNamespaceUri, getPrefix, getRawName, hashCode, modifyTag, resetTag
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.gjt.xpp.XmlNode
addDeclaredNamespaces, addNamespaceDeclaration, ensureChildrenCapacity, ensureDeclaredNamespacesCapacity, getDeclaredNamespaceLength, getDefaultNamespaceUri, getParentNode, getQNameLocal, getQNameUri, namespace2Prefix, newNode, prefix2Namespace, readDeclaredNamespaceUris, readDeclaredPrefixes, removeDeclaredNamespaces, resetNode, setDefaultNamespaceUri, setParentNode
-
Methods inherited from interface org.gjt.xpp.XmlStartTag
addAttribute, addAttribute, ensureAttributesCapacity, getAttributeCount, getAttributeLocalName, getAttributeNamespaceUri, getAttributePrefix, getAttributeRawName, getAttributeValue, getAttributeValueFromName, getAttributeValueFromRawName, isAttributeNamespaceDeclaration, removeAttributeByName, removeAttributeByRawName, removeAttributes, resetStartTag
-
Methods inherited from interface org.gjt.xpp.XmlTag
getLocalName, getNamespaceUri, getPrefix, getRawName, modifyTag, resetTag
-
-
-
-
Field Detail
-
depth
protected int depth
-
pp
protected XmlPullParser pp
-
-
Constructor Detail
-
PullNode
public PullNode(XmlPullParser pp) throws XmlPullParserException
- Throws:
XmlPullParserException
-
-
Method Detail
-
newNode
public XmlNode newNode() throws XmlPullParserException
Description copied from class:Nodecontext sensitive factory method to create the same type of node- Specified by:
newNodein interfaceXmlNode- Specified by:
newNodein interfaceXmlPullNode- Overrides:
newNodein classNode- Throws:
XmlPullParserException
-
newPullNode
public XmlPullNode newPullNode(XmlPullParser pp) throws XmlPullParserException
- Specified by:
newPullNodein interfaceXmlPullNode- Throws:
XmlPullParserException
-
resetPullNode
public void resetPullNode()
PullNode stays in finished state.- Specified by:
resetPullNodein interfaceXmlPullNode
-
isFinished
public boolean isFinished()
Description copied from interface:XmlPullNodeIs pull parsing of node finished.- Specified by:
isFinishedin interfaceXmlPullNode
-
getPullParser
public XmlPullParser getPullParser() throws java.io.IOException, XmlPullParserException
Description copied from interface:XmlPullNodeGet parser that is use to build this node tree and this pull node becomes finished - the caller is responsibile to move pull parser state to the end tag of this node (or parent pull node will be left in unconsistent state!!!!). The returned pull parser position will be before start tag of next child or before final end tag and the caller should use next() to move parser to start reading children. The node state becomes finished and subsequent call to this method will throw exception until setPullParser() is called. The final effect should be equivalen to calling skipNode()!NOTE: this pull node must be in unfinished state or exception will be thrown
- Specified by:
getPullParserin interfaceXmlPullNode- Throws:
java.io.IOExceptionXmlPullParserException
-
setPullParser
public void setPullParser(XmlPullParser pp) throws XmlPullParserException
Reset pull node to use pull parser. Pull Parser must be on START_TAG- Specified by:
setPullParserin interfaceXmlPullNode- Throws:
XmlPullParserException
-
children
public java.util.Enumeration children()
Description copied from interface:XmlPullNodeThis is not recommened method to pull children when node is not finished (use readNextChild() instead) as Enumeration interface does not allow to throw XmlPullParserException so any parsing exeption is wrapped into RuntimeException making code more messy...- Specified by:
childrenin interfaceXmlNode- Specified by:
childrenin interfaceXmlPullNode- Overrides:
childrenin classNode- See Also:
XmlPullNode.readNextChild()
-
readNextChild
public java.lang.Object readNextChild() throws XmlPullParserException, java.io.IOExceptionDescription copied from interface:XmlPullNodeThis is preferred method to pull children (children() requires .wrapping object Enumeration).- Specified by:
readNextChildin interfaceXmlPullNode- Returns:
- next child (which is String or XmlPullNode) or null if there is no re children
- Throws:
XmlPullParserExceptionjava.io.IOException- See Also:
XmlPullNode.children()
-
readChildren
public void readChildren() throws XmlPullParserException, java.io.IOExceptionRead all reminaing children up to end tag.- Specified by:
readChildrenin interfaceXmlPullNode- Throws:
XmlPullParserExceptionjava.io.IOException
-
skipChildren
public void skipChildren() throws XmlPullParserException, java.io.IOException- Specified by:
skipChildrenin interfaceXmlPullNode- Throws:
XmlPullParserExceptionjava.io.IOException
-
getChildrenCountSoFar
public int getChildrenCountSoFar()
if unfinished it returns actual number of children...- Specified by:
getChildrenCountSoFarin interfaceXmlPullNode
-
getChildrenCount
public int getChildrenCount()
it will reconsruct whole subtree to get count ...- Specified by:
getChildrenCountin interfaceXmlNode- Overrides:
getChildrenCountin classNode
-
getChildAt
public java.lang.Object getChildAt(int pos)
- Specified by:
getChildAtin interfaceXmlNode- Overrides:
getChildAtin classNode
-
appendChild
public void appendChild(java.lang.Object child) throws XmlPullParserException- Specified by:
appendChildin interfaceXmlNode- Overrides:
appendChildin classNode- Throws:
XmlPullParserException
-
insertChildAt
public void insertChildAt(int pos, java.lang.Object child) throws XmlPullParserException- Specified by:
insertChildAtin interfaceXmlNode- Overrides:
insertChildAtin classNode- Throws:
XmlPullParserException
-
removeChildAt
public void removeChildAt(int pos) throws XmlPullParserException- Specified by:
removeChildAtin interfaceXmlNode- Overrides:
removeChildAtin classNode- Throws:
XmlPullParserException
-
replaceChildAt
public void replaceChildAt(int pos, java.lang.Object child) throws XmlPullParserException- Specified by:
replaceChildAtin interfaceXmlNode- Overrides:
replaceChildAtin classNode- Throws:
XmlPullParserException
-
removeChildren
public void removeChildren() throws XmlPullParserExceptionDescription copied from interface:XmlNodeRemoves all children - every child that was implementing XmlNode will have set parent to null.- Specified by:
removeChildrenin interfaceXmlNode- Overrides:
removeChildrenin classNode- Throws:
XmlPullParserException
-
printFields
protected void printFields(java.lang.StringBuffer buf)
Print this class state into StringBuffer element name- Overrides:
printFieldsin classNode
-
-