Package net.sf.saxon.type.coercion
Class AtomicCoercionPlan
java.lang.Object
net.sf.saxon.type.coercion.CoercionPlan
net.sf.saxon.type.coercion.AtomicCoercionPlan
- Direct Known Subclasses:
AnyURICoercionPlan,Base64BinaryCoercionPlan,ChoiceCoercionPlan,DecimalCoercionPlan,DerivedAtomicCoercionPlan,DoubleCoercionPlan,FloatCoercionPlan,HexBinaryCoercionPlan,QNameCoercionPlan,SingletonEnumerationCoercionPlan,StringCoercionPlan,UnionCoercionPlan
A coercion plan represents a process for implementing the coercion rules for converting
a supplied value to a given required type. An AtomicCoercionPlan is used where the required
item type is atomic, and is further refined for specific atomic types where special rules
apply.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AtomicValuecoerceAtomicValue(AtomicValue atom, ItemType requiredType, CoercionRequest request) Coerce an atomic value to the required atomic type.coerceItem(Item item, ItemType requiredType, CoercionRequest request) Apply the coercion rules (function conversion rules) to a value, given a required type.protected AtomicValueconvertUntyped(AtomicValue atom, ItemType requiredType, CoercionRequest request) Coerce an untyped atomic value to the required atomic type.static AtomicCoercionPlanprotected AtomicValuepromote(AtomicValue atom, ItemType requiredType, CoercionRequest request) Promote an atomic value to the required atomic type.Methods inherited from class net.sf.saxon.type.coercion.CoercionPlan
check, coerceSequence, coercionError
-
Constructor Details
-
AtomicCoercionPlan
public AtomicCoercionPlan()
-
-
Method Details
-
getInstance
-
coerceItem
public GroundedValue coerceItem(Item item, ItemType requiredType, CoercionRequest request) throws XPathException Apply the coercion rules (function conversion rules) to a value, given a required type.- Specified by:
coerceItemin classCoercionPlan- Parameters:
item- the value to be convertedrequiredType- the required type (always atomic)request- the input to the coercion- Returns:
- the converted value (possibly as a lazily-evaluated sequence)
- Throws:
XPathException- if the value cannot be converted to the required type
-
coerceAtomicValue
protected AtomicValue coerceAtomicValue(AtomicValue atom, ItemType requiredType, CoercionRequest request) throws XPathException Coerce an atomic value to the required atomic type. This method essentially handles conversion of untypedAtomic values to the target type, followed by type promotion (for example decimal to double).- Parameters:
atom- the atomic value to be convertedrequiredType- the required atomic typerequest- details of the coercion request for diagnostics- Returns:
- the converted atomic value
- Throws:
XPathException- if conversion fails
-
convertUntyped
protected AtomicValue convertUntyped(AtomicValue atom, ItemType requiredType, CoercionRequest request) throws XPathException Coerce an untyped atomic value to the required atomic type.- Parameters:
atom- the untyped atomic value to be convertedrequiredType- the required atomic typerequest- details of the coercion request for diagnostics- Returns:
- the converted atomic value
- Throws:
XPathException- if conversion fails
-
promote
protected AtomicValue promote(AtomicValue atom, ItemType requiredType, CoercionRequest request) throws XPathException Promote an atomic value to the required atomic type. This handles, for example, decimal to string conversion or base64Binary to hexBinary. It also handles down-casting to derived atomic types. The default implementation returns the supplied value unchanged.- Parameters:
atom- the untyped atomic value to be convertedrequiredType- the required atomic typerequest- details of the coercion request for diagnostics- Returns:
- the converted atomic value
- Throws:
XPathException- if conversion fails
-