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.Vectorchildrenprotected intchildrenCountprotected java.lang.String[]declaredNsprotected intdeclaredNsEndprotected java.lang.String[]declaredPrefixesprotected java.lang.StringdefaultNamespaceUriprotected static java.util.EnumerationEMPTY_ENUMERATIONprotected java.lang.ObjectoneChildprotected XmlNodeparentprotected java.util.Hashtableprefix2Ns
-
Constructor Summary
Constructors Constructor Description Node()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDeclaredNamespaces(java.lang.String[] prefix, int off, int len, java.lang.String[] namespaceUri)NOTE: node SHOULD NOT keep references to passed arrays!voidaddNamespaceDeclaration(java.lang.String prefix, java.lang.String namespaceUri)voidappendChild(java.lang.Object child)java.util.Enumerationchildren()voidensureChildrenCapacity(int minCapacity)voidensureDeclaredNamespacesCapacity(int minCapacity)booleanequals(java.lang.Object o)java.lang.ObjectgetChildAt(int pos)intgetChildrenCount()it may need to reconsruct whole subtree to get count ...intgetDeclaredNamespaceLength()java.lang.StringgetDefaultNamespaceUri()Namesapce URI associated with default namesapce prefix (xmlns='....')XmlNodegetParentNode()java.lang.StringgetQNameLocal(java.lang.String qName)Return local part of qname.java.lang.StringgetQNameUri(java.lang.String qName)Return uri part of qname.voidinsertChildAt(int pos, java.lang.Object child)java.lang.Stringnamespace2Prefix(java.lang.String namespaceUri)return prefix for namesapce searching node tree upward.XmlNodenewNode()context sensitive factory method to create the same type of nodeXmlNodenewNode(java.lang.String namespaceUri, java.lang.String localName)java.lang.Stringprefix2Namespace(java.lang.String prefix)return namespace for prefix searching node tree upward.protected voidprintFields(java.lang.StringBuffer buf)Print into StringBuffer element namevoidreadDeclaredNamespaceUris(java.lang.String[] uris, int off, int len)voidreadDeclaredPrefixes(java.lang.String[] prefixes, int off, int len)voidremoveChildAt(int pos)voidremoveChildren()Removes all children - every child that was implementing XmlNode will have set parent to null.voidremoveDeclaredNamespaces()voidreplaceChildAt(int pos, java.lang.Object child)voidresetNode()Clear all Tag state to default values.voidsetDefaultNamespaceUri(java.lang.String defaultNamespaceUri)Set default namesapce URI (xmlns='....')voidsetParentNode(XmlNode parent)java.lang.StringtoString()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:XmlNodeClear 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:
newNodein interfaceXmlNode- Throws:
XmlPullParserException
-
newNode
public XmlNode newNode(java.lang.String namespaceUri, java.lang.String localName) throws XmlPullParserException
- Specified by:
newNodein interfaceXmlNode- Throws:
XmlPullParserException
-
getParentNode
public XmlNode getParentNode()
- Specified by:
getParentNodein interfaceXmlNode
-
getChildrenCount
public int getChildrenCount()
it may need to reconsruct whole subtree to get count ...- Specified by:
getChildrenCountin interfaceXmlNode
-
getChildAt
public java.lang.Object getChildAt(int pos)
- Specified by:
getChildAtin interfaceXmlNode
-
setParentNode
public void setParentNode(XmlNode parent)
- Specified by:
setParentNodein interfaceXmlNode
-
appendChild
public void appendChild(java.lang.Object child) throws XmlPullParserException- Specified by:
appendChildin interfaceXmlNode- Throws:
XmlPullParserException
-
insertChildAt
public void insertChildAt(int pos, java.lang.Object child) throws XmlPullParserException- Specified by:
insertChildAtin interfaceXmlNode- Throws:
XmlPullParserException
-
removeChildAt
public void removeChildAt(int pos) throws XmlPullParserException- Specified by:
removeChildAtin interfaceXmlNode- Throws:
XmlPullParserException
-
replaceChildAt
public void replaceChildAt(int pos, java.lang.Object child) throws XmlPullParserException- Specified by:
replaceChildAtin interfaceXmlNode- Throws:
XmlPullParserException
-
ensureChildrenCapacity
public void ensureChildrenCapacity(int minCapacity) throws XmlPullParserException- Specified by:
ensureChildrenCapacityin interfaceXmlNode- Throws:
XmlPullParserException
-
removeChildren
public void removeChildren() throws XmlPullParserExceptionDescription copied from interface:XmlNodeRemoves all children - every child that was implementing XmlNode will have set parent to null.- Specified by:
removeChildrenin interfaceXmlNode- Throws:
XmlPullParserException
-
getQNameLocal
public java.lang.String getQNameLocal(java.lang.String qName)
Description copied from interface:XmlNodeReturn local part of qname. For example for 'xsi:type' it returns 'type'.- Specified by:
getQNameLocalin interfaceXmlNode
-
getQNameUri
public java.lang.String getQNameUri(java.lang.String qName)
Description copied from interface:XmlNodeReturn 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:
getQNameUriin interfaceXmlNode
-
prefix2Namespace
public java.lang.String prefix2Namespace(java.lang.String prefix) throws XmlPullParserExceptionDescription copied from interface:XmlNodereturn namespace for prefix searching node tree upward.- Specified by:
prefix2Namespacein interfaceXmlNode- Throws:
XmlPullParserException
-
namespace2Prefix
public java.lang.String namespace2Prefix(java.lang.String namespaceUri) throws XmlPullParserExceptionDescription copied from interface:XmlNodereturn prefix for namesapce searching node tree upward.- Specified by:
namespace2Prefixin interfaceXmlNode- Throws:
XmlPullParserException
-
getDefaultNamespaceUri
public java.lang.String getDefaultNamespaceUri()
Description copied from interface:XmlNodeNamesapce URI associated with default namesapce prefix (xmlns='....')- Specified by:
getDefaultNamespaceUriin interfaceXmlNode
-
setDefaultNamespaceUri
public void setDefaultNamespaceUri(java.lang.String defaultNamespaceUri)
Description copied from interface:XmlNodeSet default namesapce URI (xmlns='....')- Specified by:
setDefaultNamespaceUriin interfaceXmlNode
-
getDeclaredNamespaceLength
public int getDeclaredNamespaceLength()
- Specified by:
getDeclaredNamespaceLengthin interfaceXmlNode
-
readDeclaredNamespaceUris
public void readDeclaredNamespaceUris(java.lang.String[] uris, int off, int len)- Specified by:
readDeclaredNamespaceUrisin interfaceXmlNode
-
readDeclaredPrefixes
public void readDeclaredPrefixes(java.lang.String[] prefixes, int off, int len)- Specified by:
readDeclaredPrefixesin interfaceXmlNode
-
ensureDeclaredNamespacesCapacity
public void ensureDeclaredNamespacesCapacity(int minCapacity)
- Specified by:
ensureDeclaredNamespacesCapacityin interfaceXmlNode
-
addNamespaceDeclaration
public void addNamespaceDeclaration(java.lang.String prefix, java.lang.String namespaceUri) throws XmlPullParserException- Specified by:
addNamespaceDeclarationin interfaceXmlNode- Throws:
XmlPullParserException
-
addDeclaredNamespaces
public void addDeclaredNamespaces(java.lang.String[] prefix, int off, int len, java.lang.String[] namespaceUri)Description copied from interface:XmlNodeNOTE: node SHOULD NOT keep references to passed arrays!- Specified by:
addDeclaredNamespacesin interfaceXmlNode
-
removeDeclaredNamespaces
public void removeDeclaredNamespaces()
- Specified by:
removeDeclaredNamespacesin interfaceXmlNode
-
printFields
protected void printFields(java.lang.StringBuffer buf)
Print into StringBuffer element name- Overrides:
printFieldsin classStartTag
-
-