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
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
FieldsFields inherited from class Node
children, childrenCount, declaredNs, declaredNsEnd, declaredPrefixes, defaultNamespaceUri, EMPTY_ENUMERATION, oneChild, parent, prefix2Ns -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendChild(Object child) children()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...getChildAt(int pos) intit will reconsruct whole subtree to get count ...intif unfinished it returns actual number of children...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, Object child) booleanIs pull parsing of node finished.newNode()context sensitive factory method to create the same type of nodeprotected voidprintFields(StringBuffer buf) Print this class state into StringBuffer element namevoidRead all reminaing children up to end tag.This is preferred method to pull children (children() requires .wrapping object Enumeration).voidremoveChildAt(int pos) voidRemoves all children - every child that was implementing XmlNode will have set parent to null.voidreplaceChildAt(int pos, Object child) voidPullNode stays in finished state.voidReset pull node to use pull parser.voidtoString()Return string representation of start tag including name and list of attributes.Methods inherited from class Node
addDeclaredNamespaces, addNamespaceDeclaration, ensureChildrenCapacity, ensureDeclaredNamespacesCapacity, equals, getDeclaredNamespaceLength, getDefaultNamespaceUri, getParentNode, getQNameLocal, getQNameUri, namespace2Prefix, newNode, prefix2Namespace, readDeclaredNamespaceUris, readDeclaredPrefixes, removeDeclaredNamespaces, resetNode, setDefaultNamespaceUri, setParentNodeMethods inherited from class StartTag
addAttribute, addAttribute, ensureAttributesCapacity, getAttributeCount, getAttributeLocalName, getAttributeNamespaceUri, getAttributePrefix, getAttributeRawName, getAttributeValue, getAttributeValueFromName, getAttributeValueFromRawName, isAttributeNamespaceDeclaration, removeAttributeByName, removeAttributeByRawName, removeAttributes, resetStartTagMethods inherited from class Tag
getLocalName, getNamespaceUri, getPrefix, getRawName, hashCode, modifyTag, resetTagMethods inherited from interface XmlNode
addDeclaredNamespaces, addNamespaceDeclaration, ensureChildrenCapacity, ensureDeclaredNamespacesCapacity, getDeclaredNamespaceLength, getDefaultNamespaceUri, getParentNode, getQNameLocal, getQNameUri, namespace2Prefix, newNode, prefix2Namespace, readDeclaredNamespaceUris, readDeclaredPrefixes, removeDeclaredNamespaces, resetNode, setDefaultNamespaceUri, setParentNodeMethods inherited from interface XmlStartTag
addAttribute, addAttribute, ensureAttributesCapacity, getAttributeCount, getAttributeLocalName, getAttributeNamespaceUri, getAttributePrefix, getAttributeRawName, getAttributeValue, getAttributeValueFromName, getAttributeValueFromRawName, isAttributeNamespaceDeclaration, removeAttributeByName, removeAttributeByRawName, removeAttributes, resetStartTagMethods inherited from interface XmlTag
getLocalName, getNamespaceUri, getPrefix, getRawName, modifyTag, resetTag
-
Field Details
-
depth
protected int depth -
pp
-
-
Constructor Details
-
PullNode
- Throws:
XmlPullParserException
-
-
Method Details
-
newNode
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
- 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
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:
IOExceptionXmlPullParserException
-
setPullParser
Reset pull node to use pull parser. Pull Parser must be on START_TAG- Specified by:
setPullParserin interfaceXmlPullNode- Throws:
XmlPullParserException
-
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... -
readNextChild
Description 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:
XmlPullParserExceptionIOException- See Also:
-
readChildren
Read all reminaing children up to end tag.- Specified by:
readChildrenin interfaceXmlPullNode- Throws:
XmlPullParserExceptionIOException
-
skipChildren
- Specified by:
skipChildrenin interfaceXmlPullNode- Throws:
XmlPullParserExceptionIOException
-
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
- Specified by:
getChildAtin interfaceXmlNode- Overrides:
getChildAtin classNode
-
appendChild
- Specified by:
appendChildin interfaceXmlNode- Overrides:
appendChildin classNode- Throws:
XmlPullParserException
-
insertChildAt
- Specified by:
insertChildAtin interfaceXmlNode- Overrides:
insertChildAtin classNode- Throws:
XmlPullParserException
-
removeChildAt
- Specified by:
removeChildAtin interfaceXmlNode- Overrides:
removeChildAtin classNode- Throws:
XmlPullParserException
-
replaceChildAt
- Specified by:
replaceChildAtin interfaceXmlNode- Overrides:
replaceChildAtin classNode- Throws:
XmlPullParserException
-
removeChildren
Description 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
Print this class state into StringBuffer element name- Overrides:
printFieldsin classNode
-
toString
-