com.saxonica.schema
Class UserAtomicType

java.lang.Object
  extended by com.saxonica.schema.SchemaStructure
      extended by com.saxonica.schema.UserDefinedType
          extended by com.saxonica.schema.UserSimpleType
              extended by com.saxonica.schema.UserAtomicType
All Implemented Interfaces:
SerializableSchemaComponent, UserSchemaComponent, Serializable, SourceLocator, AtomicType, ItemType, PlainType, SchemaComponent, SchemaType, SimpleType

public class UserAtomicType
extends UserSimpleType
implements AtomicType

An object belonging to this class represents an atomic type: either a built-in atomic type, or a user-defined atomic type. There is at most one AtomicType object for each distinct type in the schema (so equality can safely be tested using the == operator).

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.saxonica.schema.UserDefinedType
extendedTypes, finalProhibitions
 
Fields inherited from interface net.sf.saxon.type.SimpleType
VARIETY_ATOMIC, VARIETY_LIST, VARIETY_UNION, VARIETY_UNSPECIFIED_SIMPLE
 
Fields inherited from interface net.sf.saxon.type.SchemaType
DERIVATION_EXTENSION, DERIVATION_LIST, DERIVATION_RESTRICTION, DERIVATION_UNION, DERIVE_BY_SUBSTITUTION
 
Fields inherited from interface net.sf.saxon.type.SchemaComponent
FIXED_UP, INCOMPLETE, INVALID, UNVALIDATED, VALIDATED, VALIDATING
 
Constructor Summary
UserAtomicType(EnterpriseConfiguration config)
          Create a UserAtomicType
 
Method Summary
 AtomicType getAtomizedItemType()
          Get the item type of the atomic values that will be produced when an item of this type is atomized
 double getDefaultPriority()
          Determine the default priority of this item type when used on its own as a Pattern
 Set<PlainType> getPlainMemberTypes()
          Get the set of atomic types that are subsumed by this type
 ItemType getPrimitiveItemType()
          Get the primitive type from which this type is derived.
 int getPrimitiveType()
          Get the primitive type from which this type is derived.
 String getSharedInstance(String value)
          Get an instance of the facet value that is stored in the schema rather than the instance
 ItemType getSuperType(TypeHierarchy th)
          Get the type from which this item type is derived by restriction.
 SequenceIterator<AtomicValue> getTypedValue(CharSequence value, NamespaceResolver resolver, ConversionRules rules)
          Get the typed value corresponding to a given string value, assuming it is valid against this type
 StructuredQName getTypeName()
          Get the name of this type as a StructuredQName, unless the type is anonymous, in which case return null
 int hashCode()
          Returns a hash code value for the object.
 boolean isAbstract()
          Determine whether the type is abstract, that is, whether it cannot have instances that are not also instances of some concrete subtype
 boolean isAtomicType()
          Test whether this Simple Type is an atomic type
 boolean isAtomizable()
          Ask whether values of this type are atomizable
 boolean isBuiltInType()
          Determine whether this is a built-in type or a user-defined type
 boolean isIdRefType()
          Ask whether this type is an IDREF or IDREFS type.
 boolean isIdType()
          Ask whether this type is an ID type.
 boolean isNamespaceSensitive()
          Test whether this simple type is namespace-sensitive, that is, whether it is derived from xs:QName or xs:NOTATION
 boolean isOrdered()
          Determine whether the atomic type is ordered, that is, whether less-than and greater-than comparisons are permitted
 boolean isPlainType()
          Ask whether this is a plain type (a type whose instances are always atomic values)
 boolean isPrimitiveType()
          Determine whether the atomic type is a primitive type.
 boolean matches(Item item, XPathContext context)
          Test whether a given item conforms to this type
 boolean matchesItem(Item item, boolean allowURIPromotion, Configuration config)
          Test whether a given item conforms to this type
 void serializeVariety(SchemaModelSerializer serializer)
          Serialize the schema component
 String toString()
          Produce string representation for use in diagnostic output
 String toString(NamePool pool)
          Display the type descriptor for diagnostics
 ValidationFailure validate(AtomicValue primValue, CharSequence lexicalValue, ConversionRules rules)
          Validate that a primitive atomic value is a valid instance of a type derived from the same primitive type.
 boolean validate(SchemaCompiler compiler)
          Checks the validity of this SimpleType definition.
 ValidationFailure validateContent(CharSequence value, NamespaceResolver nsResolver, ConversionRules rules)
          Check whether a given input string is valid according to this SimpleType
 void visitNamedSchemaComponents(SchemaComponentVisitor visitor)
          Visit all the schema components used in this ItemType definition
 
