org.gjt.xpp.impl.node

Class Node

Implemented Interfaces:
XmlNode, XmlStartTag, XmlTag
Known Direct 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 static Enumeration
EMPTY_ENUMERATION
protected Vector
children
protected int
childrenCount
protected String[]
declaredNs
protected int
declaredNsEnd
protected String[]
declaredPrefixes
protected String
defaultNamespaceUri
protected Object
oneChild
protected XmlNode
parent
protected Hashtable
prefix2Ns

Constructor Summary

Node()

Method Summary

void
addDeclaredNamespaces(String[] prefix, int off, int len, String[] namespaceUri)
NOTE: node SHOULD NOT keep references to passed arrays!
void
addNamespaceDeclaration(String prefix, String namespaceUri)
void
appendChild(Object child)
Enumeration
children()
void
ensureChildrenCapacity(int minCapacity)
void
ensureDeclaredNamespacesCapacity(int minCapacity)
boolean
equals(Object o)
Object
getChildAt(int pos)
int
getChildrenCount()
it may need to reconsruct whole subtree to get count ...
int
getDeclaredNamespaceLength()
String
getDefaultNamespaceUri()
Namesapce URI associated with default namesapce prefix (xmlns='....')
XmlNode
getParentNode()
String
getQNameLocal(String qName)
Return local part of qname.
String
getQNameUri(String qName)
Return uri part of qname.
void
insertChildAt(int pos, Object child)
String
namespace2Prefix(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(String namespaceUri, String localName)
String
prefix2Namespace(String prefix)
return namespace for prefix searching node tree upward.
protected void
printFields(StringBuffer buf)
Print into StringBuffer element name
void
readDeclaredNamespaceUris(String[] uris, int off, int len)
void
readDeclaredPrefixes(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, Object child)
void
resetNode()
Clear all Tag state to default values.
void
setDefaultNamespaceUri(String defaultNamespaceUri)
Set default namesapce URI (xmlns='....')
void
setParentNode(XmlNode parent)
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, equals, getAttributeCount, getAttributeLocalName, getAttributeNamespaceUri, getAttributePrefix, getAttributeRawName, getAttributeValue, getAttributeValueFromName, getAttributeValueFromRawName, isAttributeNamespaceDeclaration, printFields, removeAttributeByName, removeAttributeByRawName, removeAttributes, resetStartTag, toString

Methods inherited from class org.gjt.xpp.impl.tag.Tag

equals, getLocalName, getNamespaceUri, getPrefix, getRawName, hashCode, modifyTag, printFields, resetTag

Field Details

EMPTY_ENUMERATION

protected static final Enumeration EMPTY_ENUMERATION

children

protected Vector children

childrenCount

protected int childrenCount

declaredNs

protected String[] declaredNs

declaredNsEnd

protected int declaredNsEnd

declaredPrefixes

protected String[] declaredPrefixes

defaultNamespaceUri

protected String defaultNamespaceUri

oneChild

protected Object oneChild

parent

protected XmlNode parent

prefix2Ns

protected Hashtable prefix2Ns

Constructor Details

Node

public Node()

Method Details

addDeclaredNamespaces

public void addDeclaredNamespaces(String[] prefix,
                                  int off,
                                  int len,
                                  String[] namespaceUri)
NOTE: node SHOULD NOT keep references to passed arrays!
Specified by:
addDeclaredNamespaces in interface XmlNode

addNamespaceDeclaration

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

appendChild

public void appendChild(Object child)
            throws XmlPullParserException
Specified by:
appendChild in interface XmlNode

children

public Enumeration children()
Specified by:
children in interface XmlNode

ensureChildrenCapacity

public void ensureChildrenCapacity(int minCapacity)
            throws XmlPullParserException
Specified by:
ensureChildrenCapacity in interface XmlNode

ensureDeclaredNamespacesCapacity

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

equals

public boolean equals(Object o)
Overrides:
equals in interface StartTag

getChildAt

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

getChildrenCount

public int getChildrenCount()
it may need to reconsruct whole subtree to get count ...
Specified by:
getChildrenCount in interface XmlNode

getDeclaredNamespaceLength

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

getDefaultNamespaceUri

public String getDefaultNamespaceUri()
Namesapce URI associated with default namesapce prefix (xmlns='....')
Specified by:
getDefaultNamespaceUri in interface XmlNode

getParentNode

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

getQNameLocal

public String getQNameLocal(String qName)
Return local part of qname. For example for 'xsi:type' it returns 'type'.
Specified by:
getQNameLocal in interface XmlNode

getQNameUri

public String getQNameUri(String qName)
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

insertChildAt

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

namespace2Prefix

public String namespace2Prefix(String namespaceUri)
            throws XmlPullParserException
return prefix for namesapce searching node tree upward.
Specified by:
namespace2Prefix 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

newNode

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

prefix2Namespace

public String prefix2Namespace(String prefix)
            throws XmlPullParserException
return namespace for prefix searching node tree upward.
Specified by:
prefix2Namespace in interface XmlNode

printFields

protected void printFields(StringBuffer buf)
Print into StringBuffer element name
Overrides:
printFields in interface StartTag

readDeclaredNamespaceUris

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

readDeclaredPrefixes

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

removeChildAt

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

removeChildren

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

removeDeclaredNamespaces

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

replaceChildAt

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

resetNode

public void resetNode()
Clear all Tag state to default values.
Specified by:
resetNode in interface XmlNode

setDefaultNamespaceUri

public void setDefaultNamespaceUri(String defaultNamespaceUri)
Set default namesapce URI (xmlns='....')
Specified by:
setDefaultNamespaceUri in interface XmlNode

setParentNode

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

toString

public String toString()
Return string representation of start tag including name and list of attributes.
Overrides:
toString in interface 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