org.cdlib.xtf.lazyTree
Class AttributeImpl

Object
  extended by NodeImpl
      extended by AttributeImpl
All Implemented Interfaces:
Source, SourceLocator, FingerprintedNode, Item, NodeInfo, ValueRepresentation

final class AttributeImpl
extends NodeImpl

Represents an attribute node from a persistent XML document.

Author:
Martin Haye

Field Summary
(package private)  ElementImpl element
           
(package private)  int index
           
 
Fields inherited from class NodeImpl
document, nameCode, nextSibNum, NODE_LETTER, nodeNum, parentNum, prevSibNum
 
Fields inherited from interface NodeInfo
ALL_NAMESPACES, EMPTY_NAMESPACE_LIST, IS_DTD_TYPE, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
 
Fields inherited from interface 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.
 String getDisplayName()
          Obtain the displayable name of this attribute.
 DocumentInfo getDocumentRoot()
          Get the root (document) node
 NamePool getNamePool()
          Get the NamePool for the tree containing this node
 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
 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.
 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 NodeImpl
atomize, compareOrder, equals, getAttributeValue, getBaseURI, getColumnNumber, getConfiguration, getDeclaredNamespaces, getDocumentNumber, getFingerprint, getFirstChild, getLastChild, getLineNumber, getLocalPart, getNameCode, getNextInDocument, getParent, getPrefix, getPublicId, getStringValueCS, getSystemId, getTypeAnnotation, getTypedValue, getURI, hasChildNodes, init, iterateAxis, iterateAxis, sendNamespaceDeclarations, setSystemId
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

element

ElementImpl element

index

int index
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

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 NodeImpl
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 NodeImpl
Returns:
the DocumentInfo representing the containing document

getNamePool

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

Specified by:
getNamePool in interface NodeInfo
Overrides:
getNamePool in class NodeImpl
Returns:
the NamePool

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

getStringValue

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

Returns:
the attribute value

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

generateId

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

Specified by:
generateId in interface NodeInfo
Overrides:
generateId in class NodeImpl

getDisplayName

public String getDisplayName()
Obtain the displayable name of this attribute.

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

copy

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

Throws:
XPathException