Package net.sf.saxon.expr

## Class AttributeGetter

- java.lang.Object
- - net.sf.saxon.expr.Expression
  - - net.sf.saxon.expr.AttributeGetter

- All Implemented Interfaces:
    `ExportAgent`, `Locatable`, `IdentityComparable`, `Traceable`

      public final class AttributeGetter
      extends Expression

  An AttributeGetter is an expression that returns the value of a specific attribute of the context item, provided that it is an untyped element node. That is, it represents the expression data(./@name) assuming that all data is untyped.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static int` | `CHECK_CONTEXT_ITEM_IS_NODE` |

    - ### Fields inherited from class net.sf.saxon.expr.Expression

      `EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_COST, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, WATCH_METHOD`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `AttributeGetter​(FingerprintedQName attributeName)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `PathMap.PathMapNodeSet` | `addToPathMap​(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)` | Add a representation of this expression to a PathMap.
    `int` | `computeCardinality()` | Compute the static cardinality of this expression
    `int` | `computeHashCode()` | Compute a hash code, which will then be cached for later use
    `protected int` | `computeSpecialProperties()` | Compute the special properties of this expression.
    `AttributeGetter` | `copy​(RebindingMap rebindings)` | Copy an expression.
    `boolean` | `equals​(java.lang.Object obj)` | The equals() test for expressions returns true if it can be determined that two expressions (given their static context) will return the same result in all circumstances.
    `Item` | `evaluateItem​(XPathContext context)` | Evaluate an expression as a single item.
    `void` | `export​(ExpressionPresenter out)` | Diagnostic print of expression structure.
    `FingerprintedQName` | `getAttributeName()` |
    `java.lang.String` | `getExpressionName()` | Get a name identifying the kind of expression, in terms meaningful to a user.
    `int` | `getImplementationMethod()` | An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
    `int` | `getIntrinsicDependencies()` | Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.
    `ItemType` | `getItemType()` | Determine the static item type of the expression, as precisely possible.
    `int` | `getRequiredChecks()` | Ask what run-time checks are needed.
    `void` | `setRequiredChecks​(int checks)` | Say what run-time checks are needed.
    `java.lang.String` | `toShortString()` | Produce a short string identifying the expression for use in error messages
    `java.lang.String` | `toString()` | The toString() method for an expression attempts to give a representation of the expression in an XPath-like form.

    - ### Methods inherited from class net.sf.saxon.expr.Expression

      `adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dynamicError, effectiveBooleanValue, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getStreamerName, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterate, markTailFunctionCalls, operandList, operands, operandSparseList, optimize, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, typeCheck, typeCheckChildren, typeError, unordered, verifyParentPointers`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface net.sf.saxon.trace.Traceable

      `gatherProperties`

