net.sf.saxon.tinytree
Class TinyAttributeImpl

java.lang.Object
  extended bynet.sf.saxon.om.AbstractNode
      extended bynet.sf.saxon.tinytree.TinyNodeImpl
          extended bynet.sf.saxon.tinytree.TinyAttributeImpl
All Implemented Interfaces:
Attr, DOMLocator, Item, Node, NodeInfo, Source, SourceLocator

final class TinyAttributeImpl
extends TinyNodeImpl
implements Attr

A node in the XML parse tree representing an attribute. Note that this is generated only "on demand", when the attribute is selected by a select pattern.

Author:
Field Summary
protected  TinyDocumentImpl document
           
protected  int nodeNr
           
protected  TinyNodeImpl parent
           
 
Fields inherited from class net.sf.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 net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, LOCAL_NAMESPACES, NO_NAMESPACES
 
Constructor Summary
TinyAttributeImpl(TinyDocumentImpl doc, int nodeNr)
           
 
Method Summary
 int compareOrder(NodeInfo other)
          Determine the relative position of this node and another node, in document order.
 void copy(Receiver out, int whichNamespaces, boolean copyAnnotations)
          Copy this node to a given outputter
 String generateId()
          Generate id.
 String getAttributeValue(int fingerprint)
          Get the value of a given attribute of this node
 String getBaseURI()
          Get the base URI for the node.
 String getDisplayName()
          Get the display name of this node.
 int getDocumentNumber()
          Get the document number of the document containing this node (Needed when the document isn't a real node, for sorting free-standing elements)
 DocumentInfo getDocumentRoot()
          Get the root (document) 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 getLocalPart()
          Get the local name of this node.
 int getNameCode()
          Get the name code of the node, used for finding names in the name pool
 NamePool getNamePool()
          Get the NamePool for the tree containing this node
 int getNodeKind()
          Return the type of node.
 Node getOriginatingNode()
          Get the node corresponding to this javax.xml.transform.dom.DOMLocator
 NodeInfo getParent()
          Get the parent node
 String getPrefix()
          Get the prefix part of the name of this node.
 NodeInfo getRoot()
          Get the root node of the tree (not necessarily a document node)
protected  long getSequenceNumber()
          Get the node sequence number (in document order).
 String getStringValue()
          Return the character value of the node.
 String getSystemId()
          Get the system ID for the entity containing the node.
 int getTypeAnnotation()
          Get the type annotation of this node, if any Returns 0 if there is no type annotation
 String getURI()
          Get the URI part of the name of this node.
 boolean hasAttributes()
          Returns whether this node has any attributes.
 boolean hasChildNodes()
          Determine whether the node has any children.
 boolean isSameNode(NodeInfo other)
          Determine whether this is the same node as another node
 AxisIterator iterateAxis(byte axisNumber)
          Return an iterator over all the nodes reached by the given axis from this node
 AxisIterator iterateAxis(byte axisNumber, NodeTest nodeTest)
          Return an iterator over the nodes reached by the given axis from this node
 void outputNamespaceNodes(Receiver out, boolean includeAncestors)
          Output all namespace nodes associated with this element.
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 net.sf.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, getLocalName, getName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getOwnerElement, getParentNode, getPreviousSibling, getPublicId, getSpecified, getTagName, getTypedValue, 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.Attr
getName, getOwnerElement, getSpecified, getValue, setValue
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

document

protected TinyDocumentImpl document

nodeNr

protected int nodeNr

parent

protected TinyNodeImpl parent
Constructor Detail

TinyAttributeImpl

public TinyAttributeImpl(TinyDocumentImpl doc,
                         int nodeNr)
Method Detail

getParent

public NodeInfo getParent()
Get the parent node

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

getSequenceNumber

protected long getSequenceNumber()
Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive. In the current implementation, parent nodes (elements and roots) have a zero least-significant word, while namespaces, attributes, text nodes, comments, and PIs have the top word the same as their owner and the bottom half reflecting their relative position.

Overrides:
getSequenceNumber in class TinyNodeImpl

getNodeKind

public final int getNodeKind()
Return the type of node.

Specified by:
getNodeKind in interface NodeInfo
Returns:
Node.ATTRIBUTE
See Also:
Type

getStringValue

public String getStringValue()
Return the character value of the node.

Specified by:
getStringValue in interface NodeInfo
Specified by:
getStringValue in class AbstractNode
Returns:
the attribute value

getFingerprint

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

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

getNameCode

public int getNameCode()
Get the name code of the node, used for finding names in the name pool

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

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
Overrides:
getPrefix in class TinyNodeImpl
Returns:
the prefix part of the name. For an unnamed node, return null.

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 TinyNodeImpl
Returns:
The display name of this node. For a node with no name, return an empty string.

getLocalPart

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

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

getURI

public final String getURI()
Get the URI part of the name of this node.

Specified by:
getURI in interface NodeInfo
Overrides:
getURI in class TinyNodeImpl
Returns:
The URI of the namespace of this node. For the default namespace, return an empty string

getTypeAnnotation

public int getTypeAnnotation()
Get the type annotation of this node, if any Returns 0 if there is no type annotation

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

generateId

public String generateId()
Generate id. Returns key of owning element with the attribute namecode as a suffix

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

copy

public void copy(Receiver out,
                 int whichNamespaces,
                 boolean copyAnnotations)
          throws TransformerException
Copy this node to a given outputter

Specified by:
copy in interface NodeInfo
Parameters:
out - the Receiver to which the node should be copied
whichNamespaces - in the case of an element, controls which namespace nodes should be copied. Values are NO_NAMESPACES, LOCAL_NAMESPACES, ALL_NAMESPACES
copyAnnotations - indicates whether the type annotations of element and attribute nodes should be copied
Throws:
TransformerException

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 TinyNodeImpl

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

getBaseURI

public String getBaseURI()
Get the base URI for the node. Default implementation for child nodes gets the base URI of the parent node.

Specified by:
getBaseURI in interface NodeInfo
Specified by:
getBaseURI 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

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())