Methods inherited from class com.saxonica.schema.UserSimpleType
addFacet, addInheritedFacets, analyzeContentExpression, applyWhitespaceNormalization, atomize, checkAgainstFacets, checkTypeDerivationIsOK, convertFacetValues, elaborate, getBuiltInBaseType, getExtendedFacetList, getFacet, getFacets, getLocalFacetList, getTypedValue, getWhitespaceAction, isListType, isSimpleType, isTypeDerivationOK, isUnionType, mergeEnumerationFacets, postprocess, preprocess, serialize, setFacetList
 
Methods inherited from class com.saxonica.schema.UserDefinedType
allowsDerivation, containingDeclarationIsElement, getBaseType, getBaseTypeFingerprint, getBaseTypeReference, getBlock, getContainingDeclarationName, getDerivationMethod, getDescription, getDisplayName, getFingerprint, getLocalName, getName, getNameCode, getNamePool, getTargetNamespace, hasRegisteredExtension, isAnonymousType, isComplexType, isExternalType, isSameType, iterateExtensionTypes, registerExtensionType, setBaseTypeReference, setContainingDeclaration, setDerivationMethod, setDerivationMethodName, setExtendedTypes, setFinalProhibitions, setNameCode
 
Methods inherited from class com.saxonica.schema.SchemaStructure
fixup, getColumnNumber, getConfiguration, getFixupStatus, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, lookForCycles, setConfiguration, setFixupStatus, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.type.SimpleType
getBuiltInBaseType, getWhitespaceAction, isExternalType, isListType, isUnionType, postprocess, preprocess
 
Methods inherited from interface net.sf.saxon.type.SchemaType
allowsDerivation, analyzeContentExpression, atomize, checkTypeDerivationIsOK, getBaseType, getBlock, getDerivationMethod, getDescription, getDisplayName, getFingerprint, getName, getNameCode, getSystemId, getTargetNamespace, getTypedValue, isAnonymousType, isComplexType, isSameType, isSimpleType
 
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getRedefinitionLevel, getValidationStatus
 
Methods inherited from interface net.sf.saxon.type.PlainType
isExternalType
 
Methods inherited from interface com.saxonica.schema.UserSchemaComponent
fixup, lookForCycles
 

Constructor Detail

UserAtomicType

public UserAtomicType(EnterpriseConfiguration config)
Create a UserAtomicType

Parameters:
config - the Saxon configuration
Method Detail

isAtomicType

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

Specified by:
isAtomicType in interface ItemType
Specified by:
isAtomicType in interface SchemaType
Specified by:
isAtomicType in interface SimpleType
Overrides:
isAtomicType in class UserSimpleType
Returns:
true, this is an atomic type

isPlainType

public boolean isPlainType()
Ask whether this is a plain type (a type whose instances are always atomic values)

Specified by:
isPlainType in interface ItemType
Returns:
true

isIdType

public boolean isIdType()
Ask whether this type is an ID type. This is defined to be any simple type who typed value may contain atomic values of type xs:ID: that is, it includes types derived from ID by restriction, list, or union. Note that for a node to be treated as an ID, its typed value must be a *single* atomic value of type ID; the type of the node, however, can still allow a list.

