Package net.sf.saxon.tree
Class AttributeImpl
- java.lang.Object
-
- net.sf.saxon.tree.NodeImpl
-
- net.sf.saxon.tree.AttributeImpl
-
- All Implemented Interfaces:
javax.xml.transform.Source,javax.xml.transform.SourceLocator,ExtendedNodeInfo,FingerprintedNode,Item,NodeInfo,ValueRepresentation
final class AttributeImpl extends NodeImpl implements ExtendedNodeInfo
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, IS_NILLED, LOCAL_NAMESPACES, NO_NAMESPACES
-
Fields inherited from interface net.sf.saxon.om.ValueRepresentation
EMPTY_VALUE_ARRAY
-
-
Constructor Summary
Constructors Constructor Description AttributeImpl(ElementImpl element, int index)Construct an Attribute node for the n'th attribute of a given element
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)Copy this node to a given outputtervoidgenerateId(FastStringBuffer buffer)Get sequential key.intgetNameCode()Get the name code, which enables the name to be located in the name poolNodeImplgetNextInDocument(NodeImpl anchor)Get the next node in document order (skipping attributes)NodeInfogetNextSibling()Get next sibling - not defined for attributesintgetNodeKind()Return the type of node.NodeImplgetPreviousInDocument()Get the previous node in document order (skipping attributes)NodeInfogetPreviousSibling()Get previous sibling - not defined for attributesprotected longgetSequenceNumber()Get the node sequence number (in document order).java.lang.StringgetStringValue()Return the character value of the node.intgetTypeAnnotation()Get the type annotation of this node, if anyinthashCode()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()booleanisId()Determine whether this node has the is-id propertybooleanisIdref()Determine whether this node has the is-idref propertybooleanisNilled()Determine whether the node has the is-nilled propertybooleanisSameNodeInfo(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
-
Methods inherited from interface net.sf.saxon.om.Item
getStringValueCS, getTypedValue
-
Methods inherited from interface net.sf.saxon.om.NodeInfo
atomize, compareOrder, equals, getAttributeValue, getBaseURI, getConfiguration, getDeclaredNamespaces, getDisplayName, getDocumentNumber, getDocumentRoot, getFingerprint, getLineNumber, getLocalPart, getNamePool, getParent, getPrefix, getRoot, getSystemId, getURI, hasChildNodes, iterateAxis, iterateAxis, sendNamespaceDeclarations
-
-
-
-
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 attributeindex- 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:
getNameCodein interfaceNodeInfo- Overrides:
getNameCodein classNodeImpl- 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:
getTypeAnnotationin interfaceNodeInfo- Overrides:
getTypeAnnotationin classNodeImpl- 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.
-
isId
public boolean isId()
Determine whether this node has the is-id property- Specified by:
isIdin interfaceExtendedNodeInfo- Returns:
- true if the node is an ID
-
isIdref
public boolean isIdref()
Determine whether this node has the is-idref property- Specified by:
isIdrefin interfaceExtendedNodeInfo- Returns:
- true if the node is an IDREF or IDREFS element or attribute
-
isNilled
public boolean isNilled()
Determine whether the node has the is-nilled property- Specified by:
isNilledin interfaceExtendedNodeInfo- Returns:
- true if the node has the is-nilled property
-
isSameNodeInfo
public boolean isSameNodeInfo(NodeInfo other)
Determine whether this is the same node as another node- Specified by:
isSameNodeInfoin interfaceNodeInfo- Overrides:
isSameNodeInfoin classNodeImpl- 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:
hashCodein interfaceNodeInfo- Overrides:
hashCodein classNodeImpl- 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:
getSequenceNumberin classNodeImpl
-
getNodeKind
public final int getNodeKind()
Return the type of node.- Specified by:
getNodeKindin interfaceNodeInfo- Returns:
- Node.ATTRIBUTE
- See Also:
Type
-
getStringValue
public java.lang.String getStringValue()
Return the character value of the node.- Specified by:
getStringValuein interfaceItem- Specified by:
getStringValuein interfaceNodeInfo- Specified by:
getStringValuein interfaceValueRepresentation- Returns:
- the attribute value
- See Also:
Item.getStringValueCS()
-
getNextSibling
public NodeInfo getNextSibling()
Get next sibling - not defined for attributes- Overrides:
getNextSiblingin classNodeImpl- 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:
getPreviousSiblingin classNodeImpl- 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:
getPreviousInDocumentin classNodeImpl- 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:
getNextInDocumentin classNodeImpl- 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:
generateIdin interfaceNodeInfo- Overrides:
generateIdin classNodeImpl- Parameters:
buffer-
-
copy
public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId) throws XPathException
Copy this node to a given outputter- Specified by:
copyin interfaceNodeInfo- Parameters:
out- the Receiver to which the node should be copiedwhichNamespaces- in the case of an element, controls which namespace nodes should be copied. Values areNodeInfo.NO_NAMESPACES,NodeInfo.LOCAL_NAMESPACES,NodeInfo.ALL_NAMESPACEScopyAnnotations- indicates whether the type annotations of element and attribute nodes should be copiedlocationId- 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
-
-