Qizx/open API

net.axyana.qizxopen.dm
Interface Node

All Known Subinterfaces:
XQNode
All Known Implementing Classes:
CoreDataModel.BaseNode, FONIDataModel.BaseNode, NodeBase, XQFONIDataModel.INode

public interface Node

Node as defined by the XQuery1/XPath2 Data Model, plus extensions.


Field Summary
static int ATOM_ANY
          Node nature (returned by getNature) for typed leaf node holding a value of any serializable class.
static int ATOM_BOOL
          Node nature (returned by getNature) for a typed leaf node holding a boolean value.
static int ATOM_DATE
          Node nature (returned by getNature) for typed leaf node holding a date/time value.
static int ATOM_DOUBLE
          Node nature (returned by getNature) for a typed leaf node holding a double value.
static int ATOM_INT
          Node nature (returned by getNature) for a typed integer node, holding a long integer value.
static int ATTRIBUTE
          Node nature (returned by getNature) for an Attribute node.
static int COMMENT
          Node nature (returned by getNature) for a Comment node.
static int DOCUMENT
          Node nature (returned by getNature) for a document node.
static int ELEMENT
          Node nature (returned by getNature) for an Element node.
static int NAMESPACE
          Node nature (returned by getNature) for a naemespacenode.
static int PROCESSING_INSTRUCTION
          Node nature (returned by getNature) for a processing instruction node.
static int TEXT
          Node nature (returned by getNature) for a leaf text node.
 
Method Summary
 void addText(java.lang.String text)
          Adds text inside the node.
 NodeSequence ancestors(NodeTest nodeTest)
          Returns an iterator on ancestors that match the node test.
 NodeSequence ancestorsOrSelf(NodeTest nodeTest)
          Returns an iterator on ancestors (including the node itself) that match the node test.
 Node attribute(QName name)
          Gets an attribute [of this element] by name.
 NodeSequence attributes()
          Accessor dm:attributes.
 NodeSequence attributes(NodeTest nodeTest)
          Returns an iterator on attributes that match the node test.
 NodeSequence children()
          Accessor dm:children.
 NodeSequence children(NodeTest nodeTest)
          Returns an iterator on children that match the node test.
 int compareStringValues(Node node, java.text.Collator collator)
          Compares the string values of two nodes, optionally using a collation.
 boolean contains(Node node)
          Returns true if this node is an ancestor of the parameter node or the node itself.
 NodeSequence descendants(NodeTest nodeTest)
          Returns an iterator on descendants that match the node test.
 NodeSequence descendantsOrSelf(NodeTest nodeTest)
          Returns an iterator on descendants (including the node itself) that match the node test.
 int docPosition()
          Returns an arbitrary value that is stable on the whole document (for order comparison).
 Node document()
          Returns the document node if any, else the top-level node.
 NodeSequence following(NodeTest nodeTest)
          Returns an iterator on following nodes that match the node test.
 NodeSequence followingSiblings(NodeTest nodeTest)
          Returns an iterator on following siblings that match the node test.
 java.lang.String getBaseURI()
          Accessor dm:base-uri().
 char[] getChars()
          Gets text contents as a char array.
 int getDefinedNSCount()
          Number of Namespaces defined on this particular node.
 java.lang.String getDocumentURI()
          Returns the URI of the document.
 long getIntegerValue()
          Returns the integer value (attempts to convert).
 int getNature()
          Returns a numeric node kind: DOCUMENT, ELEMENT etc.
 java.lang.String getNodeKind()
          Accessor dm:node-kind().
 QName getNodeName()
          Accessor dm:node-name().
 java.lang.String getNsPrefix(java.lang.String nsuri)
          Returns a matching prefix for the Namespace by looking up the namespace nodes on this element and its ancestors.
 java.lang.String getNsUri(java.lang.String prefix)
          Returns a matching Namespace for the prefix by looking up the namespace nodes on this element and its ancestors.
 java.lang.String getStringValue()
          Accessor dm:string-value().
 java.lang.Object getValue()
          Returns the value of an atomic node.
 boolean isAtom()
          Convenience: quick test of atomic nodes (text, comment, typed atoms).
 boolean isElement()
          Convenience: quick test of elements.
 boolean isRemote()
          Tests whether the node is a remote reference or is local to the JVM.
 NodeSequence namespaces(boolean inScope)
          Accessor dm:namespaces().
 int orderCompare(Node that)
          Returns -1 if this node is strictly before that node in document order, 0 if nodes are identical, 1 if after the that node.
 Node parent()
          Accessor dm:parent().
 NodeSequence parent(NodeTest nodeTest)
          Returns a sequence of length 1 (if the parent matches the nodeTest) else 0.
 NodeSequence preceding(NodeTest nodeTest)
          Returns an iterator preceding nodes (in document order) that match the node test.
 NodeSequence precedingSiblings(NodeTest nodeTest)
          Returns an iterator on preceding siblings (in document order) that match the node test.
 

