net.sf.saxon.expr

Class JPConverter

public abstract class JPConverter extends Object implements Serializable

This class together with its embedded subclasses handles conversion from Java values to XPath values. The general principle is to allocate a specific JPConverter at compile time wherever possible. If there is insufficient type information to make this feasible, a general-purpose JPConverter is allocated, which in turn allocates a more specific converter at run-time to do the actual work.
Nested Class Summary
static classJPConverter.FromBigDecimal
static classJPConverter.FromBigInteger
static classJPConverter.FromBoolean
static classJPConverter.FromBooleanArray
static classJPConverter.FromByte
static classJPConverter.FromByteArray
static classJPConverter.FromCharArray
static classJPConverter.FromCharacter
static classJPConverter.FromCollection
static classJPConverter.FromDate
static classJPConverter.FromDouble
static classJPConverter.FromDoubleArray
static classJPConverter.FromFloat
static classJPConverter.FromFloatArray
static classJPConverter.FromInt
static classJPConverter.FromIntArray
static classJPConverter.FromLong
static classJPConverter.FromLongArray
static classJPConverter.FromObjectArray
static classJPConverter.FromQName
static classJPConverter.FromSequenceIterator
static classJPConverter.FromShort
static classJPConverter.FromShortArray
static classJPConverter.FromSource
static classJPConverter.FromString
static classJPConverter.FromURI
static classJPConverter.FromValueRepresentation
static classJPConverter.WrapExternalObject
Method Summary
static JPConverterallocate(Class javaClass, Configuration config)
Allocate a Java-to-XPath converter for a given class of Java objects
Stringcompile(String var, CodeGeneratorService compiler)
Generate a Java expression (as text) that can be used to implement this conversion when compiling a query
abstract ValueRepresentationconvert(Object object, XPathContext context)
Convert a Java object to an equivalent XPath value
intgetCardinality()
Get the cardinality of the XPath value that will result from the conversion
abstract ItemTypegetItemType()
Get the item type of the XPath value that will result from the conversion

Method Detail

allocate

public static JPConverter allocate(Class javaClass, Configuration config)
Allocate a Java-to-XPath converter for a given class of Java objects

Parameters: javaClass the class of the Java object to be converted (this may be the static type or the dynamic type, depending when the converter is allocated) config the Saxon Configuration

Returns: a suitable converter

compile

public String compile(String var, CodeGeneratorService compiler)
Generate a Java expression (as text) that can be used to implement this conversion when compiling a query

Parameters: var the Java variable that will hold the Java value to be converted compiler provides callback services

Returns: a Java expression (as text) that implements the conversion. The result of the Java expression must be of type ValueRepresentation, and if the cardinality of the converter is exactly one then it must be of type Item.

convert

public abstract ValueRepresentation convert(Object object, XPathContext context)
Convert a Java object to an equivalent XPath value

Parameters: object the java object to be converted context the XPath dynamic evaluation context

Returns: the XPath value resulting from the conversion

Throws: XPathException if the conversion is not possible or if it fails

getCardinality

public int getCardinality()
Get the cardinality of the XPath value that will result from the conversion

Returns: the cardinality of the result

getItemType

public abstract ItemType getItemType()
Get the item type of the XPath value that will result from the conversion

Returns: the XPath item type