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 TypeMethodDescriptionvoidaddDeclaredNamespaces(String[] prefix, int off, int len, String[] namespaceUri) NOTE: node SHOULD NOT keep references to passed arrays!voidaddNamespaceDeclaration(String prefix, String namespaceUri) voidappendChild(Object child) children()voidensureChildrenCapacity(int minCapacity) voidensureDeclaredNamespacesCapacity(int minCapacity) getChildAt(int pos) intit may need to reconsruct whole subtree to get count ...intNamesapce URI associated with default namesapce prefix (xmlns='....')getQNameLocal(String qName) Return local part of qname.getQNameUri(String qName) Return uri part of qname.voidinsertChildAt(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.voidreadDeclaredNamespaceUris(String[] uris, int off, int len) voidreadDeclaredPrefixes(String[] prefixes, int off, int len) voidremoveChildAt(int pos) voidRemoves all children - every child that was implementing XmlNode will have set parent to null.voidvoidreplaceChildAt(int pos, Object child) voidClear all Tag state to default values.voidsetDefaultNamespaceUri(String defaultNamespaceUri) Set default namesapce URI (xmlns='....')voidsetParentNode(XmlNode parent) Methods inherited from interface XmlStartTag
addAttribute, addAttribute, ensureAttributesCapacity, getAttributeCount, getAttributeLocalName, getAttributeNamespaceUri, getAttributePrefix, getAttributeRawName, getAttributeValue, getAttributeValueFromName, getAttributeValueFromRawName, isAttributeNamespaceDeclaration, removeAttributeByName, removeAttributeByRawName, removeAttributes, resetStartTagMethods inherited from interface 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
-