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

public class AtomicCoercionPlan extends CoercionPlan
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 Details

    • AtomicCoercionPlan

      public AtomicCoercionPlan()
  • Method Details

    • getInstance

      public static AtomicCoercionPlan 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:
      coerceItem in class CoercionPlan
      Parameters:
      item - the value to be converted
      requiredType - 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 converted
      requiredType - the required atomic type
      request - 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 converted
      requiredType - the required atomic type
      request - 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 converted
      requiredType - the required atomic type
      request - details of the coercion request for diagnostics
      Returns:
      the converted atomic value
      Throws:
      XPathException - if conversion fails