Package net.sf.saxon.expr
Class JPConverter
java.lang.Object
net.sf.saxon.expr.JPConverter
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
JPConverter.FromBigDecimal
,JPConverter.FromBigInteger
,JPConverter.FromBoolean
,JPConverter.FromBooleanArray
,JPConverter.FromByte
,JPConverter.FromByteArray
,JPConverter.FromCharacter
,JPConverter.FromCharArray
,JPConverter.FromCollection
,JPConverter.FromDate
,JPConverter.FromDouble
,JPConverter.FromDoubleArray
,JPConverter.FromFloat
,JPConverter.FromFloatArray
,JPConverter.FromInt
,JPConverter.FromIntArray
,JPConverter.FromLong
,JPConverter.FromLongArray
,JPConverter.FromObjectArray
,JPConverter.FromQName
,JPConverter.FromSequenceIterator
,JPConverter.FromShort
,JPConverter.FromShortArray
,JPConverter.FromSource
,JPConverter.FromString
,JPConverter.FromURI
,JPConverter.FromValueRepresentation
,JPConverter.WrapExternalObject
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.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
static class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JPConverter
allocate
(Class javaClass, Configuration config) compile
(String var, CodeGeneratorService compiler) Generate a Java expression (as text) that can be used to implement this conversion when compiling a queryabstract ValueRepresentation
convert
(Object object, XPathContext context) Convert a Java object to an equivalent XPath valueint
Get the cardinality of the XPath value that will result from the conversionabstract ItemType
Get the item type of the XPath value that will result from the conversion
-
Constructor Details
-
JPConverter
public JPConverter()
-
-
Method Details
-
allocate
-
convert
public abstract ValueRepresentation convert(Object object, XPathContext context) throws XPathException Convert a Java object to an equivalent XPath value- Parameters:
object
- the java object to be convertedcontext
- 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
-
getItemType
Get the item type of the XPath value that will result from the conversion- Returns:
- the XPath item type
-
getCardinality
public int getCardinality()Get the cardinality of the XPath value that will result from the conversion- Returns:
- the cardinality of the result
-
compile
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 convertedcompiler
- 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.
-