Package net.sf.saxon.expr

## Class PJConverter

- java.lang.Object
- - net.sf.saxon.expr.PJConverter

- Direct Known Subclasses:
    `PJConverter.AnyURIValueToURI`, `PJConverter.AnyURIValueToURL`, `PJConverter.Atomic`, `PJConverter.BooleanValueToBoolean`, `PJConverter.CalendarValueToCalendar`, `PJConverter.CalendarValueToDate`, `PJConverter.CalendarValueToInstant`, `PJConverter.CalendarValueToLocalDateTime`, `PJConverter.CalendarValueToOffsetDateTime`, `PJConverter.CalendarValueToZonedDateTime`, `PJConverter.DateValueToLocalDate`, `PJConverter.General`, `PJConverter.Identity`, `PJConverter.IntegerValueToBigInteger`, `PJConverter.IntegerValueToByte`, `PJConverter.IntegerValueToChar`, `PJConverter.IntegerValueToInt`, `PJConverter.IntegerValueToLong`, `PJConverter.IntegerValueToShort`, `PJConverter.NumericValueToBigDecimal`, `PJConverter.NumericValueToDouble`, `PJConverter.NumericValueToFloat`, `PJConverter.QualifiedNameValueToQName`, `PJConverter.StringValueToChar`, `PJConverter.StringValueToString`, `PJConverter.ToArray`, `PJConverter.ToCollection`, `PJConverter.ToNull`, `PJConverter.ToOne`, `PJConverter.ToOneOrMore`, `PJConverter.ToSequenceExtent`, `PJConverter.ToSequenceIterator`, `PJConverter.ToZeroOrMore`, `PJConverter.ToZeroOrOne`, `PJConverter.UnwrapExternalObject`

      public abstract class PJConverter
      extends java.lang.Object

  This class together with its embedded subclasses handles conversion from XPath values to Java values

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `PJConverter.AnyURIValueToURI` |
    `static class` | `PJConverter.AnyURIValueToURL` |
    `static class` | `PJConverter.Atomic` | Converter for use when the source object is an atomic value, but nothing more is known statically.
    `static class` | `PJConverter.BooleanValueToBoolean` |
    `static class` | `PJConverter.CalendarValueToCalendar` |
    `static class` | `PJConverter.CalendarValueToDate` |
    `static class` | `PJConverter.CalendarValueToInstant` |
    `static class` | `PJConverter.CalendarValueToLocalDateTime` |
    `static class` | `PJConverter.CalendarValueToOffsetDateTime` |
    `static class` | `PJConverter.CalendarValueToZonedDateTime` |
    `static class` | `PJConverter.DateValueToLocalDate` |
    `static class` | `PJConverter.General` | General-purpose converter when nothing more specific is available.
    `static class` | `PJConverter.Identity` |
    `static class` | `PJConverter.IntegerValueToBigInteger` |
    `static class` | `PJConverter.IntegerValueToByte` |
    `static class` | `PJConverter.IntegerValueToChar` |
    `static class` | `PJConverter.IntegerValueToInt` |
    `static class` | `PJConverter.IntegerValueToLong` |
    `static class` | `PJConverter.IntegerValueToShort` |
    `static class` | `PJConverter.NumericValueToBigDecimal` |
    `static class` | `PJConverter.NumericValueToDouble` |
    `static class` | `PJConverter.NumericValueToFloat` |
    `static class` | `PJConverter.QualifiedNameValueToQName` |
    `static class` | `PJConverter.StringValueToChar` |
    `static class` | `PJConverter.StringValueToString` |
    `static class` | `PJConverter.ToArray` | Converter for use when the target class is an array
    `static class` | `PJConverter.ToCollection` | Converter for use when the target class is a collection class.
    `static class` | `PJConverter.ToNull` |
    `static class` | `PJConverter.ToOne` | Converter for use when the target class is `One`, which constrains the value to be a singleton
    `static class` | `PJConverter.ToOneOrMore` | Converter for use when the target class is `OneOrMore`, which constrains the value to be a non-empty sequence
    `static class` | `PJConverter.ToSequenceExtent` |
    `static class` | `PJConverter.ToSequenceIterator` |
    `static class` | `PJConverter.ToZeroOrMore` | Converter for use when the target class is `ZeroOrMore`, which allows any sequence but is a generic (parameterized) class so there is compile-time information about the type of items
    `static class` | `PJConverter.ToZeroOrOne` | Converter for use when the target class is `ZeroOrOne`, which constrains the value to be a singleton or an empty sequence
    `static class` | `PJConverter.UnwrapExternalObject` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `PJConverter()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static PJConverter` | `allocate​(Configuration config, ItemType itemType, int cardinality, java.lang.Class<?> targetClass)` | Factory method to instantiate a converter from a given XPath type to a given Java class
    `static PJConverter` | `allocateNodeListCreator​(Configuration config, java.lang.Object node)` | Static method to get a converter from an XPath sequence of nodes to the representation of a NodeList in an external object model (this is really a special for DOM, which uses NodeList rather than general purpose Java collection classes)
    `abstract java.lang.Object` | `convert​(Sequence value, java.lang.Class<?> targetClass, XPathContext context)` | Convert an XPath value to a Java value of a specified class
    `static SequenceType` | `getEquivalentSequenceType​(java.lang.Class javaClass)` | Get the nearest XPath equivalent to a Java class.
    `static SequenceType` | `getParameterizedSequenceType​(java.lang.reflect.Type javaType)` | Get the nearest XPath equivalent to a Java parameterized type.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PJConverter

          public PJConverter()

  - ### Method Detail

    - #### getEquivalentSequenceType

          public static SequenceType getEquivalentSequenceType​(java.lang.Class javaClass)

      Get the nearest XPath equivalent to a Java class. A function call will be type-checked against an XPath function signature in which the Java classes are replaced by their nearest equivalent XPath types
      Parameters:
        `javaClass` - a Java class
      Returns:
        the nearest equivalent XPath SequenceType

    - #### getParameterizedSequenceType

          public static SequenceType getParameterizedSequenceType​(java.lang.reflect.Type javaType)

      Get the nearest XPath equivalent to a Java parameterized type. The only parameterized types we recognize are those like Sequence<StringValue> which correspond exactly to an XPath SequenceType.
      Parameters:
        `javaType` - a parameterized Java class
      Returns:
        the nearest equivalent XPath SequenceType

    - #### convert

          public abstract java.lang.Object convert​(Sequence value,
                                                   java.lang.Class<?> targetClass,
                                                   XPathContext context)
                                            throws XPathException

      Convert an XPath value to a Java value of a specified class
      Parameters:
        `value` - the supplied XPath value
        `targetClass` - the class of the required Java value
        `context` - the XPath dynamic context
      Returns:
        the corresponding Java value, which is guaranteed to be an instance of the target class (except that an empty sequence is converted to null)
      Throws:
        `XPathException` - if the conversion is not possible or fails

    - #### allocate

          public static PJConverter allocate​(Configuration config,
                                             ItemType itemType,
                                             int cardinality,
                                             java.lang.Class<?> targetClass)
                                      throws XPathException

      Factory method to instantiate a converter from a given XPath type to a given Java class
      Parameters:
        `config` - the Saxon Configuration
        `itemType` - the item type of the XPath value to be converted
        `cardinality` - the cardinality of the XPath value to be converted
        `targetClass` - the Java class required for the conversion result
      Returns:
        a suitable converter
      Throws:
        `XPathException` - if no conversion is possible

    - #### allocateNodeListCreator

          public static PJConverter allocateNodeListCreator​(Configuration config,
                                                            java.lang.Object node)

      Static method to get a converter from an XPath sequence of nodes to the representation of a NodeList in an external object model (this is really a special for DOM, which uses NodeList rather than general purpose Java collection classes)
      Parameters:
        `config` - the Saxon configuration
        `node` - an object representing a node in an external model
      Returns:
        the Java object representing the external node