Package net.sf.saxon.expr
Class UntypedSequenceConverter
- java.lang.Object
-
- net.sf.saxon.expr.Expression
-
- net.sf.saxon.expr.UnaryExpression
-
- net.sf.saxon.expr.AtomicSequenceConverter
-
- net.sf.saxon.expr.UntypedSequenceConverter
-
- All Implemented Interfaces:
ExportAgent
,Locatable
,IdentityComparable
,Traceable
public final class UntypedSequenceConverter extends AtomicSequenceConverter
An UntypedSequenceConverter is an expression that performs a cast on each member of a supplied sequence that is an untypedAtomic value, while leaving other items unchanged
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UntypedSequenceConverter.UntypedConverter
A Converter that converts untyped atomic values to the required type, while leaving other values unchanged-
Nested classes/interfaces inherited from class net.sf.saxon.expr.AtomicSequenceConverter
AtomicSequenceConverter.AtomicSequenceMappingFunction, AtomicSequenceConverter.ToStringMappingFunction
-
-
Field Summary
-
Fields inherited from class net.sf.saxon.expr.AtomicSequenceConverter
converter, requiredItemType, TO_STRING_MAPPER
-
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 UntypedSequenceConverter(Expression sequence, PlainType requiredItemType)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
computeCardinality()
Determine the static cardinality of the expressionint
computeHashCode()
get HashCode for comparing two expressions.int
computeSpecialProperties()
Determine the special properties of this expressionExpression
copy(RebindingMap rebindings)
Copy an expression.protected java.lang.String
displayOperator(Configuration config)
Give a string representation of the operator for use in diagnosticsboolean
equals(java.lang.Object other)
Is this expression the same as another expression?void
export(ExpressionPresenter destination)
Diagnostic print of expression structure.java.lang.String
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.ItemType
getItemType()
Determine the data type of the items returned by the expression, if possiblestatic UntypedSequenceConverter
makeUntypedSequenceConverter(Configuration config, Expression operand, PlainType requiredItemType)
Create an AtomicSequenceConverter that converts all untypedAtomic values in the input sequence to a specified target type, while leaving items other than untypedAtomic unchangedstatic UntypedSequenceConverter
makeUntypedSequenceRejector(Configuration config, Expression operand, PlainType requiredItemType)
java.lang.String
toShortString()
Produce a short string identifying the expression for use in error messagesExpression
typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo)
Type-check the expression-
Methods inherited from class net.sf.saxon.expr.AtomicSequenceConverter
allocateConverter, allocateConverter, allocateConverterStatically, evaluateItem, getConverter, getConverterDynamically, getImplementationMethod, getOperandRole, getRequiredItemType, getRoleDiagnostic, getStreamerName, iterate, optimize, setConverter, setRoleDiagnostic, simplify
-
Methods inherited from class net.sf.saxon.expr.UnaryExpression
emitExtraAttributes, getBaseExpression, getOperand, operands, setBaseExpression, toString
-
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dynamicError, effectiveBooleanValue, evaluateAsString, evaluatePendingUpdates, explain, getCardinality, getConfiguration, getCost, getDependencies, getEvaluationMethod, getExtraProperty, getIntegerBounds, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, getStaticUType, getTracingTag, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, markTailFunctionCalls, operandList, operandSparseList, optimizeChildren, prepareForStreaming, process, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplifyChildren, staticTypeCheck, suppressValidation, toPattern, 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
-
-
-
-
Constructor Detail
-
UntypedSequenceConverter
public UntypedSequenceConverter(Expression sequence, PlainType requiredItemType)
Constructor- Parameters:
sequence
- this must be a sequence of atomic values. This is not checked; a ClassCastException will occur if the precondition is not satisfied.requiredItemType
- the item type to which all items in the sequence should be converted, using the rules for "cast as".
-
-
Method Detail
-
makeUntypedSequenceConverter
public static UntypedSequenceConverter makeUntypedSequenceConverter(Configuration config, Expression operand, PlainType requiredItemType) throws XPathException
Create an AtomicSequenceConverter that converts all untypedAtomic values in the input sequence to a specified target type, while leaving items other than untypedAtomic unchanged- Parameters:
config
- the Saxon configurationoperand
- the expression that delivers the input sequencerequiredItemType
- the type to which untypedAtomic values should be cast, which must either be an atomic type or a "plain" union type- Returns:
- an AtomicSequenceConverter that performs the required conversion
- Throws:
XPathException
- if an error occurs, for example if the target type is namespace-sensitive
-
makeUntypedSequenceRejector
public static UntypedSequenceConverter makeUntypedSequenceRejector(Configuration config, Expression operand, PlainType requiredItemType)
-
typeCheck
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
Description copied from class:AtomicSequenceConverter
Type-check the expression- Overrides:
typeCheck
in classAtomicSequenceConverter
- Parameters:
visitor
- an expression visitorcontextInfo
- Information available statically about the context item: whether it is (possibly) absent; its static type; its streaming posture.- Returns:
- the original expression, rewritten to perform necessary run-time type checks, and to perform other type-related optimizations
- Throws:
XPathException
- if an error is discovered during this phase (typically a type error)
-
computeSpecialProperties
public int computeSpecialProperties()
Determine the special properties of this expression- Overrides:
computeSpecialProperties
in classAtomicSequenceConverter
- Returns:
StaticProperty.NO_NODES_NEWLY_CREATED
.
-
copy
public Expression copy(RebindingMap rebindings)
Copy an expression. This makes a deep copy.- Overrides:
copy
in classAtomicSequenceConverter
- Parameters:
rebindings
-- Returns:
- the copy of the original expression
-
getItemType
public ItemType getItemType()
Determine the data type of the items returned by the expression, if possible- Overrides:
getItemType
in classAtomicSequenceConverter
- Returns:
- a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known in advance)
-
computeCardinality
public int computeCardinality()
Determine the static cardinality of the expression- Overrides:
computeCardinality
in classAtomicSequenceConverter
- 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_ZERO
if the result is known to be an empty sequence, orStaticProperty.ALLOWS_MANY
if if is known to return a sequence of length two or more.
-
equals
public boolean equals(java.lang.Object other)
Is this expression the same as another expression?- Overrides:
equals
in classAtomicSequenceConverter
- Parameters:
other
- 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()
get HashCode for comparing two expressions.- Overrides:
computeHashCode
in classAtomicSequenceConverter
- Returns:
- a computed hash code
-
displayOperator
protected java.lang.String displayOperator(Configuration config)
Description copied from class:UnaryExpression
Give a string representation of the operator for use in diagnostics- Overrides:
displayOperator
in classAtomicSequenceConverter
- Parameters:
config
- the Saxon configuration- Returns:
- the operator, as a string
-
getExpressionName
public java.lang.String getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.- Overrides:
getExpressionName
in classAtomicSequenceConverter
- 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 explain() 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 classUnaryExpression
- Returns:
- a short string, sufficient to identify the expression
-
export
public void export(ExpressionPresenter destination) throws XPathException
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.- Specified by:
export
in interfaceExportAgent
- Overrides:
export
in classAtomicSequenceConverter
- Parameters:
destination
- the expression presenter used to display the structure- Throws:
XPathException
- if the export fails, for example if an expression is found that won't work in the target environment.
-
-