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
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 org.gjt.xpp.impl.node.Node
children, childrenCount, declaredNs, declaredNsEnd, declaredPrefixes, defaultNamespaceUri, EMPTY_ENUMERATION, oneChild, parent, prefix2Ns
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendChild
(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) int
it will reconsruct whole subtree to get count ...int
if 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!!!!).void
insertChildAt
(int pos, Object child) boolean
Is pull parsing of node finished.newNode()
context sensitive factory method to create the same type of nodeprotected void
printFields
(StringBuffer buf) Print this class state into StringBuffer element namevoid
Read all reminaing children up to end tag.This is preferred method to pull children (children() requires .wrapping object Enumeration).void
removeChildAt
(int pos) void
Removes all children - every child that was implementing XmlNode will have set parent to null.void
replaceChildAt
(int pos, Object child) void
PullNode stays in finished state.void
Reset pull node to use pull parser.void
toString()
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 Details
-
depth
protected int depth -
pp
-
-
Constructor Details
-
PullNode
- Throws:
XmlPullParserException
-
-
Method Details
-
newNode
Description copied from class:Node
context sensitive factory method to create the same type of node- Specified by:
newNode
in interfaceXmlNode
- Specified by:
newNode
in interfaceXmlPullNode
- Overrides:
newNode
in classNode
- Throws:
XmlPullParserException
-
newPullNode
- Specified by:
newPullNode
in interfaceXmlPullNode
- Throws:
XmlPullParserException
-
resetPullNode
public void resetPullNode()PullNode stays in finished state.- Specified by:
resetPullNode
in interfaceXmlPullNode
-
isFinished
public boolean isFinished()Description copied from interface:XmlPullNode
Is pull parsing of node finished.- Specified by:
isFinished
in interfaceXmlPullNode
-
getPullParser
Description copied from interface:XmlPullNode
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!!!!). 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:
getPullParser
in interfaceXmlPullNode
- Throws:
IOException
XmlPullParserException
-
setPullParser
Reset pull node to use pull parser. Pull Parser must be on START_TAG- Specified by:
setPullParser
in interfaceXmlPullNode
- Throws:
XmlPullParserException
-
children
Description copied from interface:XmlPullNode
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... -
readNextChild
Description copied from interface:XmlPullNode
This is preferred method to pull children (children() requires .wrapping object Enumeration).- Specified by:
readNextChild
in interfaceXmlPullNode
- Returns:
- next child (which is String or XmlPullNode) or null if there is no re children
- Throws:
XmlPullParserException
IOException
- See Also:
-
readChildren
Read all reminaing children up to end tag.- Specified by:
readChildren
in interfaceXmlPullNode
- Throws:
XmlPullParserException
IOException
-
skipChildren
- Specified by:
skipChildren
in interfaceXmlPullNode
- Throws:
XmlPullParserException
IOException
-
getChildrenCountSoFar
public int getChildrenCountSoFar()if unfinished it returns actual number of children...- Specified by:
getChildrenCountSoFar
in interfaceXmlPullNode
-
getChildrenCount
public int getChildrenCount()it will reconsruct whole subtree to get count ...- Specified by:
getChildrenCount
in interfaceXmlNode
- Overrides:
getChildrenCount
in classNode
-
getChildAt
- Specified by:
getChildAt
in interfaceXmlNode
- Overrides:
getChildAt
in classNode
-
appendChild
- Specified by:
appendChild
in interfaceXmlNode
- Overrides:
appendChild
in classNode
- Throws:
XmlPullParserException
-
insertChildAt
- Specified by:
insertChildAt
in interfaceXmlNode
- Overrides:
insertChildAt
in classNode
- Throws:
XmlPullParserException
-
removeChildAt
- Specified by:
removeChildAt
in interfaceXmlNode
- Overrides:
removeChildAt
in classNode
- Throws:
XmlPullParserException
-
replaceChildAt
- Specified by:
replaceChildAt
in interfaceXmlNode
- Overrides:
replaceChildAt
in classNode
- Throws:
XmlPullParserException
-
removeChildren
Description copied from interface:XmlNode
Removes all children - every child that was implementing XmlNode will have set parent to null.- Specified by:
removeChildren
in interfaceXmlNode
- Overrides:
removeChildren
in classNode
- Throws:
XmlPullParserException
-
printFields
Print this class state into StringBuffer element name- Overrides:
printFields
in classNode
-
toString
Return string representation of start tag including name and list of attributes.
-