com.saxonica.schema
Class UserAtomicType

java.lang.Object
  extended bycom.saxonica.schema.SchemaStructure
      extended bycom.saxonica.schema.SchemaTypeImpl
          extended bycom.saxonica.schema.UserSimpleType
              extended bycom.saxonica.schema.UserAtomicType
All Implemented Interfaces:
AtomicType, ItemType, SchemaComponent, SchemaType, java.io.Serializable, SimpleType, javax.xml.transform.SourceLocator

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.SchemaTypeImpl
finalProhibitions
 
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()
           
 
Method Summary
 AtomicType getAtomizedItemType()
          Get the item type of the atomic values that will be produced when an item of this type is atomized
 AtomicType getCommonAtomicType()
          Get the most specific possible atomic type that all items in this SimpleType belong to
 ItemType getPrimitiveItemType()
          Get the primitive type from which this type is derived.
 int getPrimitiveType()
          Get the primitive type from which this type is derived.
 ItemType getSuperType(TypeHierarchy th)
          Get the type from which this item type is derived by restriction.
 SequenceIterator getTypedValue(java.lang.CharSequence value, NamespaceResolver resolver, NameChecker nameChecker)
          Get the typed value corresponding to a given string value, assuming it is valid against this type
 int hashCode()
          Returns a hash code value for the object.
 boolean isAtomicType()
          Test whether this Simple Type is an atomic type
 boolean isBuiltIn()
          Test whether this is a built-in type
 AtomicValue makeDerivedValue(AtomicValue primValue, java.lang.CharSequence lexicalValue, boolean validate)
          Factory method to create values of a derived atomic type.
 boolean matchesItem(Item item, XPathContext context, boolean allowURIPromotion)
          Test whether a given item conforms to this type
 void setIsBuiltIn(boolean yesOrNo)
          Mark this as a built-in type
 java.lang.String toString()
          Produce string representation for use in diagnostic output
 java.lang.String toString(NamePool pool)
          Display the type descriptor for diagnostics
 boolean validate(PreparedSchema schema)
          Checks the validity of this SimpleType definition.
 ValidationException validateContent(java.lang.CharSequence value, NamespaceResolver nsResolver, NameChecker checker)
          Check whether a given input string is valid according to this SimpleType
 
Methods inherited from class com.saxonica.schema.UserSimpleType
analyzeContentExpression, applyWhitespaceNormalization, atomize, getBuiltInBaseType, getFacet, getFacetCollection, getFacets, getFacets, getTypedValue, getWhitespaceAction, isListType, isNamespaceSensitive, isSimpleType, isTypeDerivationOK, isTypeDerivationOK, isUnionType, setFacetCollection
 
Methods inherited from class com.saxonica.schema.SchemaTypeImpl
allowsDerivation, containingDeclarationIsElement, getBaseType, getBaseTypeFingerprint, getBaseTypeReference, getBlock, getContainingDeclarationName, getDerivationMethod, getDescription, getDisplayName, getFingerprint, getLocalName, getNameCode, getNamePool, isComplexType, isSameType, setBaseTypeReference, setContainingDeclaration, setDerivationMethod, setDerivationMethodName, setFinalProhibitions, setLocalName, setNameCode, setNamePool
 
Methods inherited from class com.saxonica.schema.SchemaStructure
getColumnNumber, getFixupStatus, getLineNumber, getPublicId, getSchema, getSystemId, getValidationStatus, lookForCycles, setFixupStatus, setLineNumber, setLocator, setSchema, 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, isListType, isNamespaceSensitive, isUnionType
 
Methods inherited from interface net.sf.saxon.type.SchemaType
allowsDerivation, analyzeContentExpression, atomize, getBaseType, getBlock, getDerivationMethod, getDescription, getDisplayName, getFingerprint, getNameCode, getTypedValue, isComplexType, isSameType, isSimpleType, isTypeDerivationOK
 
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getValidationStatus
 

Constructor Detail

UserAtomicType

public UserAtomicType()
Method Detail

setIsBuiltIn

public void setIsBuiltIn(boolean yesOrNo)
Mark this as a built-in type


isBuiltIn

public boolean isBuiltIn()
Test whether this is a built-in type


isAtomicType

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

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

getCommonAtomicType

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

Specified by:
getCommonAtomicType in interface SimpleType
Returns:
the lowest common supertype of all member types

validate

public boolean validate(PreparedSchema schema)
                 throws SchemaException,
                        ValidationException
Checks the validity of this SimpleType definition.

Overrides:
validate in class UserSimpleType
Parameters:
schema - a Schema used for error reporting
Throws:
SchemaException - when this SimpleType definition is invalid.
ValidationException

matchesItem

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

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

validateContent

public ValidationException validateContent(java.lang.CharSequence value,
                                           NamespaceResolver nsResolver,
                                           NameChecker checker)
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.
checker -
Returns:
null if validation succeeds; return a ValidationException describing the validation failure if validation fails.
Throws:
java.lang.UnsupportedOperationException - if the type is namespace-sensitive and no namespace resolver is supplied

getTypedValue

public SequenceIterator getTypedValue(java.lang.CharSequence value,
                                      NamespaceResolver resolver,
                                      NameChecker nameChecker)
                               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 -
nameChecker -
Returns:
an iterator over the atomic sequence comprising the typed value
Throws:
ValidationException

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 xdt:anyAtomicType, whose supertype is item() (rather than xs:anySimpleType).

Specified by:
getSuperType in interface ItemType
Parameters:
th -
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

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

toString

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


toString

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

Specified by:
toString in interface ItemType

hashCode

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


makeDerivedValue

public AtomicValue makeDerivedValue(AtomicValue primValue,
                                    java.lang.CharSequence lexicalValue,
                                    boolean validate)
Factory method to create values of a derived atomic type. This method is not used to create values of a built-in type, even one that is not primitive.

Specified by:
makeDerivedValue 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)
validate - true if the value is to be validated against the facets of the derived type; false if the caller knows that the value is already valid.
Returns:
the derived atomic value if validation succeeds. Otherwise, an ErrorValue that encapsulates the exception that occurred. It is the caller's responsibility to check for this.