| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.saxon.type.Converter
public abstract class Converter
A converter implements conversions from one atomic type to another - that is, it implements the casting rules for a (source type, destination type) pair.
There is potentially one Converter implementation for each pair of (source, target) classes; though in many cases the same implementation handles a number of such pairs.
In cases where the conversion rules are fixed (specifically, where they do not depend on differences between
 versions of the XSD or QT specifications), the appropriate Converter can be obtained as a static constant, for example
 BOOLEAN_TO_DOUBLE. In other cases the converter is paramaterized by the ConversionRules object,
 and should be obtained by calling the appropriate factory method on the ConversionRules.
Where the source type of the conversion is xs:string, the converter will always be a subclass of
 StringConverter
| Nested Class Summary | |
|---|---|
| static class | Converter.Base64BinaryToHexBinaryConverts base64 to hexBinary | 
| static class | Converter.BooleanToDecimalConverts a boolean to a decimal | 
| static class | Converter.BooleanToDoubleConverts a boolean to a double | 
| static class | Converter.BooleanToFloatConverts a boolean to an xs:float | 
| static class | Converter.BooleanToIntegerConverts a boolean to an integer | 
| static class | Converter.DateTimeToDateConverts a dateTime to a date | 
| static class | Converter.DateTimeToGDayConverts a dateTime to a gDay | 
| static class | Converter.DateTimeToGMonthConverts a dateTime to a gMonth | 
| static class | Converter.DateTimeToGMonthDayConverts a dateTime to a gMonthDay | 
| static class | Converter.DateTimeToGYearConverts a dateTime to a gYear | 
| static class | Converter.DateTimeToGYearMonthConverts a dateTime to a gYearMonth | 
| static class | Converter.DateTimeToTimeConverts a dateTime to a time | 
| static class | Converter.DateToDateTimeConverts a date to a dateTime | 
| static class | Converter.DecimalToIntegerConverts a decimal to an integer. | 
| static class | Converter.DoubleToDecimalConvers a double to a decimal | 
| static class | Converter.DoubleToIntegerConverts a double to an integer | 
| static class | Converter.DownCastingConverterConverter that does nothing except change the type annotation of the value. | 
| static class | Converter.DurationToDayTimeDurationConverts a duration to a dayTimeDuration | 
| static class | Converter.DurationToYearMonthDurationConverts a duration to a yearMonthDuration | 
| static class | Converter.FloatToDecimalConverts a float to a decimal | 
| static class | Converter.FloatToIntegerConverts a float to an integer | 
| static class | Converter.HexBinaryToBase64BinaryConverts hexBinary to base64Binary | 
| static class | Converter.IntegerToDecimalConverts an integer to a decimal | 
| static class | Converter.NotationToQNameConverts Notation to QName | 
| static class | Converter.NumericToBooleanConverts a numeric value to a boolean | 
| static class | Converter.NumericToDecimalConverts any numeric value to a decimal | 
| static class | Converter.NumericToDoubleConverts any numeric value to a double. | 
| static class | Converter.NumericToFloatConverts any numeric value to xs:float | 
| static class | Converter.NumericToIntegerConverts any numeric value to an integer. | 
| static class | Converter.PromoterToDoubleConverter that implements the promotion rules to a required type of xs:double | 
| static class | Converter.PromoterToFloatConverter that implements the promotion rules to a required type of xs:float | 
| static class | Converter.QNameToNotationConverts QName to Notation | 
| static class | Converter.StringToBase64BinaryConverterConverts string to base64 | 
| static class | Converter.ToStringConverterConverts any value to a string | 
| static class | Converter.ToUntypedAtomicConverterConverts any value to untyped atomic | 
| static class | Converter.TwoPhaseConverterConverter that operates in two phases, via an intermediate type | 
| static class | Converter.UpCastingConverterConverter that does nothing except change the type annotation of the value. | 
| Constructor Summary | |
|---|---|
| protected  | Converter() | 
| protected  | Converter(ConversionRules rules)Construct a converter with a given set of conversion rules. | 
| Method Summary | |
|---|---|
| abstract  ConversionResult | convert(AtomicValue input)Convert an atomic value from the source type to the target type | 
| static AtomicValue | convert(AtomicValue value,
        AtomicType targetType,
        ConversionRules rules)Convenience method to convert a given value to a given type. | 
|  ConversionRules | getConversionRules()Get the conversion rules to be used by this Converter | 
| static Converter | getConverter(AtomicType sourceType,
             AtomicType targetType,
             ConversionRules rules)Get a converter that handles conversion from one primitive type to another. | 
