Debian Codegraph @

net/sf/saxon/type/ConversionResult.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.type;
9
10 import net.sf.saxon.value.AtomicValue;
11
12 /**
13 * This is a marker interface used as the result of methods that convert or cast values from one type
14 * to another. It is implemented by AtomicValue, which indicates a successful conversion, and by
15 * ValidationFailure, which indicates an unsuccessful conversion. An unsuccessful conversion does not
16 * throw an exception because exceptions are expensive and should not be used on success paths. For example
17 * when validating a union, conversion failures are to be expected.
18 */
19 public interface ConversionResult {
20
21 /**
22 * Calling this method on a ConversionResult returns the AtomicValue that results
23 * from the conversion if the conversion was successful, and throws a ValidationException
24 * explaining the conversion error otherwise.
25 * <p>Use this method if you are calling a conversion method that returns a ConversionResult,
26 * and if you want to throw an exception if the conversion fails.</p>
27 *
28 * @return the atomic value that results from the conversion if the conversion was successful
29 * @throws ValidationException if the conversion was not successful
30 */
31
32 AtomicValue asAtomic() throws ValidationException;
33
34 }
35