net.sf.saxon.type
Interface ConversionResult

All Known Implementing Classes:
AnyURIValue, AtomicValue, Base64BinaryValue, BigIntegerValue, BooleanValue, CalendarValue, DateTimeValue, DateValue, DayTimeDurationValue, DecimalValue, DoubleValue, DurationValue, FloatValue, GDateValue, GDayValue, GMonthDayValue, GMonthValue, GYearMonthValue, GYearValue, HexBinaryValue, Int64Value, IntegerValue, NotationValue, NumericValue, ObjectValue, PrecisionDecimalValue, QNameValue, QualifiedNameValue, StringValue, TimeValue, UntypedAtomicValue, ValidationFailure, YearMonthDurationValue

public interface ConversionResult

This is a marker interface used as the result methods that convert or cast values from one type to another. It is implemented by AtomicValue, which indicates a successful conversion, and by ValidationFailure, which indicates an unsuccessful conversion. An unsuccessful conversion does not throw an exception because exceptions are expensive and should not be used on success paths. For example when validating a union, conversion failures are to be expected.


Method Summary
 AtomicValue asAtomic()
          Calling this method on a ConversionResult returns the AtomicValue that results from the conversion if the conversion was successful, and throws a ValidationException explaining the conversion error otherwise.
 

Method Detail

asAtomic

AtomicValue asAtomic()
                     throws ValidationException
Calling this method on a ConversionResult returns the AtomicValue that results from the conversion if the conversion was successful, and throws a ValidationException explaining the conversion error otherwise.

Use this method if you are calling a conversion method that returns a ConversionResult, and if you want to throw an exception if the conversion fails.

Returns:
the atomic value that results from the conversion if the conversion was successful
Throws:
ValidationException - if the conversion was not successful


Copyright (c) 2004-2010 Saxonica Limited. All rights reserved.