org.gjt.xpp.impl.pullnode
Class PullNode

java.lang.Object
  extended by org.gjt.xpp.impl.tag.Tag
      extended by org.gjt.xpp.impl.tag.StartTag
          extended by org.gjt.xpp.impl.node.Node
              extended by 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
protected  int depth
           
protected  XmlPullParser pp
           
 
Fields inherited from class org.gjt.xpp.impl.node.Node
children, childrenCount, declaredNs, declaredNsEnd, declaredPrefixes, defaultNamespaceUri, EMPTY_ENUMERATION, oneChild, parent, prefix2Ns
 
Constructor Summary
PullNode(XmlPullParser pp)
           
 
Method Summary
 void appendChild(java.lang.Object child)
           
 java.util.Enumeration 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...
 java.lang.Object getChildAt(int pos)
           
 int getChildrenCount()
          it will reconsruct whole subtree to get count ...
 int getChildrenCountSoFar()
          if unfinished it returns actual number of children...
 XmlPullParser getPullParser()
          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, java.lang.Object child)
           
 boolean isFinished()
          Is pull parsing of node finished.
 XmlNode newNode()
          context sensitive factory method to create the same type of node
 XmlPullNode newPullNode(XmlPullParser pp)
           
protected  void printFields(java.lang.StringBuffer buf)
          Print this class state into StringBuffer element name
 void readChildren()
          Read all reminaing children up to end tag.
 java.lang.Object readNextChild()
          This is preferred method to pull children (children() requires .wrapping object Enumeration).
 void removeChildAt(int pos)
           
 void removeChildren()
          Removes all children - every child that was implementing XmlNode will have set parent to null.
 void replaceChildAt(int pos, java.lang.Object child)
           
 void resetPullNode()
          PullNode stays in finished state.
 void setPullParser(XmlPullParser pp)
          Reset pull node to use pull parser.
 void skipChildren()
           
 java.lang.String 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 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: Node
context sensitive factory method to create the same type of node

Specified by:
newNode in interface XmlNode
Specified by:
newNode in interface XmlPullNode
Overrides:
newNode in class Node
Throws:
XmlPullParserException

newPullNode

public XmlPullNode newPullNode(XmlPullParser pp)
                        throws XmlPullParserException
Specified by:
newPullNode in interface XmlPullNode
Throws:
XmlPullParserException

resetPullNode

public void resetPullNode()
PullNode stays in finished state.

Specified by:
resetPullNode in interface XmlPullNode

isFinished

public boolean isFinished()
Description copied from interface: XmlPullNode
Is pull parsing of node finished.

Specified by:
isFinished in interface XmlPullNode

getPullParser

public XmlPullParser getPullParser()
                            throws java.io.IOException,
                                   XmlPullParserException
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 interface XmlPullNode
Throws:
java.io.IOException
XmlPullParserException

setPullParser

public void setPullParser(XmlPullParser pp)
                   throws XmlPullParserException
Reset pull node to use pull parser. Pull Parser must be on START_TAG

Specified by:
setPullParser in interface XmlPullNode
Throws:
XmlPullParserException

children

public java.util.Enumeration 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...

Specified by:
children in interface XmlNode
Specified by:
children in interface XmlPullNode
Overrides:
children in class Node
See Also:
XmlPullNode.readNextChild()

readNextChild

public java.lang.Object readNextChild()
                               throws XmlPullParserException,
                                      java.io.IOException
Description copied from interface: XmlPullNode
This is preferred method to pull children (children() requires .wrapping object Enumeration).

Specified by:
readNextChild in interface XmlPullNode
Returns:
next child (which is String or XmlPullNode) or null if there is no re children
Throws:
XmlPullParserException
java.io.IOException
See Also:
XmlPullNode.children()

readChildren

public void readChildren()
                  throws XmlPullParserException,
                         java.io.IOException
Read all reminaing children up to end tag.

Specified by:
readChildren in interface XmlPullNode
Throws:
XmlPullParserException
java.io.IOException

skipChildren

public void skipChildren()
                  throws XmlPullParserException,
                         java.io.IOException
Specified by:
skipChildren in interface XmlPullNode
Throws:
XmlPullParserException
java.io.IOException

getChildrenCountSoFar

public int getChildrenCountSoFar()
if unfinished it returns actual number of children...

Specified by:
getChildrenCountSoFar in interface XmlPullNode

getChildrenCount

public int getChildrenCount()
it will reconsruct whole subtree to get count ...

Specified by:
getChildrenCount in interface XmlNode
Overrides:
getChildrenCount in class Node

getChildAt

public java.lang.Object getChildAt(int pos)
Specified by:
getChildAt in interface XmlNode
Overrides:
getChildAt in class Node

appendChild

public void appendChild(java.lang.Object child)
                 throws XmlPullParserException
Specified by:
appendChild in interface XmlNode
Overrides:
appendChild in class Node
Throws:
XmlPullParserException

insertChildAt

public void insertChildAt(int pos,
                          java.lang.Object child)
                   throws XmlPullParserException
Specified by:
insertChildAt in interface XmlNode
Overrides:
insertChildAt in class Node
Throws:
XmlPullParserException

removeChildAt

public void removeChildAt(int pos)
                   throws XmlPullParserException
Specified by:
removeChildAt in interface XmlNode
Overrides:
removeChildAt in class Node
Throws:
XmlPullParserException

replaceChildAt

public void replaceChildAt(int pos,
                           java.lang.Object child)
                    throws XmlPullParserException
Specified by:
replaceChildAt in interface XmlNode
Overrides:
replaceChildAt in class Node
Throws:
XmlPullParserException

removeChildren

public void removeChildren()
                    throws XmlPullParserException
Description copied from interface: XmlNode
Removes all children - every child that was implementing XmlNode will have set parent to null.

Specified by:
removeChildren in interface XmlNode
Overrides:
removeChildren in class Node
Throws:
XmlPullParserException

printFields

protected void printFields(java.lang.StringBuffer buf)
Print this class state into StringBuffer element name

Overrides:
printFields in class Node

toString

public java.lang.String toString()
Return string representation of start tag including name and list of attributes.

Overrides:
toString in class Node


Copyright (c) 2003 IU Extreme! Lab http://www.extreme.indiana.edu/ All Rights Reserved.

Note this package is deprecated by XPP3 that implements XmlPull API