Package org.gjt.xpp
Interface XmlNode
- All Superinterfaces:
XmlStartTag
,XmlTag
- All Known Subinterfaces:
XmlPullNode
This class represents XML subtree.
XmlNode is extension of XmlStartTag adding support for children
(some of them may be also XmlNode so we get recursively built tree)
and namespaces declarations associated with this node.
When node has no children and namespaces declared it is
essentially equivalent to XmlStartTag.
When XmlNode user does not need namespaces then namespace related methods may be ignored. However to use namespaces it is required to:
- call setDefaultNamespaceUri() to associate default namespace in which this node is declared
- and to declare additional namespaces (as of xmlns:prefix="...") with calling first removeNamespaces() and then addNamespaces()
- Author:
- Aleksander Slominski
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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) children()
void
ensureChildrenCapacity
(int minCapacity) void
ensureDeclaredNamespacesCapacity
(int minCapacity) getChildAt
(int pos) int
it may need to reconsruct whole subtree to get count ...int
Namesapce URI associated with default namesapce prefix (xmlns='....')getQNameLocal
(String qName) Return local part of qname.getQNameUri
(String qName) Return uri part of qname.void
insertChildAt
(int pos, Object child) namespace2Prefix
(String namespaceUri) return prefix for namesapce searching node tree upward.newNode()
context sensitive factory method to create the same type of nodeprefix2Namespace
(String prefix) return namespace for prefix searching node tree upward.void
readDeclaredNamespaceUris
(String[] uris, int off, int len) void
readDeclaredPrefixes
(String[] prefixes, int off, int len) void
removeChildAt
(int pos) void
Removes all children - every child that was implementing XmlNode will have set parent to null.void
void
replaceChildAt
(int pos, Object child) void
Clear all Tag state to default values.void
setDefaultNamespaceUri
(String defaultNamespaceUri) Set default namesapce URI (xmlns='....')void
setParentNode
(XmlNode parent) 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
-
Method Details
-
resetNode
void resetNode()Clear all Tag state to default values. -
newNode
context sensitive factory method to create the same type of node- Throws:
XmlPullParserException
-
newNode
- Throws:
XmlPullParserException
-
getParentNode
XmlNode getParentNode() -
setParentNode
- Throws:
XmlPullParserException
-
children
Enumeration children() -
getChildrenCount
int getChildrenCount()it may need to reconsruct whole subtree to get count ... -
getChildAt
-
appendChild
- Throws:
XmlPullParserException
-
insertChildAt
- Throws:
XmlPullParserException
-
removeChildAt
- Throws:
XmlPullParserException
-
replaceChildAt
- Throws:
XmlPullParserException
-
ensureChildrenCapacity
- Throws:
XmlPullParserException
-
removeChildren
Removes all children - every child that was implementing XmlNode will have set parent to null.- Throws:
XmlPullParserException
-
getQNameLocal
Return local part of qname. For example for 'xsi:type' it returns 'type'.- Throws:
XmlPullParserException
-
getQNameUri
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'.- Throws:
XmlPullParserException
-
prefix2Namespace
return namespace for prefix searching node tree upward.- Throws:
XmlPullParserException
-
namespace2Prefix
return prefix for namesapce searching node tree upward.- Throws:
XmlPullParserException
-
getDefaultNamespaceUri
String getDefaultNamespaceUri()Namesapce URI associated with default namesapce prefix (xmlns='....') -
setDefaultNamespaceUri
Set default namesapce URI (xmlns='....')- Throws:
XmlPullParserException
-
getDeclaredNamespaceLength
int getDeclaredNamespaceLength() -
readDeclaredNamespaceUris
- Throws:
XmlPullParserException
-
readDeclaredPrefixes
- Throws:
XmlPullParserException
-
ensureDeclaredNamespacesCapacity
- Throws:
XmlPullParserException
-
addNamespaceDeclaration
- Throws:
XmlPullParserException
-
addDeclaredNamespaces
void addDeclaredNamespaces(String[] prefix, int off, int len, String[] namespaceUri) throws XmlPullParserException NOTE: node SHOULD NOT keep references to passed arrays!- Throws:
XmlPullParserException
-
removeDeclaredNamespaces
- Throws:
XmlPullParserException
-