com.icl.saxon.tinytree
Class TinyElementImpl

java.lang.Object
  extended bycom.icl.saxon.om.AbstractNode
      extended bycom.icl.saxon.tinytree.TinyNodeImpl
          extended bycom.icl.saxon.tinytree.TinyParentNodeImpl
              extended bycom.icl.saxon.tinytree.TinyElementImpl
All Implemented Interfaces:
DOMLocator, Element, Node, NodeInfo, Source, SourceLocator

final class TinyElementImpl
extends TinyParentNodeImpl
implements Element

A node in the XML parse tree representing an XML element.

This class is an implementation of NodeInfo and also implements the DOM Element interface

Author:
Field Summary
protected  TinyDocumentImpl document
           
protected  int nodeNr
           
protected  TinyNodeImpl parent
           
 
Fields inherited from class com.icl.saxon.om.AbstractNode
NODE_LETTER
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Fields inherited from interface com.icl.saxon.om.NodeInfo
ATTRIBUTE, COMMENT, ELEMENT, NAMESPACE, NODE, NONE, NUMBER_OF_TYPES, PI, ROOT, TEXT
 
Constructor Summary
TinyElementImpl(TinyDocumentImpl doc, int nodeNr)
          Constructor
 
Method Summary
 int compareOrder(NodeInfo other)
          Determine the relative position of this node and another node, in document order.
 void copy(Outputter out)
          Copy this node to a given outputter (supporting xsl:copy-of)
 void copy(Outputter out, boolean allNamespaces)
          Copy this node to a given outputter
 void copyStringValue(Outputter out)
          Copy the string-value of this node to a given outputter
 String generateId()
          Get a character string that uniquely identifies this node
 String getAttributeValue(int fingerprint)
          Get the value of a given attribute of this node
 String getAttributeValue(String uri, String localName)
          Find the value of a given attribute of this node.
 String getBaseURI()
          Get the base URI of this element node.
 String getDisplayName()
          Get the display name of this node.
 DocumentInfo getDocumentRoot()
          Get the root (document) node
 AxisEnumeration getEnumeration(byte axisNumber, NodeTest nodeTest)
          Return an enumeration over the nodes reached by the given axis from this node
 int getFingerprint()
          Get the fingerprint of the node, used for matching names
 int getLineNumber()
          Get the line number of the node within its source document entity
 String getLocalName()
          Get the local name of this node.
 int getNameCode()
          Get the name code of the node, used for matching names
 short getNodeType()
          Return the type of node.
 Node getOriginatingNode()
          Get the node corresponding to this javax.xml.transform.dom.DOMLocator
 NodeInfo getParent()
          Find the parent node of this node.
 String getPrefix()
          Get the prefix part of the name of this node.
protected  long getSequenceNumber()
          Get the node sequence number (in document order).
 String getStringValue()
          Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.
 String getSystemId()
          Get the system ID for the entity containing the node.
 String getURI()
          Get the URI part of the name of this node.
 boolean hasAttributes()
          Returns whether this node (if it is an element) has any attributes.
 boolean hasChildNodes()
          Determine if the node has children.
 boolean isSameNode(NodeInfo other)
          Determine whether this is the same node as another node
 TinyAttributeImpl makeAttributeNode(int index)
          Make an attribute node for a given attribute of this element
 void outputNamespaceNodes(Outputter out, boolean includeAncestors)
          Output all namespace nodes associated with this element.
 void setAttribute(String name, String value)
          Set the value of an attribute on the current element.
 void setLineNumber(int line)
          Set the line number of the node within its source document entity
protected  void setParentNode(TinyNodeImpl parent)
          Set the parent of this node.
 void setSystemId(String uri)
          Set the system id of this node.
 
Methods inherited from class com.icl.saxon.om.AbstractNode
appendChild, appendData, cloneNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getChildNodes, getColumnNumber, getData, getDoctype, getDocumentElement, getElementById, getElementsByTagName, getElementsByTagNameNS, getFirstChild, getImplementation, getLastChild, getLength, getName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getOwnerElement, getParentNode, getPreviousSibling, getPublicId, getSpecified, getTagName, getValue, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isSupported, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setNodeValue, setPrefix, setValue, splitText, substringData, supports
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Element
getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getElementsByTagName, getElementsByTagNameNS, getTagName, hasAttribute, hasAttributeNS, removeAttribute, removeAttributeNode, removeAttributeNS, setAttributeNode, setAttributeNodeNS, setAttributeNS
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

