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 intCHECK_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.PathMapNodeSetaddToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)Add a representation of this expression to a PathMap.intcomputeCardinality()Compute the static cardinality of this expressionintcomputeHashCode()Compute a hash code, which will then be cached for later useprotected intcomputeSpecialProperties()Compute the special properties of this expression.AttributeGettercopy(RebindingMap rebindings)Copy an expression.booleanequals(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.ItemevaluateItem(XPathContext context)Evaluate an expression as a single item.voidexport(ExpressionPresenter out)Diagnostic print of expression structure.FingerprintedQNamegetAttributeName()java.lang.StringgetExpressionName()Get a name identifying the kind of expression, in terms meaningful to a user.intgetImplementationMethod()An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().intgetIntrinsicDependencies()Determine the intrinsic dependencies of an expression, that is, those which are not derived from the dependencies of its subexpressions.ItemTypegetItemType()Determine the static item type of the expression, as precisely possible.intgetRequiredChecks()Ask what run-time checks are needed.voidsetRequiredChecks(int checks)Say what run-time checks are needed.java.lang.StringtoShortString()Produce a short string identifying the expression for use in error messagesjava.lang.StringtoString()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:ExpressionDetermine 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:
getItemTypein classExpression- 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:ExpressionCompute the static cardinality of this expression- Specified by:
computeCardinalityin classExpression- 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 returnStaticProperty.ALLOWS_ZEROif the result is known to be an empty sequence, orStaticProperty.ALLOWS_MANYif if is known to return a sequence of length two or more.
-
computeSpecialProperties
protected int computeSpecialProperties()
Description copied from class:ExpressionCompute the special properties of this expression. These properties are denoted by a bit-significant integer, possible values are in classStaticProperty. 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:
computeSpecialPropertiesin classExpression- Returns:
- the special properties, as a bit-significant integer
-
getIntrinsicDependencies
public int getIntrinsicDependencies()
Description copied from class:ExpressionDetermine 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:
getIntrinsicDependenciesin classExpression- 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:ExpressionCopy an expression. This makes a deep copy.- Specified by:
copyin classExpression- 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:ExpressionAdd 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:
addToPathMapin classExpression- Parameters:
pathMap- the PathMap to which the expression should be addedpathMapNodeSet- 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:ExpressionAn 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:
getImplementationMethodin classExpression- Returns:
- the implementation method, for example
Expression.ITERATE_METHODorExpression.EVALUATE_METHODorExpression.PROCESS_METHOD
-
evaluateItem
public Item evaluateItem(XPathContext context) throws XPathException
Description copied from class:ExpressionEvaluate 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:
evaluateItemin classExpression- 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:ExpressionGet a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionNamein classExpression- 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:ExpressionProduce a short string identifying the expression for use in error messages- Overrides:
toShortStringin classExpression- Returns:
- a short string, sufficient to identify the expression
-
toString
public java.lang.String toString()
Description copied from class:ExpressionThe 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:
toStringin classExpression- Returns:
- a representation of the expression as a string
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:ExpressionThe 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:
equalsin classExpression- 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:ExpressionCompute a hash code, which will then be cached for later use- Overrides:
computeHashCodein classExpression- Returns:
- a computed hash code
-
export
public void export(ExpressionPresenter out)
Description copied from class:ExpressionDiagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
exportin interfaceExportAgent- Specified by:
exportin classExpression- Parameters:
out- the expression presenter used to display the structure
-
-