Debian Codegraph @

net/sf/saxon/type/SimpleType.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.lib.ConversionRules;
11 import net.sf.saxon.om.AtomicSequence;
12 import net.sf.saxon.om.NamespaceResolver;
13
14 /**
15 * This interface represents a simple type, which may be a built-in simple type, or
16 * a user-defined simple type.
17 */
18
19 public interface SimpleType extends SchemaType {
20
21 /**
22 * Test whether this Simple Type is an atomic type
23 *
24 * @return true if this is an atomic type
25 */
26
27 boolean isAtomicType();
28
29 /**
30 * Test whether this Simple Type is a list type
31 *
32 * @return true if this is a list type
33 */
34 boolean isListType();
35
36 /**
37 * Test whether this Simple Type is a union type
38 *
39 * @return true if this is a union type
40 */
41
42 boolean isUnionType();
43
44 /**
45 * Return true if this is an external object type, that is, a Saxon-defined type for external
46 * Java or .NET objects
47 *
48 * @return true if this is an external type
49 */
50
51 boolean isExternalType();
52
53 /**
54 * Determine whether this is a built-in type or a user-defined type
55 *
56 * @return true if this is a built-in type
57 */
58
59 boolean isBuiltInType();
60
61 /**
62 * Get the built-in type from which this type is derived by restriction
63 *
64 * @return the built-in type from which this type is derived by restriction. This will not necessarily
65 * be a primitive type.
66 */
67
68 /*@Nullable*/ SchemaType getBuiltInBaseType();
69
70 /**
71 * Get the typed value corresponding to a given string value, assuming it is
72 * valid against this type
73 *
74 * @param value the string value
75 * @param resolver a namespace resolver used to resolve any namespace prefixes appearing
76 * in the content of values. Can supply null, in which case any namespace-sensitive content
77 * will be rejected.
78 * @param rules the conversion rules from the configuration
79 * @return an iterator over the atomic sequence comprising the typed value. The objects
80 * returned by this SequenceIterator will all be of type {@link net.sf.saxon.value.AtomicValue},
81 * The next() method on the iterator throws no checked exceptions, although it is not actually
82 * declared as an UnfailingIterator.
83 * @throws ValidationException if the supplied value is not in the lexical space of the data type
84 */
85
86 AtomicSequence getTypedValue(CharSequence value, /*@Nullable*/ NamespaceResolver resolver, ConversionRules rules)
87 throws ValidationException;
88
89 /**
90 * Check whether a given input string is valid according to this SimpleType
91 *
92 * @param value the input string to be checked
93 * @param nsResolver a namespace resolver used to resolve namespace prefixes if the type
94 * is namespace sensitive. The value supplied may be null; in this case any namespace-sensitive
95 * content will throw an UnsupportedOperationException.
96 * @param rules the conversion rules from the configuration
97 * @return null if validation succeeds; or return a ValidationFailure describing the validation failure
98 * if validation fails. Note that the exception is returned rather than being thrown.
99 * @throws UnsupportedOperationException if the type is namespace-sensitive and no namespace
100 * resolver is supplied
101 */
102
103 /*@Nullable*/
104 ValidationFailure validateContent(
105 /*@NotNull*/ CharSequence value, /*@Nullable*/ NamespaceResolver nsResolver, /*@NotNull*/ ConversionRules rules);
106
107 /**
108 * Test whether this type is namespace sensitive, that is, if a namespace context is needed
109 * to translate between the lexical space and the value space. This is true for types derived
110 * from, or containing, QNames and NOTATIONs
111 *
112 * @return true if the type is namespace-sensitive, or if the namespace-sensitivity cannot be determined
113 * because there are missing schema components. (However, for xs:anyAtomicType, the result returned is
114 * false, even though the type allows xs:QName instances.)
115 */
116
117 boolean isNamespaceSensitive();
118
119 /**
120 * Determine how values of this simple type are whitespace-normalized.
121 *
122 * @return one of {@link net.sf.saxon.value.Whitespace#PRESERVE}, {@link net.sf.saxon.value.Whitespace#COLLAPSE},
123 * {@link net.sf.saxon.value.Whitespace#REPLACE}.
124 */
125
126 public int getWhitespaceAction();
127
128 /**
129 * Apply any pre-lexical facets, other than whitespace. At the moment the only such
130 * facet is saxon:preprocess
131 *
132 * @param input the value to be preprocessed
133 * @return the value after preprocessing
134 * @throws ValidationException if preprocessing detects that the value is invalid
135 */
136
137 public CharSequence preprocess(CharSequence input) throws ValidationException;
138
139 /**
140 * Reverse any pre-lexical facets, other than whitespace. At the moment the only such
141 * facet is saxon:preprocess. This is called when converting a value of this type to
142 * a string
143 *
144 * @param input the value to be postprocessed: this is the "ordinary" result of converting
145 * the value to a string
146 * @return the value after postprocessing
147 * @throws ValidationException if postprocessing detects that the value is invalid
148 */
149
150 public CharSequence postprocess(CharSequence input) throws ValidationException;
151
152 }
153