iterateAxis

public AxisIterator iterateAxis(byte axisNumber)
Return an iterator over all the nodes reached by the given axis from this node

Parameters:
axisNumber - Identifies the required axis, eg. Axis.CHILD or Axis.PARENT
Returns:
a AxisIteratorImpl that scans the nodes reached by the axis in turn.
See Also:
Axis

iterateAxis

public AxisIterator iterateAxis(byte axisNumber,
                                NodeTest nodeTest)
Return an iterator over the nodes reached by the given axis from this node

Specified by:
iterateAxis in interface NodeInfo
Specified by:
iterateAxis 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 AxisIteratorImpl that scans the nodes reached by the axis in turn.

hasChildNodes

public boolean hasChildNodes()
Determine whether the node has any children.

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

hasAttributes

public boolean hasAttributes()
Returns whether this node has any attributes.

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

getAttributeValue

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

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

getRoot

public NodeInfo getRoot()
Get the root node of the tree (not necessarily a document node)

Specified by:
getRoot in interface NodeInfo
Overrides:
getRoot in class AbstractNode
Returns:
the NodeInfo representing the root of this tree

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

getNamePool

public NamePool getNamePool()
Get the NamePool for the tree containing this node

Returns:
the NamePool

outputNamespaceNodes

public void outputNamespaceNodes(Receiver out,
                                 boolean includeAncestors)
                          throws TransformerException
Output all namespace nodes associated with this element. Does nothing if the node is not an element.

Specified by:
outputNamespaceNodes in interface NodeInfo
Overrides:
outputNamespaceNodes in class AbstractNode
Parameters:
out - The relevant outputter
includeAncestors - True if namespaces declared on ancestor elements must be output; false if it is known that these are already on the result tree
Throws:
TransformerException

getDocumentNumber

public int getDocumentNumber()
Get the document number of the document containing this node (Needed when the document isn't a real node, for sorting free-standing elements)

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