document

protected TinyDocumentImpl document

nodeNr

protected int nodeNr

parent

protected TinyNodeImpl parent
Constructor Detail

TinyElementImpl

public TinyElementImpl(TinyDocumentImpl doc,
                       int nodeNr)
Constructor

Method Detail

getNodeType

public final short getNodeType()
Return the type of node.

Specified by:
getNodeType in interface Node
Returns:
NodeInfo.ELEMENT

getBaseURI

public String getBaseURI()
Get the base URI of this element node. This will be the same as the System ID unless xml:base has been used.

Specified by:
getBaseURI in interface NodeInfo
Overrides:
getBaseURI in class TinyNodeImpl

outputNamespaceNodes

public void outputNamespaceNodes(Outputter out,
                                 boolean includeAncestors)
                          throws TransformerException
Output all namespace nodes associated with this element.

Specified by:
outputNamespaceNodes in interface NodeInfo
Overrides:
outputNamespaceNodes in class TinyNodeImpl
Parameters:
out - The relevant outputter
includeAncestors - True if namespaces associated with ancestor elements must also be output; false if these are already known to be on the result tree.
Throws:
TransformerException

hasAttributes

public boolean hasAttributes()
Returns whether this node (if it is an element) has any attributes.

Specified by:
hasAttributes in interface Node
Overrides:
hasAttributes in class TinyNodeImpl
Returns:
true if this node has any attributes, false otherwise.
Since:
DOM Level 2

getAttributeValue

public String getAttributeValue(String uri,
                                String localName)
Find the value of a given attribute of this node.
This method is defined on all nodes to meet XSL requirements, but for nodes other than elements it will always return null.

Specified by:
getAttributeValue in interface NodeInfo
Overrides:
getAttributeValue in class TinyNodeImpl
Parameters:
uri - the namespace uri of an attribute
localName - the local name of an attribute
Returns:
the value of the attribute, if it exists, otherwise null

getAttributeValue

public String getAttributeValue(int fingerprint)
Get the value of a given attribute of this node

Specified by:
getAttributeValue in interface NodeInfo
Overrides:
getAttributeValue in class TinyNodeImpl
Parameters:
fingerprint - The fingerprint of the attribute name
Returns:
the attribute value if it exists or null if not

makeAttributeNode

public TinyAttributeImpl makeAttributeNode(int index)
Make an attribute node for a given attribute of this element

Parameters:
index - The relative position of the attribute, counting from zero. This is trusted to be in range.

setAttribute

public void setAttribute(String name,
                         String value)
                  throws DOMException
Set the value of an attribute on the current element. This affects subsequent calls of getAttribute() for that element.

Specified by:
setAttribute in interface Element
Parameters:
name - The name of the attribute to be set. Any prefix is interpreted relative to the namespaces defined for this element.
value - The new value of the attribute. Set this to null to remove the attribute.
Throws:
DOMException

copy

public void copy(Outputter out)
          throws TransformerException
Copy this node to a given outputter (supporting xsl:copy-of)

Specified by:
copy in interface NodeInfo
Throws:
TransformerException

copy

public void copy(Outputter out,
                 boolean allNamespaces)
          throws TransformerException
Copy this node to a given outputter

Parameters:
allNamespaces - true if all namespace nodes must be copied; false if namespace nodes for the parent element are already on the result tree
Throws:
TransformerException

hasChildNodes

public boolean hasChildNodes()
Determine if the node has children.

Specified by:
hasChildNodes in interface Node
Overrides:
hasChildNodes in class TinyNodeImpl
Returns:
true if this node has any attributes, false otherwise.

getStringValue

public String getStringValue()
Return the string-value of the node, that is, the concatenation of the character content of all descendent elements and text nodes.

Returns:
the accumulated character content of the element, including descendant elements.

copyStringValue

public void copyStringValue(Outputter out)
                     throws TransformerException
Copy the string-value of this node to a given outputter

Specified by:
copyStringValue in interface NodeInfo
Overrides:
copyStringValue in class AbstractNode
Throws:
TransformerException

setSystemId

public void setSystemId(String uri)
Set the system id of this node.
This method is present to ensure that the class implements the javax.xml.transform.Source interface, so a node can be used as the source of a transformation.


setParentNode

protected void setParentNode(TinyNodeImpl parent)
Set the parent of this node. Providing this information is useful, if it is known, because otherwise getParent() has to search backwards through the document.


