public abstract class Converter
extends java.lang.Object
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
Converter.BooleanToDouble.INSTANCE
. In other cases the converter is parameterized 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
Modifier and Type | Class and Description |
---|---|
static class |
Converter.Base64BinaryToHexBinary
Converts base64 to hexBinary
|
static class |
Converter.BooleanToDecimal
Converts a boolean to a decimal
|
static class |
Converter.BooleanToDouble
Converts a boolean to a double
|
static class |
Converter.BooleanToFloat
Converts a boolean to an xs:float
|
static class |
Converter.BooleanToInteger
Converts a boolean to an integer
|
static class |
Converter.DateTimeToDate
Converts a dateTime to a date
|
static class |
Converter.DateTimeToGDay
Converts a dateTime to a gDay
|
static class |
Converter.DateTimeToGMonth
Converts a dateTime to a gMonth
|
static class |
Converter.DateTimeToGMonthDay
Converts a dateTime to a gMonthDay
|
static class |
Converter.DateTimeToGYear
Converts a dateTime to a gYear
|
static class |
Converter.DateTimeToGYearMonth
Converts a dateTime to a gYearMonth
|
static class |
Converter.DateTimeToTime
Converts a dateTime to a time
|
static class |
Converter.DateToDateTime
Converts a date to a dateTime
|
static class |
Converter.DecimalToInteger
Converts a decimal to an integer.
|
static class |
Converter.DoubleToDecimal
Convers a double to a decimal
|
static class |
Converter.DoubleToInteger
Converts a double to an integer
|
static class |
Converter.DownCastingConverter
Converter that checks that a value belonging to a supertype is a valid
instance of a subtype, and returns an instance of the subtype
|
static class |
Converter.DurationToDayTimeDuration
Converts a duration to a dayTimeDuration
|
static class |
Converter.DurationToYearMonthDuration
Converts a duration to a yearMonthDuration
|
static class |
Converter.FloatToDecimal
Converts a float to a decimal
|
static class |
Converter.FloatToInteger
Converts a float to an integer
|
static class |
Converter.HexBinaryToBase64Binary
Converts hexBinary to base64Binary
|
static class |
Converter.IdentityConverter
Converter that does nothing - it returns the input unchanged
|
static class |
Converter.IntegerToDecimal
Converts an integer to a decimal
|
static class |
Converter.NotationToQName
Converts Notation to QName
|
static class |
Converter.NumericToBoolean
Converts a numeric value to a boolean
|
static class |
Converter.NumericToDecimal
Converts any numeric value to a decimal
|
static class |
Converter.NumericToDouble
Converts any numeric value to a double.
|
static class |
Converter.NumericToFloat
Converts any numeric value to xs:float
|
static class |
Converter.NumericToInteger
Converts any numeric value to an integer.
|
static class |
Converter.PromoterToDouble
Converter that implements the promotion rules to a required type of xs:double
|
static class |
Converter.PromoterToFloat
Converter that implements the promotion rules to a required type of xs:float
|
static class |
Converter.QNameToNotation
Converts QName to Notation
|
static class |
Converter.ToStringConverter
Converts any value to a string
|
static class |
Converter.ToUntypedAtomicConverter
Converts any value to untyped atomic
|
static class |
Converter.TwoPhaseConverter
Converter that operates in two phases, via an intermediate type
|
static class |
Converter.UnfailingConverter
Specialisation for converters that always succeed
|
static class |
Converter.UpCastingConverter
Converter that does nothing except change the type annotation of the value.
|
Modifier | Constructor and Description |
---|---|
protected |
Converter() |
protected |
Converter(ConversionRules rules)
Construct a converter with a given set of conversion rules.
|
Modifier and Type | Method and Description |
---|---|
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
|
NamespaceResolver |
getNamespaceResolver()
Get the namespace resolver if one has been supplied
|
boolean |
isAlwaysSuccessful()
Ask if this converter will always succeed
|
void |
setConversionRules(ConversionRules rules)
Set the conversion rules to be used by this Converter
|
Converter |
setNamespaceResolver(NamespaceResolver resolver)
Provide a namespace resolver, needed for conversion to namespace-sensitive types such as QName and NOTATION.
|
protected Converter()
protected Converter(ConversionRules rules)
rules
- the conversion rules for the configurationpublic 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 configurationValidationException
- if conversion failspublic 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. The results are undefined if the value is of the wrong type;
possible outcomes are (apparent) success, or a ClassCastException.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 isAlwaysSuccessful()
public Converter setNamespaceResolver(NamespaceResolver resolver)
resolver
- the namespace resolver to be usedpublic NamespaceResolver getNamespaceResolver()
Copyright (c) 2004-2020 Saxonica Limited. All rights reserved.