org.gjt.xpp.impl.node
Class Node

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
All Implemented Interfaces:
XmlNode, XmlStartTag, XmlTag
Direct Known Subclasses:
PullNode

public class Node
extends StartTag
implements XmlNode

Encapsulate XML Node with list of associated children and namespaces :-).

Author:
Aleksander Slominski

Field Summary
protected  java.util.Vector children
           
protected  int childrenCount
           
protected  java.lang.String[] declaredNs
           
protected  int declaredNsEnd
           
protected  java.lang.String[] declaredPrefixes
           
protected  java.lang.String defaultNamespaceUri
           
protected static java.util.Enumeration EMPTY_ENUMERATION
           
protected  java.lang.Object oneChild
           
protected  XmlNode parent
           
protected  java.util.Hashtable prefix2Ns
           
 
Constructor Summary
Node()
           
 
Method Summary
 void addDeclaredNamespaces(java.lang.String[] prefix, int off, int len, java.lang.String[] namespaceUri)
          NOTE: node SHOULD NOT keep references to passed arrays!
 void addNamespaceDeclaration(java.lang.String prefix, java.lang.String namespaceUri)
           
 void appendChild(java.lang.Object child)
           
 java.util.Enumeration children()
           
 void ensureChildrenCapacity(int minCapacity)
           
 void ensureDeclaredNamespacesCapacity(int minCapacity)
           
 boolean equals(java.lang.Object o)
           
 java.lang.Object getChildAt(int pos)
           
 int getChildrenCount()
          it may need to reconsruct whole subtree to get count ...
 int getDeclaredNamespaceLength()
           
 java.lang.String getDefaultNamespaceUri()
          Namesapce URI associated with default namesapce prefix (xmlns='....')
 XmlNode getParentNode()
           
 java.lang.String getQNameLocal(java.lang.String qName)
          Return local part of qname.
 java.lang.String getQNameUri(java.lang.String qName)
          Return uri part of qname.
 void insertChildAt(int pos, java.lang.Object child)
           
 java.lang.String namespace2Prefix(java.lang.String namespaceUri)
          return prefix for namesapce searching node tree upward.
 XmlNode newNode()
          context sensitive factory method to create the same type of node
 XmlNode newNode(java.lang.String namespaceUri, java.lang.String localName)
           
 java.lang.String prefix2Namespace(java.lang.String prefix)
          return namespace for prefix searching node tree upward.
protected  void printFields(java.lang.StringBuffer buf)
          Print into StringBuffer element name
 void readDeclaredNamespaceUris(java.lang.String[] uris, int off, int len)
           
 void readDeclaredPrefixes(java.lang.String[] prefixes, int off, int len)
           
 void removeChildAt(int pos)
           
 void removeChildren()
          Removes all children - every child that was implementing XmlNode will have set parent to null.
 void removeDeclaredNamespaces()
           
 void replaceChildAt(int pos, java.lang.Object child)
           
 void resetNode()
          Clear all Tag state to default values.
 void setDefaultNamespaceUri(java.lang.String defaultNamespaceUri)
          Set default namesapce URI (xmlns='....')
 void setParentNode(XmlNode parent)
           
 java.lang.String toString()
          Return string representation of start tag including name and list of attributes.
 
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.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

EMPTY_ENUMERATION

protected static final java.util.Enumeration EMPTY_ENUMERATION

children

protected java.util.Vector children

childrenCount

protected int childrenCount

oneChild

protected java.lang.Object oneChild

parent

protected XmlNode parent

defaultNamespaceUri

protected java.lang.String defaultNamespaceUri

prefix2Ns

protected java.util.Hashtable prefix2Ns

declaredNsEnd

protected int declaredNsEnd

declaredNs

protected java.lang.String[] declaredNs

declaredPrefixes

protected java.lang.String[] declaredPrefixes
Constructor Detail

Node

public Node()
Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class StartTag

resetNode

public void resetNode()
Description copied from interface: XmlNode
Clear all Tag state to default values.

Specified by:
resetNode in interface XmlNode

newNode

public XmlNode newNode()
                throws XmlPullParserException
context sensitive factory method to create the same type of node

Specified by:
newNode in interface XmlNode
Throws:
XmlPullParserException

newNode

