Class Converter

    • Constructor Detail

      • Converter

        protected Converter()
      • Converter

        protected Converter​(ConversionRules rules)
        Construct a converter with a given set of conversion rules. For use in constructing subclasses
        rules - the conversion rules for the configuration
    • Method Detail

      • convert

        public static AtomicValue convert​(AtomicValue value,
                                          AtomicType targetType,
                                          ConversionRules rules)
                                   throws ValidationException
        Convenience method to convert a given value to a given type. Note: it is more efficient to obtain a converter in advance and to reuse it for multiple conversions
        value - the value to be converted
        targetType - the type to which the value is to be converted
        rules - the conversion rules for the configuration
        the converted value
        ValidationException - if conversion fails
      • convert

        public abstract ConversionResult convert​(AtomicValue input)
        Convert an atomic value from the source type to the target type
        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.
        the result of the conversion, as an 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.
      • setConversionRules

        public final void setConversionRules​(ConversionRules rules)
        Set the conversion rules to be used by this Converter
        rules - the conversion rules
      • getConversionRules

        public final ConversionRules getConversionRules()
        Get the conversion rules to be used by this Converter
        the conversion rules
      • isAlwaysSuccessful

        public boolean isAlwaysSuccessful()
        Ask if this converter will always succeed
        true if this Converter will never return a ValidationFailure
      • isPromoter

        public boolean isPromoter()
        Ask if this converter implements promotion rules
        true if this Converter handles type promotion in the coercion rules
      • setNamespaceResolver

        public Converter setNamespaceResolver​(NamespaceResolver resolver)
        Provide a namespace resolver, needed for conversion to namespace-sensitive types such as QName and NOTATION. The resolver is ignored if the target type is not namespace-sensitive
        resolver - the namespace resolver to be used
        a new Converter customised with the supplied namespace context. The original Converter is unchanged (see bug 2754)
      • getNamespaceResolver

        public NamespaceResolver getNamespaceResolver()
        Get the namespace resolver if one has been supplied
        the namespace resolver, or null if none has been supplied