Package net.sf.saxon.tree.linked

## Class AttributeImpl

- java.lang.Object
- - net.sf.saxon.tree.linked.NodeImpl
  - - net.sf.saxon.tree.linked.AttributeImpl

- All Implemented Interfaces:
    `javax.xml.transform.Source`, `javax.xml.transform.SourceLocator`, `GroundedValue`, `Item`, `MutableNodeInfo`, `NodeInfo`, `Sequence`, `Location`, `SteppingNode<NodeImpl>`, `SiblingCountingNode`, `org.xml.sax.Locator`

      public class AttributeImpl
      extends NodeImpl

  A node in the "linked" tree representing an attribute. Note that this is generated only "on demand", when the attribute is selected by a path expression.

  It is possible for multiple AttributeImpl objects to represent the same attribute node. The identity of an attribute node is determined by the identity of the element, and the index position of the attribute within the element. Index positions are not reused when an attribute is deleted, and are retained when an attribute is renamed.

  This object no longer caches information such as the name code and string value, because these would become invalid when the element node is modified.

- - ### Field Summary

    - ### Fields inherited from class net.sf.saxon.tree.linked.NodeImpl

      `NODE_LETTER`

    - ### Fields inherited from interface net.sf.saxon.om.NodeInfo

      `IS_DTD_TYPE, IS_NILLED`

  - ### 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
    --- | --- | ---
    `void` | `copy​(Receiver out, int copyOptions, Location locationId)` | Copy this node to a given outputter.
    `void` | `delete()` | Delete this node (that is, detach it from its parent)
    `boolean` | `equals​(java.lang.Object other)` | Determine whether this is the same node as another node
    `void` | `generateId​(FastStringBuffer buffer)` | Get sequential key.
    `int` | `getFingerprint()` | Get the fingerprint of the node.
    `NodeImpl` | `getNextInDocument​(NodeImpl anchor)` | Get the next node in document order (skipping attributes)
    `NodeImpl` | `getNextSibling()` | Get next sibling - not defined for attributes
    `int` | `getNodeKind()` | Return the type of node.
    `NodeName` | `getNodeName()` | Get the name of the node.
    `NodeImpl` | `getPreviousInDocument()` | Get the previous node in document order (skipping attributes)
    `NodeImpl` | `getPreviousSibling()` | Get previous sibling - not defined for attributes
    `SchemaType` | `getSchemaType()` | Get the type annotation
    `protected long` | `getSequenceNumber()` | Get the node sequence number (in document order).
    `java.lang.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` | `isDeleted()` | Test whether this MutableNodeInfo object represents a node that has been deleted.
    `boolean` | `isId()` | Determine whether this node has the is-id property
    `boolean` | `isIdref()` | Determine whether this node has the is-idref property
    `void` | `removeTypeAnnotation()` | Remove type information from this node (and its ancestors, recursively).
    `void` | `rename​(NodeName newNameCode, boolean inheritNamespaces)` | Rename this node
    `void` | `replace​(NodeInfo[] replacement, boolean inherit)` | Replace this node with a given sequence of nodes
    `void` | `replaceStringValue​(java.lang.CharSequence stringValue)` | Replace the string-value of this node.
    `void` | `setTypeAnnotation​(SchemaType type)` | Set the type annotation on a node.

    - ### Methods inherited from class net.sf.saxon.tree.linked.NodeImpl

      `addAttribute, addNamespace, atomize, attributes, compareOrder, effectiveBooleanValue, equals, getAllNamespaces, getAttributeValue, getBaseURI, getColumnNumber, getConfiguration, getDeclaredNamespaces, getDisplayName, getFirstChild, getLastChild, getLineNumber, getLocalPart, getNamePool, getParent, getPhysicalRoot, getPrefix, getRawParent, getRoot, getSiblingPosition, getStringValueCS, getSuccessorElement, getSystemId, getTreeInfo, getURI, hasChildNodes, hasFingerprint, head, insertChildren, insertSiblings, iterateAxis, iterateAxis, newBuilder, removeAttribute, saveLocation, setAttributes, setRawParent, setSiblingPosition, 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.GroundedValue

      `asIterable, concatenate, containsNode, materialize`

    - ### Methods inherited from interface net.sf.saxon.om.Item

      `getLength, itemAt, iterate, reduce, subsequence`

    - ### Methods inherited from interface net.sf.saxon.om.MutableNodeInfo

      `addNamespace, removeNamespace`

    - ### Methods inherited from interface net.sf.saxon.om.NodeInfo

      `children, children, getGenre, getPublicId, isNilled, isSameNodeInfo, isStreamed, toShortString`

    - ### Methods inherited from interface net.sf.saxon.om.Sequence

      `makeRepeatable`

    - ### Methods inherited from interface javax.xml.transform.Source

      `isEmpty`

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

    - #### getNodeName

          public NodeName getNodeName()

      Get the name of the node. Returns null for an unnamed node
      Overrides:
        `getNodeName` in class `NodeImpl`
      Returns:
        the name of the node

    - #### getFingerprint

          public int getFingerprint()

      Get the fingerprint of the node. This is used to compare whether two nodes have equivalent names. Return -1 for a node with no name.
      Specified by:
        `getFingerprint` in interface `NodeInfo`
      Overrides:
        `getFingerprint` in class `NodeImpl`
      Returns:
        an integer fingerprint; two nodes with the same fingerprint have the same expanded QName. For unnamed nodes (text nodes, comments, document nodes, and namespace nodes for the default namespace), returns -1.

    - #### getSchemaType

          public SchemaType getSchemaType()

      Get the type annotation
      Specified by:
        `getSchemaType` in interface `NodeInfo`
      Overrides:
        `getSchemaType` in class `NodeImpl`
      Returns:
        the type annotation of the node, if any

    - #### isId

          public boolean isId()

      Determine whether this node has the is-id property
      Returns:
        true if the node is an ID

    - #### isIdref

          public boolean isIdref()

      Determine whether this node has the is-idref property
      Returns:
        true if the node is an IDREF or IDREFS element or attribute

    - #### equals

          public boolean equals​(java.lang.Object other)

      Determine whether this is the same node as another node
      Specified by:
        `equals` in interface `NodeInfo`
      Overrides:
        `equals` in class `java.lang.Object`
      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 `java.lang.Object`

    - #### 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`
      Returns:
        the sequence number if there is one, or -1L otherwise.

    - #### 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 NodeImpl getNextSibling()

      Get next sibling - not defined for attributes
      Specified by:
        `getNextSibling` in interface `SteppingNode<NodeImpl>`
      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 NodeImpl getPreviousSibling()

      Get previous sibling - not defined for attributes
      Specified by:
        `getPreviousSibling` in interface `SteppingNode<NodeImpl>`
      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` - a buffer to which the generated ID will be written

    - #### copy

          public void copy​(Receiver out,
                           int copyOptions,
                           Location locationId)
                    throws XPathException

      Copy this node to a given outputter.
      Parameters:
        `out` - the Receiver to which the node should be copied. It is the caller's responsibility to ensure that this Receiver is open before the method is called (or that it is self-opening), and that it is closed after use.
        `copyOptions` - a selection of the options defined in `CopyOptions`
        `locationId` - If non-null, identifies the location of the instruction that requested this copy. If zero, indicates that the location information is not available
      Throws:
        `java.lang.IllegalArgumentException` - this method is not supported for attribute nodes
        `XPathException` - if any downstream error occurs

    - #### delete

          public void delete()

      Delete this node (that is, detach it from its parent)
      Specified by:
        `delete` in interface `MutableNodeInfo`
      Overrides:
        `delete` in class `NodeImpl`

    - #### isDeleted

          public boolean isDeleted()

      Test whether this MutableNodeInfo object represents a node that has been deleted. Generally, such a node is unusable, and any attempt to use it will result in an exception being thrown
      Specified by:
        `isDeleted` in interface `MutableNodeInfo`
      Overrides:
        `isDeleted` in class `NodeImpl`
      Returns:
        true if this node has been deleted

    - #### replace

          public void replace​(NodeInfo[] replacement,
                              boolean inherit)

      Replace this node with a given sequence of nodes
      Specified by:
        `replace` in interface `MutableNodeInfo`
      Overrides:
        `replace` in class `NodeImpl`
      Parameters:
        `replacement` - the replacement nodes (which for this version of the method must be attribute nodes - they may use any implementation of the NodeInfo interface). The target attribute node is deleted, and the replacement nodes are added to the parent element; if they have the same names as existing nodes, then the existing nodes will be overwritten.
        `inherit` - set to true if new child elements are to inherit the in-scope namespaces of their new parent. Not used when replacing attribute nodes.
      Throws:
        `java.lang.IllegalArgumentException` - if any of the replacement nodes is not an attribute
        `java.lang.IllegalStateException` - if this node has been deleted or has no parent node or if two of the replacement nodes have the same name

    - #### rename

          public void rename​(NodeName newNameCode,
                             boolean inheritNamespaces)

      Rename this node
      Specified by:
        `rename` in interface `MutableNodeInfo`
      Overrides:
        `rename` in class `NodeImpl`
      Parameters:
        `newNameCode` - the NamePool code of the new name
        `inheritNamespaces` -

    - #### replaceStringValue

          public void replaceStringValue​(java.lang.CharSequence stringValue)

      Description copied from interface: `MutableNodeInfo`
      Replace the string-value of this node. If applied to an element or document node, this causes all existing children to be deleted, and replaced with a new text node whose string value is the value supplied. The caller is responsible for checking that the value is valid, for example that comments do not contain a double hyphen; the implementation is not required to check for such conditions.
      Parameters:
        `stringValue` - the new string value

    - #### removeTypeAnnotation

          public void removeTypeAnnotation()

      Remove type information from this node (and its ancestors, recursively). This method implements the upd:removeType() primitive defined in the XQuery Update specification
      Specified by:
        `removeTypeAnnotation` in interface `MutableNodeInfo`
      Overrides:
        `removeTypeAnnotation` in class `NodeImpl`

    - #### setTypeAnnotation

          public void setTypeAnnotation​(SchemaType type)

      Set the type annotation on a node. This must only be called when the caller has verified (by validation) that the node is a valid instance of the specified type. The call is ignored if the node is not an element or attribute node.
      Specified by:
        `setTypeAnnotation` in interface `MutableNodeInfo`
      Overrides:
        `setTypeAnnotation` in class `NodeImpl`
      Parameters:
        `type` - the type annotation (possibly including high bits set to indicate the isID, isIDREF, and isNilled properties)