public XmlNode newNode(java.lang.String namespaceUri,
                       java.lang.String localName)
                throws XmlPullParserException
Specified by:
newNode in interface XmlNode
Throws:
XmlPullParserException

getParentNode

public XmlNode getParentNode()
Specified by:
getParentNode in interface XmlNode

children

public java.util.Enumeration children()
Specified by:
children in interface XmlNode

getChildrenCount

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

Specified by:
getChildrenCount in interface XmlNode

getChildAt

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

setParentNode

public void setParentNode(XmlNode parent)
Specified by:
setParentNode in interface XmlNode

appendChild

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

insertChildAt

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

removeChildAt

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

replaceChildAt

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

ensureChildrenCapacity

public void ensureChildrenCapacity(int minCapacity)
                            throws XmlPullParserException
Specified by:
ensureChildrenCapacity in interface XmlNode
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
Throws:
XmlPullParserException

getQNameLocal

public java.lang.String getQNameLocal(java.lang.String qName)
Description copied from interface: XmlNode
Return local part of qname. For example for 'xsi:type' it returns 'type'.

Specified by:
getQNameLocal in interface XmlNode

getQNameUri

public java.lang.String getQNameUri(java.lang.String qName)
Description copied from interface: XmlNode
Return uri part of qname. The return value is dependent on declared namespaces in this node and possible when looking for value in parent node. For example for 'xsi:type' if xsi namespace prefix was declared to 'http://foo' it will return 'http://foo'.

Specified by:
getQNameUri in interface XmlNode

prefix2Namespace

public java.lang.String prefix2Namespace(java.lang.String prefix)
                                  throws XmlPullParserException
Description copied from interface: XmlNode
return namespace for prefix searching node tree upward.

Specified by:
prefix2Namespace in interface XmlNode
Throws:
XmlPullParserException

namespace2Prefix

public java.lang.String namespace2Prefix(java.lang.String namespaceUri)
                                  throws XmlPullParserException
Description copied from interface: XmlNode
return prefix for namesapce searching node tree upward.

Specified by:
namespace2Prefix in interface XmlNode
Throws:
XmlPullParserException

getDefaultNamespaceUri

public java.lang.String getDefaultNamespaceUri()
Description copied from interface: XmlNode
Namesapce URI associated with default namesapce prefix (xmlns='....')

Specified by:
getDefaultNamespaceUri in interface XmlNode

setDefaultNamespaceUri

public void setDefaultNamespaceUri(java.lang.String defaultNamespaceUri)
Description copied from interface: XmlNode
Set default namesapce URI (xmlns='....')

Specified by:
setDefaultNamespaceUri in interface XmlNode

getDeclaredNamespaceLength

public int getDeclaredNamespaceLength()
Specified by:
getDeclaredNamespaceLength in interface XmlNode

readDeclaredNamespaceUris

public void readDeclaredNamespaceUris(java.lang.String[] uris,
                                      int off,
                                      int len)
Specified by:
readDeclaredNamespaceUris in interface XmlNode

readDeclaredPrefixes

public void readDeclaredPrefixes(java.lang.String[] prefixes,
                                 int off,
                                 int len)
Specified by:
readDeclaredPrefixes in interface XmlNode

ensureDeclaredNamespacesCapacity

public void ensureDeclaredNamespacesCapacity(int minCapacity)
Specified by:
ensureDeclaredNamespacesCapacity in interface XmlNode

addNamespaceDeclaration

public void addNamespaceDeclaration(java.lang.String prefix,
                                    java.lang.String namespaceUri)
                             throws XmlPullParserException
Specified by:
addNamespaceDeclaration in interface XmlNode
Throws:
XmlPullParserException

addDeclaredNamespaces

public void addDeclaredNamespaces(java.lang.String[] prefix,
                                  int off,
                                  int len,
                                  java.lang.String[] namespaceUri)
Description copied from interface: XmlNode
NOTE: node SHOULD NOT keep references to passed arrays!

Specified by:
addDeclaredNamespaces in interface XmlNode

removeDeclaredNamespaces

public void removeDeclaredNamespaces()
Specified by:
removeDeclaredNamespaces in interface XmlNode

printFields

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

Overrides:
printFields in class StartTag

toString

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

Overrides:
toString in class StartTag


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