net.sf.saxon.type

Interface SimpleType

public interface SimpleType extends SchemaType

This interface represents a simple type, which may be a built-in simple type, or a user-defined simple type.
Field Summary
static intVARIETY_ATOMIC
static intVARIETY_LIST
static intVARIETY_UNION
static intVARIETY_UNSPECIFIED_SIMPLE
Method Summary
SchemaTypegetBuiltInBaseType()
Get the built-in type from which this type is derived by restriction
AtomicTypegetCommonAtomicType()
Get the most specific possible atomic type that all items in this SimpleType belong to
SequenceIteratorgetTypedValue(CharSequence value, NamespaceResolver resolver, NameChecker nameChecker)
Get the typed value corresponding to a given string value, assuming it is valid against this type
intgetWhitespaceAction(TypeHierarchy th)
Determine how values of this simple type are whitespace-normalized.
booleanisAtomicType()
Test whether this Simple Type is an atomic type
booleanisBuiltInType()
Determine whether this is a built-in type or a user-defined type
booleanisExternalType()
Return true if this is an external object type, that is, a Saxon-defined type for external Java or .NET objects
booleanisListType()
Test whether this Simple Type is a list type
booleanisNamespaceSensitive()
Test whether this type is namespace sensitive, that is, if a namespace context is needed to translate between the lexical space and the value space.
booleanisUnionType()
Test whether this Simple Type is a union type
CharSequencepostprocess(CharSequence input)
Reverse any pre-lexical facets, other than whitespace.
CharSequencepreprocess(CharSequence input)
Apply any pre-lexical facets, other than whitespace.
ValidationFailurevalidateContent(CharSequence value, NamespaceResolver nsResolver, NameChecker nameChecker)
Check whether a given input string is valid according to this SimpleType

Field Detail

VARIETY_ATOMIC

public static final int VARIETY_ATOMIC

VARIETY_LIST

public static final int VARIETY_LIST

VARIETY_UNION

public static final int VARIETY_UNION

VARIETY_UNSPECIFIED_SIMPLE

public static final int VARIETY_UNSPECIFIED_SIMPLE

Method Detail

getBuiltInBaseType

public SchemaType getBuiltInBaseType()
Get the built-in type from which this type is derived by restriction

Returns: the built-in type from which this type is derived by restriction. This will not necessarily be a primitive type.

getCommonAtomicType

public AtomicType getCommonAtomicType()
Get the most specific possible atomic type that all items in this SimpleType belong to

Returns: the lowest common supertype of all member types

getTypedValue

public SequenceIterator getTypedValue(CharSequence value, NamespaceResolver resolver, NameChecker nameChecker)
Get the typed value corresponding to a given string value, assuming it is valid against this type

Parameters: value the string value resolver a namespace resolver used to resolve any namespace prefixes appearing in the content of values. Can supply null, in which case any namespace-sensitive content will be rejected. nameChecker a NameChecker used in the case of types that are defined in terms of the XML NCName syntax: this is used to check conformance to XML 1.0 or XML 1.1 naming rules, as appropriate

Returns: an iterator over the atomic sequence comprising the typed value. The objects returned by this SequenceIterator will all be of type AtomicValue, The next() method on the iterator throws no checked exceptions, although it is not actually declared as an UnfailingIterator.

Throws: ValidationException if the supplied value is not in the lexical space of the data type

getWhitespaceAction

public int getWhitespaceAction(TypeHierarchy th)
Determine how values of this simple type are whitespace-normalized.

Parameters: th the type hierarchy cache. Not needed in the case of a built-in type

Returns: one of PRESERVE, COLLAPSE, REPLACE.

isAtomicType

public boolean isAtomicType()
Test whether this Simple Type is an atomic type

Returns: true if this is an atomic type

isBuiltInType

public boolean isBuiltInType()
Determine whether this is a built-in type or a user-defined type

Returns: true if this is a built-in type

isExternalType

public boolean isExternalType()
Return true if this is an external object type, that is, a Saxon-defined type for external Java or .NET objects

Returns: true if this is an external type

isListType

public boolean isListType()
Test whether this Simple Type is a list type

Returns: true if this is a list type

isNamespaceSensitive

public boolean isNamespaceSensitive()
Test whether this type is namespace sensitive, that is, if a namespace context is needed to translate between the lexical space and the value space. This is true for types derived from, or containing, QNames and NOTATIONs

Returns: true if the type is namespace-sensitive

isUnionType

public boolean isUnionType()
Test whether this Simple Type is a union type

Returns: true if this is a union type

postprocess

public CharSequence postprocess(CharSequence input)
Reverse any pre-lexical facets, other than whitespace. At the moment the only such facet is saxon:preprocess. This is called when converting a value of this type to a string

Parameters: input the value to be postprocessed: this is the "ordinary" result of converting the value to a string

Returns: the value after postprocessing

preprocess

public CharSequence preprocess(CharSequence input)
Apply any pre-lexical facets, other than whitespace. At the moment the only such facet is saxon:preprocess

Parameters: input the value to be preprocessed

Returns: the value after preprocessing

validateContent

public ValidationFailure validateContent(CharSequence value, NamespaceResolver nsResolver, NameChecker nameChecker)
Check whether a given input string is valid according to this SimpleType

Parameters: value the input string to be checked nsResolver a namespace resolver used to resolve namespace prefixes if the type is namespace sensitive. The value supplied may be null; in this case any namespace-sensitive content will throw an UnsupportedOperationException. nameChecker XML 1.0 or 1.1 name checker, needed when types such as xs:NCName are used

Returns: null if validation succeeds; return a ValidationFailure describing the validation failure if validation fails. Note that the exception is returned rather than being thrown.

Throws: UnsupportedOperationException if the type is namespace-sensitive and no namespace resolver is supplied