|  NamespaceResolver | getNamespaceResolver()Get the namespace resolver if one has been supplied | 
|  boolean | isAlwaysSuccessful()Ask if this converter will always succeed | 
|  boolean | isXPath30Conversion()Ask if this converter implements a conversion that requires XPath 3.0 (or XQuery 3.0 etc) to be enabled | 
|  void | setConversionRules(ConversionRules rules)Set the conversion rules to be used by this Converter | 
|  void | setNamespaceResolver(NamespaceResolver resolver)Provide a namespace resolver, needed for conversion to namespace-sensitive types such as QName and NOTATION. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final StringConverter.IdentityConverter IDENTITY_CONVERTER
public static final Converter.ToUntypedAtomicConverter TO_UNTYPED_ATOMIC
public static final Converter.ToStringConverter TO_STRING
public static final Converter.NumericToFloat NUMERIC_TO_FLOAT
public static final Converter.BooleanToFloat BOOLEAN_TO_FLOAT
public static final Converter.NumericToDouble NUMERIC_TO_DOUBLE
public static final Converter.BooleanToDouble BOOLEAN_TO_DOUBLE
public static final Converter.DoubleToDecimal DOUBLE_TO_DECIMAL
public static final Converter.FloatToDecimal FLOAT_TO_DECIMAL
public static final Converter.IntegerToDecimal INTEGER_TO_DECIMAL
public static final Converter.NumericToDecimal NUMERIC_TO_DECIMAL
public static final Converter.BooleanToDecimal BOOLEAN_TO_DECIMAL
public static final Converter.DoubleToInteger DOUBLE_TO_INTEGER
public static final Converter.FloatToInteger FLOAT_TO_INTEGER
public static final Converter.DecimalToInteger DECIMAL_TO_INTEGER
public static final Converter.NumericToInteger NUMERIC_TO_INTEGER
public static final Converter.BooleanToInteger BOOLEAN_TO_INTEGER
public static final Converter.DurationToDayTimeDuration DURATION_TO_DAY_TIME_DURATION
public static final Converter.DurationToYearMonthDuration DURATION_TO_YEAR_MONTH_DURATION
public static final Converter.DateToDateTime DATE_TO_DATE_TIME
public static final Converter.DateTimeToDate DATE_TIME_TO_DATE
public static final Converter.DateTimeToGMonth DATE_TIME_TO_G_MONTH
public static final Converter.DateTimeToGYearMonth DATE_TIME_TO_G_YEAR_MONTH
public static final Converter.DateTimeToGYear DATE_TIME_TO_G_YEAR
public static final Converter.DateTimeToGMonthDay DATE_TIME_TO_G_MONTH_DAY
public static final Converter.DateTimeToGDay DATE_TIME_TO_G_DAY
public static final Converter.DateTimeToTime DATE_TIME_TO_TIME
public static final Converter.NumericToBoolean NUMERIC_TO_BOOLEAN
public static final Converter.Base64BinaryToHexBinary BASE64_BINARY_TO_HEX_BINARY
public static final Converter.HexBinaryToBase64Binary HEX_BINARY_TO_BASE64_BINARY
public static final Converter.NotationToQName NOTATION_TO_QNAME
public static final Converter.QNameToNotation QNAME_TO_NOTATION
| Constructor Detail | 
|---|
protected Converter()
protected Converter(ConversionRules rules)
rules - the conversion rules for the configuration| Method Detail | 
|---|
public static AtomicValue convert(AtomicValue value,
                                  AtomicType targetType,
                                  ConversionRules rules)
                           throws ValidationException
value - the value to be convertedtargetType - the type to which the value is to be convertedrules - the conversion rules for the configuration
ValidationException - if conversion fails
public static Converter getConverter(AtomicType sourceType,
                                     AtomicType targetType,
                                     ConversionRules rules)
This method is intended for internal use only. The approved way to get a converter is using the
 factory method ConversionRules.getConverter(net.sf.saxon.type.AtomicType, net.sf.saxon.type.AtomicType)}
sourceType - the fingerprint of the source primitive typetargetType - the fingerprint of the target primitive typerules - the conversion rules to be applied
public abstract ConversionResult convert(AtomicValue input)
input - the atomic value to be converted, which the caller guarantees to be of the appropriate
              type for the converter
AtomicValue, if conversion succeeds, or a ValidationFailure
         object describing the reasons for failure if conversion is not possible. Note that the ValidationFailure
         object is not (and does not contain) an exception, because it does not necessarily result in an error being
         thrown, and creating exceptions on non-failure paths is expensive.public final void setConversionRules(ConversionRules rules)
rules - the conversion rulespublic final ConversionRules getConversionRules()
public boolean isXPath30Conversion()
public boolean isAlwaysSuccessful()
public void setNamespaceResolver(NamespaceResolver resolver)
resolver - the namespace resolver to be usedpublic NamespaceResolver getNamespaceResolver()
| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||