Package org.gjt.xpp.impl.node
Class Node
- java.lang.Object
-
- org.gjt.xpp.impl.tag.Tag
-
- org.gjt.xpp.impl.tag.StartTag
-
- 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
Fields Modifier and Type Field Description 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
Constructors Constructor Description Node()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 nodeXmlNode
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 namevoid
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
-
-
Method Detail
-
resetNode
public void resetNode()
Description copied from interface:XmlNode
Clear all Tag state to default values.
-
newNode
public XmlNode newNode() throws XmlPullParserException
context sensitive factory method to create the same type of node- Specified by:
newNode
in interfaceXmlNode
- Throws:
XmlPullParserException
-
newNode
public XmlNode newNode(java.lang.String namespaceUri, java.lang.String localName) throws XmlPullParserException
- Specified by:
newNode
in interfaceXmlNode
- Throws:
XmlPullParserException
-
getParentNode
public XmlNode getParentNode()
- Specified by:
getParentNode
in interfaceXmlNode
-
getChildrenCount
public int getChildrenCount()
it may need to reconsruct whole subtree to get count ...- Specified by:
getChildrenCount
in interfaceXmlNode
-
getChildAt
public java.lang.Object getChildAt(int pos)
- Specified by:
getChildAt
in interfaceXmlNode
-
setParentNode
public void setParentNode(XmlNode parent)
- Specified by:
setParentNode
in interfaceXmlNode
-
appendChild
public void appendChild(java.lang.Object child) throws XmlPullParserException
- Specified by:
appendChild
in interfaceXmlNode
- Throws:
XmlPullParserException
-
insertChildAt
public void insertChildAt(int pos, java.lang.Object child) throws XmlPullParserException
- Specified by:
insertChildAt
in interfaceXmlNode
- Throws:
XmlPullParserException
-
removeChildAt
public void removeChildAt(int pos) throws XmlPullParserException
- Specified by:
removeChildAt
in interfaceXmlNode
- Throws:
XmlPullParserException
-
replaceChildAt
public void replaceChildAt(int pos, java.lang.Object child) throws XmlPullParserException
- Specified by:
replaceChildAt
in interfaceXmlNode
- Throws:
XmlPullParserException
-
ensureChildrenCapacity
public void ensureChildrenCapacity(int minCapacity) throws XmlPullParserException
- Specified by:
ensureChildrenCapacity
in interfaceXmlNode
- 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 interfaceXmlNode
- 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 interfaceXmlNode
-
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 interfaceXmlNode
-
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 interfaceXmlNode
- 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 interfaceXmlNode
- 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 interfaceXmlNode
-
setDefaultNamespaceUri
public void setDefaultNamespaceUri(java.lang.String defaultNamespaceUri)
Description copied from interface:XmlNode
Set default namesapce URI (xmlns='....')- Specified by:
setDefaultNamespaceUri
in interfaceXmlNode
-
getDeclaredNamespaceLength
public int getDeclaredNamespaceLength()
- Specified by:
getDeclaredNamespaceLength
in interfaceXmlNode
-
readDeclaredNamespaceUris
public void readDeclaredNamespaceUris(java.lang.String[] uris, int off, int len)
- Specified by:
readDeclaredNamespaceUris
in interfaceXmlNode
-
readDeclaredPrefixes
public void readDeclaredPrefixes(java.lang.String[] prefixes, int off, int len)
- Specified by:
readDeclaredPrefixes
in interfaceXmlNode
-
ensureDeclaredNamespacesCapacity
public void ensureDeclaredNamespacesCapacity(int minCapacity)
- Specified by:
ensureDeclaredNamespacesCapacity
in interfaceXmlNode
-
addNamespaceDeclaration
public void addNamespaceDeclaration(java.lang.String prefix, java.lang.String namespaceUri) throws XmlPullParserException
- Specified by:
addNamespaceDeclaration
in interfaceXmlNode
- 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 interfaceXmlNode
-
removeDeclaredNamespaces
public void removeDeclaredNamespaces()
- Specified by:
removeDeclaredNamespaces
in interfaceXmlNode
-
printFields
protected void printFields(java.lang.StringBuffer buf)
Print into StringBuffer element name- Overrides:
printFields
in classStartTag
-
-