Field Detail

DOCUMENT

public static final int DOCUMENT
Node nature (returned by getNature) for a document node.

See Also:
Constant Field Values

ELEMENT

public static final int ELEMENT
Node nature (returned by getNature) for an Element node.

See Also:
Constant Field Values

ATTRIBUTE

public static final int ATTRIBUTE
Node nature (returned by getNature) for an Attribute node.

See Also:
Constant Field Values

NAMESPACE

public static final int NAMESPACE
Node nature (returned by getNature) for a naemespacenode.

See Also:
Constant Field Values

PROCESSING_INSTRUCTION

public static final int PROCESSING_INSTRUCTION
Node nature (returned by getNature) for a processing instruction node.

See Also:
Constant Field Values

COMMENT

public static final int COMMENT
Node nature (returned by getNature) for a Comment node.

See Also:
Constant Field Values

TEXT

public static final int TEXT
Node nature (returned by getNature) for a leaf text node.

See Also:
Constant Field Values

ATOM_BOOL

public static final int ATOM_BOOL
Node nature (returned by getNature) for a typed leaf node holding a boolean value.

See Also:
Constant Field Values

ATOM_INT

public static final int ATOM_INT
Node nature (returned by getNature) for a typed integer node, holding a long integer value.

See Also:
Constant Field Values

ATOM_DOUBLE

public static final int ATOM_DOUBLE
Node nature (returned by getNature) for a typed leaf node holding a double value.

See Also:
Constant Field Values

ATOM_ANY

public static final int ATOM_ANY
Node nature (returned by getNature) for typed leaf node holding a value of any serializable class.

See Also:
Constant Field Values

ATOM_DATE

public static final int ATOM_DATE
Node nature (returned by getNature) for typed leaf node holding a date/time value.

See Also:
Constant Field Values
Method Detail

getNodeKind

public java.lang.String getNodeKind()
                             throws DataModelException
Accessor dm:node-kind().

Returns:
the node kind as a string: "element", "attribute" etc.
Throws:
DataModelException

getNodeName

public QName getNodeName()
                  throws DataModelException
Accessor dm:node-name().

Returns:
null if the node has no name (document, text, comment, pi).
Throws:
DataModelException

parent

public Node parent()
            throws DataModelException
Accessor dm:parent().

Returns:
null if the node has no parent.
Throws:
DataModelException

getStringValue

public java.lang.String getStringValue()
                                throws DataModelException
Accessor dm:string-value().

Returns the string value of the node. For an element, it is the concatenation of text nodes contained in the element.

Throws:
DataModelException

getBaseURI

public java.lang.String getBaseURI()
Accessor dm:base-uri().


getDocumentURI

public java.lang.String getDocumentURI()
                                throws DataModelException
Returns the URI of the document.

Throws:
DataModelException

children

public NodeSequence children()
                      throws DataModelException
Accessor dm:children. Returns the children in document order.

Only for Document and Elements: other kinds return an empty sequence.

Throws:
DataModelException

attributes

public NodeSequence attributes()
                        throws DataModelException
Accessor dm:attributes. Only for Elements: other kinds return an empty sequence.

Throws:
DataModelException

namespaces

public NodeSequence namespaces(boolean inScope)
                        throws DataModelException
Accessor dm:namespaces(). According to the parameter, returns in-scope namespaces for this node, or namespaces defined by this node. On non-element nodes, always returns the empty sequence.

Parameters:
inScope - if true, return the closure of in-scope namespaces, else the namespaces defined specifically on this node.
Throws:
DataModelException

getNature

public int getNature()
              throws DataModelException
Returns a numeric node kind: DOCUMENT, ELEMENT etc.

Throws:
DataModelException

document

public Node document()
              throws DataModelException
Returns the document node if any, else the top-level node.

Throws:
DataModelException

isElement

public boolean isElement()
                  throws DataModelException
Convenience: quick test of elements.

Throws:
DataModelException

isAtom

public boolean isAtom()
               throws DataModelException