isSameNode

public boolean isSameNode(NodeInfo other)
Determine whether this is the same node as another node

Specified by:
isSameNode in interface NodeInfo
Specified by:
isSameNode in class AbstractNode
Returns:
true if this Node object and the supplied Node object represent the same node in the tree.

getSystemId

public String getSystemId()
Get the system ID for the entity containing the node.

Specified by:
getSystemId in interface NodeInfo
Specified by:
getSystemId in class AbstractNode

getOriginatingNode

public Node getOriginatingNode()
Get the node corresponding to this javax.xml.transform.dom.DOMLocator

Specified by:
getOriginatingNode in interface DOMLocator
Overrides:
getOriginatingNode in class AbstractNode

setLineNumber

public void setLineNumber(int line)
Set the line number of the node within its source document entity


getLineNumber

public int getLineNumber()
Get the line number of the node within its source document entity

Specified by:
getLineNumber in interface NodeInfo
Overrides:
getLineNumber in class AbstractNode

getSequenceNumber

protected long getSequenceNumber()
Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive. The sequence number must be unique within the document (not, as in previous releases, within the whole document collection)


compareOrder

public final int compareOrder(NodeInfo other)
Determine the relative position of this node and another node, in document order. The other node will always be in the same document.

Specified by:
compareOrder in interface NodeInfo
Specified by:
compareOrder in class AbstractNode
Parameters:
other - The other node, whose position is to be compared with this node
Returns:
-1 if this node precedes the other node, +1 if it follows the other node, or 0 if they are the same node. (In this case, isSameNode() will always return true, and the two nodes will produce the same result for generateId())

getFingerprint

public int getFingerprint()
Get the fingerprint of the node, used for matching names

Specified by:
getFingerprint in interface NodeInfo
Specified by:
getFingerprint in class AbstractNode

getNameCode

public int getNameCode()
Get the name code of the node, used for matching names

Specified by:
getNameCode in interface NodeInfo
Specified by:
getNameCode in class AbstractNode

getPrefix

public String getPrefix()
Get the prefix part of the name of this node. This is the name before the ":" if any.

Specified by:
getPrefix in interface Node
Specified by:
getPrefix in class AbstractNode
Returns:
the prefix part of the name. For an unnamed node, return "".

getURI

public String getURI()
Get the URI part of the name of this node. This is the URI corresponding to the prefix, or the URI of the default namespace if appropriate.

Specified by:
getURI in interface NodeInfo
Specified by:
getURI in class AbstractNode
Returns:
The URI of the namespace of this node. For an unnamed node, or for an element or attribute in the default namespace, return an empty string.

getDisplayName

public String getDisplayName()
Get the display name of this node. For elements and attributes this is [prefix:]localname. For unnamed nodes, it is an empty string.

Specified by:
getDisplayName in interface NodeInfo
Overrides:
getDisplayName in class AbstractNode
Returns:
The display name of this node. For a node with no name, return an empty string.

getLocalName

public String getLocalName()
Get the local name of this node.

Specified by:
getLocalName in interface Node
Specified by:
getLocalName in class AbstractNode
Returns:
The local name of this node. For a node with no name, return an empty string.

getEnumeration

public AxisEnumeration getEnumeration(byte axisNumber,
                                      NodeTest nodeTest)
Return an enumeration over the nodes reached by the given axis from this node

Specified by:
getEnumeration in interface NodeInfo
Specified by:
getEnumeration in class AbstractNode
Parameters:
axisNumber - Identifies the required axis, eg. Axis.CHILD or Axis.PARENT
nodeTest - A pattern to be matched by the returned nodes
Returns:
a AxisEnumeration that scans the nodes reached by the axis in turn.

getParent

public NodeInfo getParent()
Find the parent node of this node.

Specified by:
getParent in interface NodeInfo
Specified by:
getParent in class AbstractNode
Returns:
The Node object describing the containing element or root node.

getDocumentRoot

public DocumentInfo getDocumentRoot()
Get the root (document) node

Specified by:
getDocumentRoot in interface NodeInfo
Overrides:
getDocumentRoot in class AbstractNode
Returns:
the DocumentInfo representing the containing document

generateId

public String generateId()
Get a character string that uniquely identifies this node

Specified by:
generateId in interface NodeInfo
Specified by:
generateId in class AbstractNode
Returns:
a string.