Package net.sf.saxon.expr
Class CastingExpression
java.lang.Object
net.sf.saxon.expr.Expression
net.sf.saxon.expr.UnaryExpression
net.sf.saxon.expr.CastingExpression
- All Implemented Interfaces:
Serializable
,SourceLocator
,LocationProvider
,SaxonLocator
,InstructionInfo
,Locator
- Direct Known Subclasses:
CastableExpression
,CastExpression
Casting Expression: abstract superclass for "cast as X" and "castable as X", which share a good deal of logic
- See Also:
-
Field Summary
FieldsFields inherited from class net.sf.saxon.expr.UnaryExpression
operand
Fields inherited from class net.sf.saxon.expr.Expression
EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, EVENT_FEED_METHOD, ITEM_FEED_METHOD, ITERATE_METHOD, locationId, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, PUSH_SELECTION, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, WATCH_METHOD
-
Constructor Summary
ConstructorsConstructorDescriptionCastingExpression
(Expression source, AtomicType target, boolean allowEmpty) Create a cast expression -
Method Summary
Modifier and TypeMethodDescriptionboolean
Ask whether the expression accepts an empty sequence as input (producing an empty sequence as output)int
Determine the special properties of this expressionGet the Converter allocated to implement this cast expression, if anyGet the namespace resolver, if anyGet the primitive base type of the target type of the castGet the target type (the result type)boolean
Ask whether the operand to the cast expression was supplied in the form of a string literal.void
setAllowEmpty
(boolean allow) Say whether the expression accepts an empty sequence as input (producing an empty sequence as output)void
setNamespaceResolver
(NamespaceResolver resolver) Set the namespace resolver, if anyvoid
setOperandIsStringLiteral
(boolean option) Say whether the operand to the cast expression was supplied in the form of a string literal.void
setTargetType
(AtomicType type) Set the target typesimplify
(ExpressionVisitor visitor) Simplify the expressionMethods inherited from class net.sf.saxon.expr.UnaryExpression
computeCardinality, displayOperator, equals, explain, getBaseExpression, getItemType, hashCode, iterateSubExpressions, optimize, promote, replaceSubExpression, toString, typeCheck
Methods inherited from class net.sf.saxon.expr.Expression
addToPathMap, adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, copy, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, evaluatePendingUpdates, explain, getCardinality, getColumnNumber, getColumnNumber, getConstructType, getContainer, getDependencies, getEvaluationMethod, getExecutable, getExpressionName, getHostLanguage, getImplementationMethod, getIntegerBounds, getIntrinsicDependencies, getLineNumber, getLineNumber, getLocationId, getLocationProvider, getObjectName, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, getSystemId, hasLoopingSubexpression, hasVariableBinding, implementsStaticTypeCheck, isSubtreeExpression, isUpdatingExpression, isVacuousExpression, iterate, iterateEvents, iterateSameFocusSubExpressions, markTailFunctionCalls, process, resetLocalStaticProperties, setContainer, setEvaluationMethod, setFiltered, setFlattened, setLocationId, staticTypeCheck, suppressValidation, typeError
-
Field Details
-
converter
-
nsResolver
-
-
Constructor Details
-
CastingExpression
Create a cast expression- Parameters:
source
- expression giving the value to be convertedtarget
- the type to which the value is to be convertedallowEmpty
- true if the expression allows an empty sequence as input, producing an empty sequence as output. If false, an empty sequence is a type error.
-
-
Method Details
-
getTargetPrimitiveType
Get the primitive base type of the target type of the cast- Returns:
- the primitive type of the target type
-
setTargetType
Set the target type- Parameters:
type
- the target type for the cast
-
getTargetType
Get the target type (the result type)- Returns:
- the target type
-
setAllowEmpty
public void setAllowEmpty(boolean allow) Say whether the expression accepts an empty sequence as input (producing an empty sequence as output)- Parameters:
allow
- true if an empty sequence is accepted
-
allowsEmpty
public boolean allowsEmpty()Ask whether the expression accepts an empty sequence as input (producing an empty sequence as output)- Returns:
- true if an empty sequence is accepted
-
setOperandIsStringLiteral
public void setOperandIsStringLiteral(boolean option) Say whether the operand to the cast expression was supplied in the form of a string literal. This is relevant only for XPath 2.0 / XQuery 1.0, and then only when the target type is a QName or NOTATION.- Parameters:
option
- true if the operand was supplied as a string literal
-
isOperandIsStringLiteral
public boolean isOperandIsStringLiteral()Ask whether the operand to the cast expression was supplied in the form of a string literal. This is relevant only for XPath 2.0 / XQuery 1.0, and then only when the target type is a QName or NOTATION.- Returns:
- true if the operand was supplied as a string literal
-
getConverter
Get the Converter allocated to implement this cast expression, if any- Returns:
- the Converter if one has been statically allocated, or null if not
-
setNamespaceResolver
Set the namespace resolver, if any- Parameters:
resolver
- the namespace resolver to be used if the target type is namespace-sensitive
-
getNamespaceResolver
Get the namespace resolver, if any- Returns:
- the namespace resolver that was statically allocated if the target type is namespace-sensitive
-
simplify
Simplify the expression- Overrides:
simplify
in classUnaryExpression
- Parameters:
visitor
- an expression visitor- Returns:
- the simplified expression
- Throws:
XPathException
- if an error is discovered during expression rewriting
-
computeSpecialProperties
public int computeSpecialProperties()Determine the special properties of this expression- Overrides:
computeSpecialProperties
in classUnaryExpression
- Returns:
StaticProperty.NON_CREATIVE
.
-