Convenience: quick test of atomic nodes (text, comment, typed atoms).

Throws:
DataModelException

isRemote

public boolean isRemote()
Tests whether the node is a remote reference or is local to the JVM.

This helps to choose an optimal strategy to retrieve the node contents: an remote node is more efficiently retrieved using methods like XMLDocument.exportNode.

Note: a node from a CoreDataModel is never remote.


docPosition

public int docPosition()
                throws DataModelException
Returns an arbitrary value that is stable on the whole document (for order comparison).

Throws:
DataModelException

attribute

public Node attribute(QName name)
               throws DataModelException
Gets an attribute [of this element] by name.

Returns:
An attribute node; null if not found or not applied to an element.
Throws:
DataModelException

getChars

public char[] getChars()
                throws DataModelException
Gets text contents as a char array. Applicable only to text nodes, PI nodes and attributes.

Throws:
DataModelException

getDefinedNSCount

public int getDefinedNSCount()
                      throws DataModelException
Number of Namespaces defined on this particular node.

Throws:
DataModelException

getNsPrefix

public java.lang.String getNsPrefix(java.lang.String nsuri)
                             throws DataModelException
Returns a matching prefix for the Namespace by looking up the namespace nodes on this element and its ancestors.

Returns:
the first suitable prefix, otherwise null if none is found.
Throws:
DataModelException

getNsUri

public java.lang.String getNsUri(java.lang.String prefix)
                          throws DataModelException
Returns a matching Namespace for the prefix by looking up the namespace nodes on this element and its ancestors.

Returns:
the first suitable namespace URI, otherwise null if none is found.
Throws:
DataModelException

orderCompare

public int orderCompare(Node that)
Returns -1 if this node is strictly before that node in document order, 0 if nodes are identical, 1 if after the that node. If the two nodes belong to different documents, returns an arbitrary but stable "order of documents".


compareStringValues

public int compareStringValues(Node node,
                               java.text.Collator collator)
                        throws DataModelException
Compares the string values of two nodes, optionally using a collation.

Throws:
DataModelException

contains

public boolean contains(Node node)
Returns true if this node is an ancestor of the parameter node or the node itself.


ancestors

public NodeSequence ancestors(NodeTest nodeTest)
Returns an iterator on ancestors that match the node test.

Parameters:
nodeTest - concrete classes are BaseNodeTest, UnionNodeTest.

ancestorsOrSelf

public NodeSequence ancestorsOrSelf(NodeTest nodeTest)
Returns an iterator on ancestors (including the node itself) that match the node test.

Parameters:
nodeTest - concrete classes are BaseNodeTest, UnionNodeTest.

parent

public NodeSequence parent(NodeTest nodeTest)
Returns a sequence of length 1 (if the parent matches the nodeTest) else 0.


children

public NodeSequence children(NodeTest nodeTest)
Returns an iterator on children that match the node test.


descendants

public NodeSequence descendants(NodeTest nodeTest)
Returns an iterator on descendants that match the node test.


descendantsOrSelf

public NodeSequence descendantsOrSelf(NodeTest nodeTest)
Returns an iterator on descendants (including the node itself) that match the node test.


attributes

public NodeSequence attributes(NodeTest nodeTest)
Returns an iterator on attributes that match the node test.


followingSiblings

public NodeSequence followingSiblings(NodeTest nodeTest)
Returns an iterator on following siblings that match the node test.


precedingSiblings

public NodeSequence precedingSiblings(NodeTest nodeTest)
Returns an iterator on preceding siblings (in document order) that match the node test.


following

public NodeSequence following(NodeTest nodeTest)
Returns an iterator on following nodes that match the node test.


preceding

public NodeSequence preceding(NodeTest nodeTest)
Returns an iterator preceding nodes (in document order) that match the node test.


addText

public void addText(java.lang.String text)
Adds text inside the node. For an element, creates a text child node if necessary.

Caution: Some implementations do not support modification and can raise a run-time exception.


getValue

public java.lang.Object getValue()
                          throws DataModelException
Returns the value of an atomic node.

Returns:
Generally a String, but for typed atoms it is an object of class Boolean (ATOM_BOOL), Long (ATOM_INT), Double (ATOM_BOOL) or any class (ATOM_ANY).
Throws:
DataModelException

getIntegerValue

public long getIntegerValue()
                     throws DataModelException
Returns the integer value (attempts to convert).

Throws:
DataModelException - if not convertible to integer.

© 2005 Axyana Software