Specified by:
isIdType in interface SchemaType
Overrides:
isIdType in class UserSimpleType
Returns:
true if this type is an ID type

isIdRefType

public boolean isIdRefType()
Ask whether this type is an IDREF or IDREFS type. This is defined to be any simple type who typed value may contain atomic values of type xs:IDREF: that is, it includes types derived from IDREF or IDREFS by restriction, list, or union

Specified by:
isIdRefType in interface SchemaType
Overrides:
isIdRefType in class UserSimpleType
Returns:
true if this type is an IDREF type

isBuiltInType

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

Specified by:
isBuiltInType in interface AtomicType
Specified by:
isBuiltInType in interface SimpleType
Returns:
true if this is a built-in type

getTypeName

public StructuredQName getTypeName()
Get the name of this type as a StructuredQName, unless the type is anonymous, in which case return null

Specified by:
getTypeName in interface AtomicType
Returns:
the name of the atomic type, or null if the type is anonymous.

isPrimitiveType

public boolean isPrimitiveType()
Determine whether the atomic type is a primitive type. The primitive types are the 19 primitive types of XML Schema, plus xs:integer, xs:dayTimeDuration and xs:yearMonthDuration; xs:untypedAtomic; and all supertypes of these (xs:anyAtomicType, xs:numeric, ...)

Specified by:
isPrimitiveType in interface AtomicType
Returns:
true if the type is considered primitive under the above rules

isOrdered

public boolean isOrdered()
Determine whether the atomic type is ordered, that is, whether less-than and greater-than comparisons are permitted

Specified by:
isOrdered in interface AtomicType
Returns:
true if ordering operations are permitted

isAbstract

public boolean isAbstract()
Determine whether the type is abstract, that is, whether it cannot have instances that are not also instances of some concrete subtype

Specified by:
isAbstract in interface AtomicType
Returns:
false (always)

validate

public boolean validate(SchemaCompiler compiler)
                 throws SchemaException
Checks the validity of this SimpleType definition.

Specified by:
validate in interface UserSchemaComponent
Overrides:
validate in class UserSimpleType
Parameters:
compiler - used for error reporting
Returns:
true when this Schema definition is valid, otherwise false.
Throws:
SchemaException - when this SimpleType definition is invalid.

matches

public boolean matches(Item item,
                       XPathContext context)
Test whether a given item conforms to this type

Specified by:
matches in interface ItemType
Parameters:
item - The item to be tested
context - the XPath dynamic evaluation context
Returns:
true if the item is an instance of this type; false otherwise

matchesItem

public boolean matchesItem(Item item,
                           boolean allowURIPromotion,
                           Configuration config)
Test whether a given item conforms to this type

Specified by:
matchesItem in interface ItemType
Parameters:
item - The item to be tested
allowURIPromotion - true if URIs can be promoted to strings
config - the Saxon configuration
Returns:
true if the item is an instance of this type; false otherwise

validateContent

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

Specified by:
validateContent in interface 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.
rules - the conversion rules for this Configuration
Returns:
null if validation succeeds; return a ValidationFailure describing the validation failure if validation fails.
Throws:
UnsupportedOperationException - if the type is namespace-sensitive and no namespace resolver is supplied

getTypedValue

public SequenceIterator<AtomicValue> getTypedValue(CharSequence value,
                                                   NamespaceResolver resolver,
                                                   ConversionRules rules)
                                            throws ValidationException
Get the typed value corresponding to a given string value, assuming it is valid against this type

Specified by:
getTypedValue in interface SimpleType
Parameters:
value - the string value
resolver - the namespace resolver
rules - the conversion rules for the Saxon configuration
Returns:
an iterator over the atomic sequence comprising the typed value
Throws:
ValidationException - if the supplied value is not in the lexical space of the data type

getSuperType

