net.sf.saxon.tree
Class AttributeImpl

java.lang.Object
  extended by net.sf.saxon.tree.NodeImpl
      extended by net.sf.saxon.tree.AttributeImpl
All Implemented Interfaces:
javax.xml.transform.Source, javax.xml.transform.SourceLocator, FingerprintedNode, Item, NodeInfo, ValueRepresentation

final class AttributeImpl
extends NodeImpl

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:
Michael H. Kay

Field Summary
 
Fields inherited from class net.sf.saxon.tree.NodeImpl
index, NODE_LETTER, parent
 
Fields inherited from interface net.sf.saxon.om.NodeInfo
ALL_NAMESPACES, EMPTY_NAMESPACE_LIST, IS_DTD_TYPE, LOCAL_NAMESPACES, NO_NAMESPACES
 
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
 
Constructor Summary
AttributeImpl(ElementImpl element, int index)
          Construct an Attribute node for the n'th attribute of a given element
 
Method Summary
 void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)
          Copy this node to a given outputter
 void generateId(FastStringBuffer buffer)
          Get sequential key.
 int getNameCode()
          Get the name code, which enables the name to be located in the name pool
 NodeImpl getNextInDocument(NodeImpl anchor)
          Get the next node in document order (skipping attributes)
 NodeInfo getNextSibling()
          Get next sibling - not defined for attributes
 int getNodeKind()
          Return the type of node.
 NodeImpl getPreviousInDocument()
          Get the previous node in document order (skipping attributes)
 NodeInfo getPreviousSibling()
          Get previous sibling - not defined for attributes
protected  long getSequenceNumber()
          Get the node sequence number (in document order).
 java.lang.String getStringValue()
          Return the character value of the node.
 int getTypeAnnotation()
          Get the type annotation of this node, if any
 int hashCode()
          The hashCode() method obeys the contract for hashCode(): that is, if two objects are equal (represent the same node) then they must have the same hashCode()
 boolean isSameNodeInfo(NodeInfo other)
          Determine whether this is the same node as another node
 
Methods inherited from class net.sf.saxon.tree.NodeImpl
atomize, compareOrder, equals, getAttributeValue, getBaseURI, getColumnNumber, getConfiguration, getDeclaredNamespaces, getDisplayName, getDocumentNumber, getDocumentRoot, getFingerprint, getFirstChild, getLastChild, getLineNumber, getLocalPart, getNamePool, getParent, getPrefix, getPublicId, getRoot, getStringValueCS, getSystemId, getTypedValue, getURI, hasChildNodes, iterateAxis, iterateAxis, sendNamespaceDeclarations, setSystemId
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeImpl

public AttributeImpl(ElementImpl element,
                     int index)
Construct an Attribute node for the n'th attribute of a given element

Parameters:
element - The element containing the relevant attribute
index - The index position of the attribute starting at zero
Method Detail

getNameCode

public int getNameCode()
Get the name code, which enables the name to be located in the name pool

Specified by:
getNameCode in interface NodeInfo
Overrides:
getNameCode in class NodeImpl
Returns:
an integer name code, which may be used to obtain the actual node name from the name pool. For unnamed nodes (text nodes, comments, document nodes, and namespace nodes for the default namespace), returns -1.
See Also:
allocate, getFingerprint

getTypeAnnotation

public int getTypeAnnotation()
Get the type annotation of this node, if any

Specified by:
getTypeAnnotation in interface NodeInfo
Overrides:
getTypeAnnotation in class NodeImpl
Returns:
the type annotation of the node, under the mask NamePool.FP_MASK, and optionally the bit setting IS_DTD_TYPE in the case of a DTD-derived ID or IDREF/S type (which is treated as untypedAtomic for the purposes of obtaining the typed value).

The result is undefined for nodes other than elements and attributes.


isSameNodeInfo

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

Specified by:
isSameNodeInfo in interface NodeInfo
Overrides:
isSameNodeInfo in class NodeImpl
Parameters:
other - the node to be compared with this node
Returns:
true if this Node object and the supplied Node object represent the same node in the tree.

hashCode

public int hashCode()
The hashCode() method obeys the contract for hashCode(): that is, if two objects are equal (represent the same node) then they must have the same hashCode()

Specified by:
hashCode in interface NodeInfo
Overrides:
hashCode in class NodeImpl
Since:
8.7 Previously, the effect of the equals() and hashCode() methods was not defined. Callers should therefore be aware that third party implementations of the NodeInfo interface may not implement the correct semantics.

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 NodeImpl

getNodeKind

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

Returns:
Node.ATTRIBUTE
See Also:
Type

getStringValue

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

Returns:
the attribute value
See Also:
Item.getStringValueCS()

getNextSibling

public NodeInfo getNextSibling()
Get next sibling - not defined for attributes

Overrides:
getNextSibling in class NodeImpl
Returns:
The next sibling node of the required type. Returns null if the current node is the last child of its parent.

getPreviousSibling

public NodeInfo getPreviousSibling()
Get previous sibling - not defined for attributes

Overrides:
getPreviousSibling in class NodeImpl
Returns:
The previous sibling node. Returns null if the current node is the first child of its parent.

getPreviousInDocument

public NodeImpl getPreviousInDocument()
Get the previous node in document order (skipping attributes)

Overrides:
getPreviousInDocument in class NodeImpl
Returns:
the previous node in the document, or null if there is no such node

getNextInDocument

public NodeImpl getNextInDocument(NodeImpl anchor)
Get the next node in document order (skipping attributes)

Overrides:
getNextInDocument in class NodeImpl
Parameters:
anchor - the scan stops when it reaches a node that is not a descendant of the specified anchor node
Returns:
the next node in the document, or null if there is no such node

generateId

public void generateId(FastStringBuffer buffer)
Get sequential key. Returns key of owning element with the attribute index as a suffix

Specified by:
generateId in interface NodeInfo
Overrides:
generateId in class NodeImpl
Parameters:
buffer -

copy

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

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 NodeInfo.NO_NAMESPACES, NodeInfo.LOCAL_NAMESPACES, NodeInfo.ALL_NAMESPACES
copyAnnotations - indicates whether the type annotations of element and attribute nodes should be copied
locationId - If non-zero, identifies the location of the instruction that requested this copy. If zero, indicates that the location information for the original node is to be copied; in this case the Receiver must be a LocationCopier
Throws:
XPathException