|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jvoicexml.xml.AbstractXmlNode
public abstract class AbstractXmlNode
Abstract base class for all nodes in an XML document.
Copyright © 2005-2006 JVoiceXML group - http://jvoicexml.sourceforge.net/
XmlDocument| Field Summary |
|---|
| Constructor Summary | |
|---|---|
protected |
AbstractXmlNode(Node n,
XmlNodeFactory<? extends XmlNode> nodeFactory)
Construct a new XmlNode. |
| Method Summary | ||
|---|---|---|
|
addChild(Class<T> tagClass)
Adds an instance of the specified child class to this node. |
|
XmlNode |
addChild(String tagName)
Adds an instance of the specified child class to this node. |
|
Node |
appendChild(Node newChild)
Adds the node newChild to the end of the list of children
of this node. |
|
protected abstract boolean |
canContainChild(String childName)
Can the specified sub-tag be contained within this node? |
|
Node |
cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. |
|
short |
compareDocumentPosition(Node other)
Compares the reference node, i.e. |
|
String |
getAttribute(String attribute)
Convenient method to get the value of an attribute. |
|
Collection<String> |
getAttributeNames()
Returns a collection of permitted attribute names for the node. |
|
NamedNodeMap |
getAttributes()
A NamedNodeMap containing the attributes of this node (if
it is an Element) or null otherwise. |
|
String |
getBaseURI()
The absolute base URI of this node or null if the
implementation wasn't able to obtain an absolute URI. |
|
|
getChildNodes(Class<T> tagClass)
Return a collection of child nodes with the specified tag class. |
|
Object |
getFeature(String feature,
String version)
This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in . |
|
Node |
getFirstChild()
The first child of this node. |
|
Node |
getLastChild()
The last child of this node. |
|
String |
getLocalName()
Returns the local part of the qualified name of this node. |
|
String |
getNamespaceURI()
The namespace URI of this node, or null if it is
unspecified. |
|
Node |
getNextSibling()
The node immediately following this node. |
|
Node |
getNode()
Retrieves the encapsulated node. |
|
protected XmlNodeFactory<? extends XmlNode> |
getNodeFactory()
Retrieves the factory to create node lists. |
|
String |
getNodeName()
The name of this node, depending on its type; see the table above. |
|
short |
getNodeType()
A code representing the type of the underlying object, as defined above. |
|
String |
getNodeValue()
The value of this node, depending on its type; see the table above. |
|
Document |
getOwnerDocument()
The Document object associated with this node. |
|
Node |
getParentNode()
The parent of this node. |
|
String |
getPrefix()
The namespace prefix of this node, or null if it is
unspecified. |
|
Node |
getPreviousSibling()
The node immediately preceding this node. |
|
String |
getTextContent()
This attribute returns the text content of this node and its descendants. |
|
Object |
getUserData(String key)
Retrieves the object associated to a key on a this node. |
|
boolean |
hasAttributes()
Returns whether this node (if it is an element) has any attributes. |
|
boolean |
hasChildNodes()
Returns whether this node has any children. |
|
Node |
insertBefore(Node newChild,
Node refChild)
Inserts the node newChild before the existing child node
refChild. |
|
boolean |
isDefaultNamespace(String namespaceURI)
This method checks if the specified namespaceURI is the
default namespace or not. |
|
boolean |
isEqualNode(Node arg)
Tests whether two nodes are equal. |
|
boolean |
isSameNode(Node other)
Returns whether this node is the same node as the given one. |
|
boolean |
isSupported(String feature,
String version)
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node. |
|
String |
lookupNamespaceURI(String prefix)
Look up the namespace URI associated to the given prefix, starting from this node. |
|
String |
lookupPrefix(String namespaceURI)
Look up the prefix associated to the given namespace URI, starting from this node. |
|
void |
normalize()
Puts all Text nodes in the full depth of the sub-tree
underneath this Node, including attribute nodes, into a
"normal" form where only structure (e.g., elements, comments, processing
instructions, CDATA sections, and entity references) separates
Text nodes, i.e., there are neither adjacent
Text nodes nor empty Text nodes. |
|
Node |
removeChild(Node oldChild)
Removes the child node indicated by oldChild from the list
of children, and returns it. |
|
Node |
replaceChild(Node newChild,
Node oldChild)
Replaces the child node oldChild with
newChild in the list of children, and returns the
oldChild node. |
|
void |
setAttribute(String name,
String value)
Convenient method to set the value of an attribute. |
|
void |
setNodeValue(String nodeValue)
The value of this node, depending on its type; see the table above. |
|
void |
setPrefix(String prefix)
The namespace prefix of this node, or null if it is
unspecified. |
|
void |
setTextContent(String textContent)
This attribute returns the text content of this node and its descendants. |
|
Object |
setUserData(String key,
Object data,
UserDataHandler handler)
Associate an object to a key on this node. |
|
String |
toString()
Returns a string representation of the object. |
|
void |
writeChildrenXml(XmlWriter writer)
Used to write any children of a node. |
|
void |
writeXml(XmlWriter writer)
This is the primary method used to write an object and its children as XML text. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.jvoicexml.xml.XmlNode |
|---|
getTagName, newInstance |
| Methods inherited from interface org.w3c.dom.Node |
|---|
getChildNodes |
| Constructor Detail |
|---|
protected AbstractXmlNode(Node n,
XmlNodeFactory<? extends XmlNode> nodeFactory)
n - The encapsulated node.nodeFactory - Node factory to create node lists.| Method Detail |
|---|
public final Node getNode()
getNode in interface XmlNodeprotected final XmlNodeFactory<? extends XmlNode> getNodeFactory()
public final String getAttribute(String attribute)
getAttribute in interface XmlNodeattribute - Name of the attribute.
null if the value of the
attribute cannot be retrieved.
public final void setAttribute(String name,
String value)
null then the attribute is removed.
setAttribute in interface XmlNodename - Name of the attribute.value - New value of the attribute or null to remove the
attribute.
public final Node appendChild(Node newChild)
throws DOMException
newChild to the end of the list of children
of this node.
appendChild in interface NodenewChild - The node to add.If it is a DocumentFragment object,
the entire contents of the document fragment are moved into the
child list of this node
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does
not allow children of the type of the newChild
node, or if the node to append is one of this node's ancestors or
this node itself. newChild was created
from a different document than the one that created this node.
public final Node cloneNode(boolean deep)
cloneNode in interface Nodedeep - If true, recursively clone the subtree under the
specified node; if false, clone only the node
itself (and its attributes, if it is an Element).
public final NamedNodeMap getAttributes()
NamedNodeMap containing the attributes of this node (if
it is an Element) or null otherwise.
getAttributes in interface Nodepublic final String getLocalName()
getLocalName in interface Nodepublic final String getNamespaceURI()
null if it is
unspecified.
getNamespaceURI in interface Nodepublic final String getNodeName()
getNodeName in interface Nodepublic final short getNodeType()
getNodeType in interface Node
public final String getNodeValue()
throws DOMException
getNodeValue in interface NodeDOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters
than fit in a DOMString variable on the
implementation platform.public final Document getOwnerDocument()
Document object associated with this node.
getOwnerDocument in interface Nodepublic final String getPrefix()
null if it is
unspecified.
getPrefix in interface Nodepublic final Object getUserData(String key)
getUserData in interface Nodekey - The key the object is associated to.
null if there was none.public final boolean hasAttributes()
hasAttributes in interface Nodetrue if this node has any attributes,
false otherwise.public final boolean hasChildNodes()
hasChildNodes in interface Nodetrue if this node has any children,
false otherwise.
public final Node insertBefore(Node newChild,
Node refChild)
throws DOMException
newChild before the existing child node
refChild.
insertBefore in interface NodenewChild - The node to insert.refChild - The reference node, i.e., the node before which the new node must
be inserted.
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does
not allow children of the type of the newChild
node, or if the node to insert is one of this node's ancestors or
this node itself. newChild was created
from a different document than the one that created this node.
refChild is not a child
of this node.
public final boolean isSupported(String feature,
String version)
isSupported in interface Nodefeature - The name of the feature to test. This is the same name which can
be passed to the method hasFeature on
DOMImplementation.version - This is the version number of the feature to test. In Level 2,
version 1, this is the string "2.0". If the version is not
specified, supporting any version of the feature will cause the
method to return true.
true if the specified feature is supported
on this node, false otherwise.public final void normalize()
Text nodes in the full depth of the sub-tree
underneath this Node, including attribute nodes, into a
"normal" form where only structure (e.g., elements, comments, processing
instructions, CDATA sections, and entity references) separates
Text nodes, i.e., there are neither adjacent
Text nodes nor empty Text nodes.
normalize in interface Node
public final Node removeChild(Node oldChild)
throws DOMException
oldChild from the list
of children, and returns it.
removeChild in interface NodeoldChild - The node being removed.
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
oldChild is not a child
of this node.
public final Node replaceChild(Node newChild,
Node oldChild)
throws DOMException
oldChild with
newChild in the list of children, and returns the
oldChild node.
replaceChild in interface NodenewChild - The new node to put in the child list.oldChild - The node being replaced in the list.
DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does
not allow children of the type of the newChild
node, or if the node to put in is one of this node's ancestors or
this node itself. newChild was created
from a different document than the one that created this node.
oldChild is not a child
of this node.
public final void setNodeValue(String nodeValue)
throws DOMException
setNodeValue in interface NodenodeValue - String
DOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters
than fit in a DOMString variable on the
implementation platform.
public final void setPrefix(String prefix)
throws DOMException
null if it is
unspecified.
setPrefix in interface Nodeprefix - String
DOMException - INVALID_CHARACTER_ERR: Raised if the specified prefix contains an
illegal character, per the XML 1.0 specification . prefix is
malformed per the Namespaces in XML specification, if the
namespaceURI of this node is null,
if the specified prefix is "xml" and the
namespaceURI of this node is different from
"http://www.w3.org/XML/1998/namespace", if this node is an
attribute and the specified prefix is "xmlns" and the
namespaceURI of this node is different from "
http://www.w3.org/2000/xmlns/", or if this node is an attribute
and the qualifiedName of this node is "xmlns" .
public Object setUserData(String key,
Object data,
UserDataHandler handler)
setUserData in interface Nodekey - The key to associate the object to.data - The object to associate to the given key, or null
to remove any existing association to that key.handler - The handler to associate to that key, or null
DOMUserData previously associated to
the given key on this node, or null if there was
none.public final Node getFirstChild()
getFirstChild in interface Nodepublic final Node getLastChild()
getLastChild in interface Nodepublic final Node getNextSibling()
getNextSibling in interface Nodepublic final Node getPreviousSibling()
getPreviousSibling in interface Nodepublic final Node getParentNode()
getParentNode in interface Node
public void writeXml(XmlWriter writer)
throws IOException
writeXml in interface XmlWritablewriter - XMLWriter used when writing XML text.
IOException - Error in writing.
public void writeChildrenXml(XmlWriter writer)
throws IOException
writeChildrenXml in interface XmlWritablewriter - XMLWriter used when writing XML text.
IOException - Error in writing.public String getBaseURI()
null if the
implementation wasn't able to obtain an absolute URI.
getBaseURI in interface Node
public short compareDocumentPosition(Node other)
throws DOMException
compareDocumentPosition in interface Nodeother - The node to compare against the reference node.
DOMException - NOT_SUPPORTED_ERR: when the compared nodes are from different DOM
implementations that do not coordinate to return consistent
implementation-specific results.
public String getTextContent()
throws DOMException
getTextContent in interface NodeDOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters
than fit in a DOMString variable on the
implementation platform.
public void setTextContent(String textContent)
throws DOMException
setTextContent in interface NodetextContent - String
DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.public boolean isSameNode(Node other)
isSameNode in interface Nodeother - The node to test against.
true if the nodes are the same,
false otherwise.public String lookupPrefix(String namespaceURI)
lookupPrefix in interface NodenamespaceURI - The namespace URI to look for.
null if none is found. If more than one prefix are
associated to the namespace prefix, the returned namespace prefix
is implementation dependent.public boolean isDefaultNamespace(String namespaceURI)
namespaceURI is the
default namespace or not.
isDefaultNamespace in interface NodenamespaceURI - The namespace URI to look for.
true if the specified
namespaceURI is the default namespace,
false otherwise.public String lookupNamespaceURI(String prefix)
lookupNamespaceURI in interface Nodeprefix - The prefix to look for. If this parameter is null,
the method will return the default namespace URI if any.
null if
none is found.public boolean isEqualNode(Node arg)
isEqualNode in interface Nodearg - The node to compare equality with.
true if the nodes are equal,
false otherwise.
public Object getFeature(String feature,
String version)
getFeature in interface Nodefeature - The name of the feature requested. Note that any plus sign "+"
prepended to the name of the feature will be ignored since it is
not significant in the context of this method.version - This is the version number of the feature to test.
null if
there is no object which implements interfaces associated with
that feature. If the DOMObject returned by this
method implements the Node interface, it must
delegate to the primary core Node and not return
results inconsistent with the primary core Node
such as attributes, childNodes, etc.public <T extends XmlNode> T addChild(Class<T> tagClass)
T - Node type to load.tagClass - The class type of the node to add.
public XmlNode addChild(String tagName)
addChild in interface XmlNodetagName - The tag name of the node to add.
public <T extends XmlNode> Collection<T> getChildNodes(Class<T> tagClass)
getChildNodes in interface XmlNodeT - Type of the child nodes.tagClass - Class of child node to return.
protected abstract boolean canContainChild(String childName)
childName - Name of child.
public String toString()
toString in class Objectpublic Collection<String> getAttributeNames()
getAttributeNames in interface XmlNode
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||