public ItemType getSuperType(TypeHierarchy th)
Get the type from which this item type is derived by restriction. This is the supertype in the XPath type heirarchy, as distinct from the Schema base type: this means that the supertype of xs:boolean is xs:anyAtomicType, whose supertype is item() (rather than xs:anySimpleType).

Specified by:
getSuperType in interface ItemType
Parameters:
th - the type hierarchy cache
Returns:
the supertype, or null if this type is item()

getPrimitiveItemType

public ItemType getPrimitiveItemType()
Get the primitive type from which this type is derived. For the definition of primitive types, see Type.isPrimitiveType(int)

Specified by:
getPrimitiveItemType in interface ItemType
Returns:
the type code of the primitive type

getPrimitiveType

public int getPrimitiveType()
Get the primitive type from which this type is derived. For the definition of primitive types, see Type.isPrimitiveType(int)

Specified by:
getPrimitiveType in interface ItemType
Returns:
the type code of the primitive type

isNamespaceSensitive

public boolean isNamespaceSensitive()
Test whether this simple type is namespace-sensitive, that is, whether it is derived from xs:QName or xs:NOTATION

Specified by:
isNamespaceSensitive in interface SimpleType
Returns:
true if this type is derived from xs:QName or xs:NOTATION

getAtomizedItemType

public AtomicType getAtomizedItemType()
Get the item type of the atomic values that will be produced when an item of this type is atomized

Specified by:
getAtomizedItemType in interface ItemType
Returns:
the best available item type of the atomic values that will be produced when an item of this type is atomized

isAtomizable

public boolean isAtomizable()
Ask whether values of this type are atomizable

Specified by:
isAtomizable in interface ItemType
Returns:
true unless it is known that these items will be elements with element-only content, in which case return false

getSharedInstance

public String getSharedInstance(String value)
Get an instance of the facet value that is stored in the schema rather than the instance

Parameters:
value - the value required
Returns:
a string which is equal to the value required, but which if possible is the instance held in the compiled schema, reducing storage requirements in instances.

toString

public String toString()
Produce string representation for use in diagnostic output

Overrides:
toString in class Object

toString

public String toString(NamePool pool)
Display the type descriptor for diagnostics

Specified by:
toString in interface ItemType
Parameters:
pool - the name pool
Returns:
a string representation of the type, in notation resembling but not necessarily identical to XPath syntax

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Object

validate

public ValidationFailure validate(AtomicValue primValue,
                                  CharSequence lexicalValue,
                                  ConversionRules rules)
Validate that a primitive atomic value is a valid instance of a type derived from the same primitive type.

Specified by:
validate in interface AtomicType
Parameters:
primValue - the value in the value space of the primitive type.
lexicalValue - the value in the lexical space. If null, the string value of primValue is used. This value is checked against the pattern facet (if any)
rules - the conversion rules used for this configuration
Returns:
null if the value is valid; otherwise, a ValidationFailure object indicating the nature of the error.
Throws:
UnsupportedOperationException - in the case of an external object type

serializeVariety

public void serializeVariety(SchemaModelSerializer serializer)
                      throws XPathException
Serialize the schema component

Specified by:
serializeVariety in class UserSimpleType
Throws:
XPathException

visitNamedSchemaComponents

public void visitNamedSchemaComponents(SchemaComponentVisitor visitor)
                                throws XPathException
Visit all the schema components used in this ItemType definition

Specified by:
visitNamedSchemaComponents in interface ItemType
Parameters:
visitor - the visitor class to be called when each component is visited
Throws:
XPathException - if an error occurs

getPlainMemberTypes

public Set<PlainType> getPlainMemberTypes()
Get the set of atomic types that are subsumed by this type

Specified by:
getPlainMemberTypes in interface PlainType
Returns:
for an atomic type, the type itself; for a union type, the set of atomic types in its transitive membership

getDefaultPriority

public double getDefaultPriority()
Determine the default priority of this item type when used on its own as a Pattern

Specified by:
getDefaultPriority in interface ItemType
Returns:
the default priority


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