- - ### Field Detail

    - #### CHECK_CONTEXT_ITEM_IS_NODE

          public static final int CHECK_CONTEXT_ITEM_IS_NODE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### AttributeGetter

          public AttributeGetter​(FingerprintedQName attributeName)

  - ### Method Detail

    - #### getAttributeName

          public FingerprintedQName getAttributeName()

    - #### setRequiredChecks

          public void setRequiredChecks​(int checks)

      Say what run-time checks are needed. (This information is only used when generating bytecode)
      Parameters:
        `checks` - the run-time checks that need to be performed

    - #### getRequiredChecks

          public int getRequiredChecks()

      Ask what run-time checks are needed. (This information is only used when generating bytecode)
      Returns:
        the run-time checks that need to be performed

    - #### getItemType

          public ItemType getItemType()

      Description copied from class: `Expression`
      Determine the static item type of the expression, as precisely possible. All expression return sequences, in general; this method determines the type of the items within the sequence, assuming that (a) this is known in advance, and (b) it is the same for all items in the sequence.

      This method should always return a result, though it may be the best approximation that is available at the time.

      Specified by:
        `getItemType` in class `Expression`
      Returns:
        a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)

    - #### computeCardinality

          public int computeCardinality()

      Description copied from class: `Expression`
      Compute the static cardinality of this expression
      Specified by:
        `computeCardinality` in class `Expression`
      Returns:
        the computed cardinality, as one of the values `StaticProperty.ALLOWS_ZERO_OR_ONE`, `StaticProperty.EXACTLY_ONE`, `StaticProperty.ALLOWS_ONE_OR_MORE`, `StaticProperty.ALLOWS_ZERO_OR_MORE`. May also return `StaticProperty.ALLOWS_ZERO` if the result is known to be an empty sequence, or `StaticProperty.ALLOWS_MANY` if if is known to return a sequence of length two or more.

    - #### computeSpecialProperties

          protected int computeSpecialProperties()

      Description copied from class: `Expression`
      Compute the special properties of this expression. These properties are denoted by a bit-significant integer, possible values are in class `StaticProperty`. The "special" properties are properties other than cardinality and dependencies, and most of them relate to properties of node sequences, for example whether the nodes are in document order.
      Overrides:
        `computeSpecialProperties` in class `Expression`
      Returns:
        the special properties, as a bit-significant integer

    - #### getIntrinsicDependencies

          public int getIntrinsicDependencies()

      Description copied from class: `Expression`
      Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions. For example, position() has an intrinsic dependency on the context position, while (position()+1) does not. The default implementation of the method returns 0, indicating "no dependencies".
      Overrides:
        `getIntrinsicDependencies` in class `Expression`
      Returns:
        a set of bit-significant flags identifying the "intrinsic" dependencies. The flags are documented in class net.sf.saxon.value.StaticProperty

    - #### copy

          public AttributeGetter copy​(RebindingMap rebindings)

      Description copied from class: `Expression`
      Copy an expression. This makes a deep copy.
      Specified by:
        `copy` in class `Expression`
      Parameters:
        `rebindings` - a mutable list of (old binding, new binding) pairs that is used to update the bindings held in any local variable references that are copied.
      Returns:
        the copy of the original expression

    - #### addToPathMap

          public PathMap.PathMapNodeSet addToPathMap​(PathMap pathMap,
                                                     PathMap.PathMapNodeSet pathMapNodeSet)

      Description copied from class: `Expression`
      Add a representation of this expression to a PathMap. The PathMap captures a map of the nodes visited by an expression in a source tree.

      The default implementation of this method assumes that an expression does no navigation other than the navigation done by evaluating its subexpressions, and that the subexpressions are evaluated in the same context as the containing expression. The method must be overridden for any expression where these assumptions do not hold. For example, implementations exist for AxisExpression, ParentExpression, and RootExpression (because they perform navigation), and for the doc(), document(), and collection() functions because they create a new navigation root. Implementations also exist for PathExpression and FilterExpression because they have subexpressions that are evaluated in a different context from the calling expression.

      Overrides:
        `addToPathMap` in class `Expression`
      Parameters:
        `pathMap` - the PathMap to which the expression should be added
        `pathMapNodeSet` - the PathMapNodeSet to which the paths embodied in this expression should be added
      Returns:
        the pathMapNodeSet representing the points in the source document that are both reachable by this expression, and that represent possible results of this expression. For an expression that does navigation, it represents the end of the arc in the path map that describes the navigation route. For other expressions, it is the same as the input pathMapNode.

    - #### getImplementationMethod

          public int getImplementationMethod()

      Description copied from class: `Expression`
      An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is provided directly. The other methods will always be available indirectly, using an implementation that relies on one of the other methods.
      Specified by:
        `getImplementationMethod` in class `Expression`
      Returns:
        the implementation method, for example `Expression.ITERATE_METHOD` or `Expression.EVALUATE_METHOD` or `Expression.PROCESS_METHOD`

    - #### evaluateItem

          public Item evaluateItem​(XPathContext context)
                            throws XPathException

      Description copied from class: `Expression`
      Evaluate an expression as a single item. This always returns either a single Item or null (denoting the empty sequence). No conversion is done. This method should not be used unless the static type of the expression is a subtype of "item" or "item?": that is, it should not be called if the expression may return a sequence. There is no guarantee that this condition will be detected.
      Overrides:
        `evaluateItem` in class `Expression`
      Parameters:
        `context` - The context in which the expression is to be evaluated
      Returns:
        the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
      Throws:
        `XPathException` - if any dynamic error occurs evaluating the expression

    - #### getExpressionName

          public java.lang.String getExpressionName()

      Description copied from class: `Expression`
      Get a name identifying the kind of expression, in terms meaningful to a user.
      Overrides:
        `getExpressionName` in class `Expression`
      Returns:
        a name identifying the kind of expression, in terms meaningful to a user. The name will always be in the form of a lexical XML QName, and should match the name used in export() output displaying the expression.

    - #### toShortString

          public java.lang.String toShortString()

      Description copied from class: `Expression`
      Produce a short string identifying the expression for use in error messages
      Overrides:
        `toShortString` in class `Expression`
      Returns:
        a short string, sufficient to identify the expression

    - #### toString

          public java.lang.String toString()

      Description copied from class: `Expression`

      The toString() method for an expression attempts to give a representation of the expression in an XPath-like form.

      For subclasses of Expression that represent XPath expressions, the result should always be a string that parses as an XPath 3.0 expression. The expression produced should be equivalent to the original making certain assumptions about the static context. In general the expansion will make no assumptions about namespace bindings, except that (a) the prefix "xs" is used to refer to the XML Schema namespace, and (b) the default function namespace is assumed to be the "fn" namespace.

      In the case of XSLT instructions and XQuery expressions, the toString() method gives an abstracted view of the syntax that is not designed in general to be parseable.

      Overrides:
        `toString` in class `Expression`
      Returns:
        a representation of the expression as a string

    - #### equals

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

      Description copied from class: `Expression`
      The equals() test for expressions returns true if it can be determined that two expressions (given their static context) will return the same result in all circumstances. The value false is returned if this is not the case or if it cannot be determined to be the case.

      During the various phases of compilation, expression objects are mutable. Changing an expression may change its hashCode, and may change the result of equals() comparisons. Expressions should therefore not be held in data structures such as maps and sets that depend on equality comparison unless they are no longer subject to such mutation.

      Overrides:
        `equals` in class `Expression`
      Parameters:
        `obj` - the other operand; the result is false if this is not an Expression
      Returns:
        true if the other operand is an expression and if it can be determined that the two expressions are equivalent, in the sense that they will always return the same result.

    - #### computeHashCode

          public int computeHashCode()

      Description copied from class: `Expression`
      Compute a hash code, which will then be cached for later use
      Overrides:
        `computeHashCode` in class `Expression`
      Returns:
        a computed hash code

    - #### export

          public void export​(ExpressionPresenter out)

      Description copied from class: `Expression`
      Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
      Specified by:
        `export` in interface `ExportAgent`
      Specified by:
        `export` in class `Expression`
      Parameters:
        `out` - the expression presenter used to display the structure