Package net.sf.saxon.expr
Class PJConverter
- java.lang.Object
-
- net.sf.saxon.expr.PJConverter
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
PJConverter.AnyURIValueToURI
,PJConverter.AnyURIValueToURL
,PJConverter.Atomic
,PJConverter.BooleanValueToBoolean
,PJConverter.CalendarValueToCalendar
,PJConverter.CalendarValueToDate
,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.ToSequenceExtent
,PJConverter.ToSequenceIterator
,PJConverter.UnwrapExternalObject
public abstract class PJConverter extends java.lang.Object implements java.io.Serializable
This class together with its embedded subclasses handles conversion from XPath values to Java values- See Also:
- Serialized Form
-
-
Nested Class Summary
-
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 classstatic 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)java.lang.String
compile(java.lang.String var, java.lang.Class targetClass, CodeGeneratorService compiler)
Generate Java code to implement the type conversionabstract java.lang.Object
convert(ValueRepresentation value, java.lang.Class targetClass, XPathContext context)
Convert an XPath value to a Java value of a specified classstatic SequenceType
getEquivalentItemType(java.lang.Class javaClass)
Get the nearest XPath equivalent to a Java class.
-
-
-
Method Detail
-
getEquivalentItemType
public static SequenceType getEquivalentItemType(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
-
convert
public abstract java.lang.Object convert(ValueRepresentation 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 valuetargetClass
- the class of the required Java valuecontext
- 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
-
compile
public java.lang.String compile(java.lang.String var, java.lang.Class targetClass, CodeGeneratorService compiler)
Generate Java code to implement the type conversion- Parameters:
var
- the name of a variable whose value will be the XPath ValueRepresentation to be convertedtargetClass
- the required class of the Java valuecompiler
- provides supporting services by callback @return the text of a Java expression whose result will be a Java object/value of the required type
-
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 ConfigurationitemType
- the item type of the XPath value to be convertedcardinality
- the cardinality of the XPath value to be convertedtargetClass
- the Java class required for the conversion result- Returns:
- a suitable converter
- Throws:
XPathException
-
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)
-
-