## net.sf.saxon.type
Class SchemaType

    java.lang.Object
      |
      +--net.sf.saxon.type.SchemaType

All Implemented Interfaces:
  java.io.Serializable, javax.xml.transform.SourceLocator, TypeInfo

Direct Known Subclasses:
  AnyType, SimpleType, Untyped

public abstract class SchemaType
extends java.lang.Object
implements TypeInfo, java.io.Serializable, javax.xml.transform.SourceLocator

This class represents a simple type or complex type as defined in XML Schema. In the non-schema-aware version of Saxon it is used to represent built-in schema types only. In the schema-aware version it is subclassed to represent user-defined types.

See Also:
  Serialized Form

Field Summary
`static int` `DERIVATION_EXTENSION`
`static int` `DERIVATION_LIST`
`static int` `DERIVATION_RESTRICTION`
`static int` `DERIVATION_UNION`
`static int` `DERIVE_BY_SUBSTITUTION`
`protected int` `finalProhibitions` Flags used to implement the "final" and "block" attributes
`static int` `INVALID`
`static int` `UNVALIDATED`
`static int` `VALIDATED`
`static int` `VALIDATING`
`protected int` `validationPhase` Flag used to check for cycles during validation

Constructor Summary
`SchemaType()` Default constructor.

Method Summary
`boolean` `allowsDerivation(int derivation)` Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" property
`void` `checkDerivation(SchemaType type, int block)` Check that this type is validly derived from a given type
`boolean` `containingDeclarationIsElement()` Determine whether the containing declaration is an element declaration or an attribute declaration
`SchemaType` `getBaseType()` Returns the base type that this type inherits from.
`int` `getBaseTypeFingerprint()` Get the fingerprint of the name of the base type of this type
`int` `getBlock()` Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such as `DERIVATION_LIST` and `DERIVATION_EXTENSION`
`int` `getColumnNumber()` Get the column number of the location where the type was defined.
`int` `getContainingDeclarationName()` Get the name of the containing element or attribute declaration, if any (and if known)
`int` `getDerivationMethod()` Gets the integer code of the derivation method used to derive this type from its parent.
`java.lang.String` `getDescription()` Get a description of this type for use in diagnostics.
`java.lang.String` `getDisplayName()` Get the display name of the type: that is, a lexical QName with an arbitrary prefix
`int` `getFingerprint()` Get the fingerprint of the name of this type
`int` `getLineNumber()` Get the line number of the location where the type was defined
`java.lang.String` `getLocalName()` Get the local name of this type
`NamePool` `getNamePool()` Get the NamePool in which the name of this type is defined
`java.lang.String` `getPublicId()` Get the public ID of the location where the type was defined.
`java.lang.String` `getSystemId()` Get the system ID (URI) of the schema document where the type was defined
`abstract SequenceIterator` `getTypedValue(NodeInfo node)` Get the typed value of a node that is annotated with this schema type
`java.lang.String` `getTypeName()` Get the local name of the type (a system-allocated name if anonymous).
`java.lang.String` `getTypeNamespace()` Get the namespace name of the type (a system-allocated name if anonymous).
`boolean` `isComplexType()` Test whether this SchemaType is a complex type
`boolean` `isDerivedFrom(java.lang.String typeNamespaceArg, java.lang.String typeNameArg, int derivationMethod)` This method returns true if there is a derivation between the reference type definition, that is the TypeInfo on which the method is being called, and the other type definition, that is the one passed as parameters.
`boolean` `isSameType(SchemaType other)` Test whether this is the same type as another type.
`abstract boolean` `isSimpleType()` Test whether this SchemaType is a simple type
`abstract int` `relationshipTo(SchemaType other)` Determine the relationship of this schema type to another schema type.
`void` `setBaseType(SchemaType baseType)` Sets the base type for this datatype.
`void` `setBaseTypeFingerprint(int fingerprint)` Set the fingerprint of the name of the base type of this type.
`void` `setContainingDeclaration(int fingerprint, boolean isElement)` Set the name of the containing declaration (for diagnostics)
`void` `setDerivationMethod(int method)` Sets the derivation method code (without validating it)
`void` `setDerivationMethodName(java.lang.String method)` Set the derivation method name.
`void` `setFinalProhibitions(int finalValue)` Sets the value of the 'final' property, indicating which types of derivation are not allowed.
`void` `setFingerprint(int fingerprint)` Set the fingerprint of the name of this type.
`void` `setLineNumber(int lineNumber)` Set the line number at which the type is defined within a schema document
`void` `setLocalName(java.lang.String localName)` Set the local name of this type
`void` `setLocator(javax.xml.transform.SourceLocator locator)` Set location information for diagnostics
`void` `setNamePool(NamePool pool)` Set the NamePool in which the type is defined.
`void` `setSystemId(java.lang.String systemId)` Set the system identifier (URI) of the schema document in which this type is defined

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### finalProhibitions

    protected int finalProhibitions

  Flags used to implement the "final" and "block" attributes

### DERIVATION_RESTRICTION

    public static final int DERIVATION_RESTRICTION

See Also:
  Constant Field Values

### DERIVATION_EXTENSION

    public static final int DERIVATION_EXTENSION

See Also:
  Constant Field Values

### DERIVATION_UNION

    public static final int DERIVATION_UNION

See Also:
  Constant Field Values

### DERIVATION_LIST

    public static final int DERIVATION_LIST

See Also:
  Constant Field Values

### DERIVE_BY_SUBSTITUTION

    public static final int DERIVE_BY_SUBSTITUTION

See Also:
  Constant Field Values

### validationPhase

    protected int validationPhase

  Flag used to check for cycles during validation

### UNVALIDATED

    public static final int UNVALIDATED

See Also:
  Constant Field Values

### VALIDATING

    public static final int VALIDATING

See Also:
  Constant Field Values

### VALIDATED

    public static final int VALIDATED

See Also:
  Constant Field Values

### INVALID

    public static final int INVALID

See Also:
  Constant Field Values

Constructor Detail

### SchemaType

    public SchemaType()

  Default constructor. For internal use only.

Method Detail

### getFingerprint

    public int getFingerprint()

  Get the fingerprint of the name of this type

  Returns:
    the fingerprint. Returns -1 for an anonymous type.

### setFingerprint

    public void setFingerprint(int fingerprint)

  Set the fingerprint of the name of this type. For internal use only.

  Parameters:
    `fingerprint` - the fingerprint allocated in the namepool for this schema

### getBaseTypeFingerprint

    public int getBaseTypeFingerprint()

  Get the fingerprint of the name of the base type of this type

  Returns:
    the fingerprint. Return -1 for an anonymous type.

### setBaseTypeFingerprint

    public void setBaseTypeFingerprint(int fingerprint)

  Set the fingerprint of the name of the base type of this type. For internal use only.

  Parameters:
    `fingerprint` - the fingerprint allocated in the namepool

### getLocalName

    public java.lang.String getLocalName()

  Get the local name of this type

  Returns:
    the local part of the name, or null if the type is anonymous

### setLocalName

    public void setLocalName(java.lang.String localName)

  Set the local name of this type

  Parameters:
    `localName` - the local name of the type

### getDisplayName

    public java.lang.String getDisplayName()

  Get the display name of the type: that is, a lexical QName with an arbitrary prefix

  Returns:
    a lexical QName identifying the type

### getTypeName

    public java.lang.String getTypeName()

  Get the local name of the type (a system-allocated name if anonymous). Needed to implement the DOM level 3 TypeInfo interface.

  Specified by:
    `getTypeName` in interface `TypeInfo`

### getTypeNamespace

    public java.lang.String getTypeNamespace()

  Get the namespace name of the type (a system-allocated name if anonymous). Needed to implement the DOM level 3 TypeInfo interface.

  Specified by:
    `getTypeNamespace` in interface `TypeInfo`

### isComplexType

    public final boolean isComplexType()

  Test whether this SchemaType is a complex type

  Returns:
    true if this SchemaType is a complex type

### isSimpleType

    public abstract boolean isSimpleType()

  Test whether this SchemaType is a simple type

  Returns:
    true if this SchemaType is a simple type

### getBlock

    public int getBlock()

  Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such as `DERIVATION_LIST` and `DERIVATION_EXTENSION`

  Returns:
    the value of the 'block' attribute for this type

### getNamePool

    public NamePool getNamePool()

  Get the NamePool in which the name of this type is defined

### setNamePool

    public void setNamePool(NamePool pool)

  Set the NamePool in which the type is defined. For internal use only.

  Parameters:
    `pool` - the NamePool containing the names in this schema

### getBaseType

    public SchemaType getBaseType()

  Returns the base type that this type inherits from. If this type is a Simpletype that is a built in primitive type then null is returned.

  Returns:
    the base type.

### setBaseType

    public void setBaseType(SchemaType baseType)
                     throws SchemaException

  Sets the base type for this datatype. For internal use only.

  Parameters:
    `baseType` - the base type which this type inherits from
    `SchemaException`

### getDerivationMethod

    public int getDerivationMethod()

  Gets the integer code of the derivation method used to derive this type from its parent. Returns zero for primitive types.

  Returns:
    a numeric code representing the derivation method, for example `DERIVATION_RESTRICTION`

### allowsDerivation

    public boolean allowsDerivation(int derivation)

  Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" property

  Parameters:
    `derivation` - the kind of derivation, for example `DERIVATION_LIST`
  Returns:
    true if this kind of derivation is allowed

### setDerivationMethodName

    public void setDerivationMethodName(java.lang.String method)
                                 throws SchemaException

  Set the derivation method name. For internal use only.

  Parameters:
    `method` - the derivation method, for example "restriction"
  Throws:
    `SchemaException` - for an unknown derivation method

### setDerivationMethod

    public void setDerivationMethod(int method)

  Sets the derivation method code (without validating it)

  Parameters:
    `method` - the derivation method as an integer code, for example `DERIVATION_UNION`

### setFinalProhibitions

    public void setFinalProhibitions(int finalValue)

  Sets the value of the 'final' property, indicating which types of derivation are not allowed. For internal use only.

  Parameters:
    `finalValue` - the value of the final property, as a bit-significant integer

### checkDerivation

    public void checkDerivation(SchemaType type,
                                int block)
                         throws SchemaException

  Check that this type is validly derived from a given type

  Parameters:
    `type` - the type from which this type is derived
    `block` - the derivations that are blocked by the relevant element declaration
  Throws:
    `SchemaException` - if the derivation is not allowed

### isDerivedFrom

    public boolean isDerivedFrom(java.lang.String typeNamespaceArg,
                                 java.lang.String typeNameArg,
                                 int derivationMethod)

  This method returns true if there is a derivation between the reference type definition, that is the TypeInfo on which the method is being called, and the other type definition, that is the one passed as parameters. This method implements the DOM Level 3 TypeInfo interface.

  Specified by:
    `isDerivedFrom` in interface `TypeInfo`
  Parameters:
    `typeNamespaceArg` - the namespace of the "other" type
    `typeNameArg` - the local name of the "other" type
    `derivationMethod` - the derivation method: zero or more of `TypeInfo.DERIVATION_RESTRICTION`, `TypeInfo.DERIVATION_EXTENSION`, `TypeInfo.DERIVATION_LIST`, or `TypeInfo.DERIVATION_UNION`. Zero means derived by any possible route.

### getTypedValue

    public abstract SequenceIterator getTypedValue(NodeInfo node)
                                            throws XPathException

  Get the typed value of a node that is annotated with this schema type

  Parameters:
    `node` - the node whose typed value is required
  Returns:
    a SequenceIterator over the atomic values making up the typed value of the specified node. The objects returned by this iterator are of type `AtomicValue`
    `XPathException`

### setContainingDeclaration

    public void setContainingDeclaration(int fingerprint,
                                         boolean isElement)

  Set the name of the containing declaration (for diagnostics)

  Parameters:
    `fingerprint` - The fingerprint of the element or attribute declaration "owning" this anonymous type definition
    `isElement` - True if the owning declaration is an element declaration, false if it is an attribute declaration

### setLocator

    public void setLocator(javax.xml.transform.SourceLocator locator)

  Set location information for diagnostics

  Parameters:
    `locator` - information about the location of the type definition within a schema document

### setSystemId

    public void setSystemId(java.lang.String systemId)

  Set the system identifier (URI) of the schema document in which this type is defined

  Parameters:
    `systemId` - the URI of the schema document

### setLineNumber

    public void setLineNumber(int lineNumber)

  Set the line number at which the type is defined within a schema document

  Parameters:
    `lineNumber` - the line where the definition appears

### getSystemId

    public java.lang.String getSystemId()

  Get the system ID (URI) of the schema document where the type was defined

  Specified by:
    `getSystemId` in interface `javax.xml.transform.SourceLocator`
  Returns:
    the system ID (or URI) of the containing schema document

### getLineNumber

    public int getLineNumber()

  Get the line number of the location where the type was defined

  Specified by:
    `getLineNumber` in interface `javax.xml.transform.SourceLocator`
  Returns:
    the line number

### getPublicId

    public java.lang.String getPublicId()

  Get the public ID of the location where the type was defined. This is always null.

  Specified by:
    `getPublicId` in interface `javax.xml.transform.SourceLocator`
  Returns:
    null

### getColumnNumber

    public int getColumnNumber()

  Get the column number of the location where the type was defined. This is always -1, meaning unknown.

  Specified by:
    `getColumnNumber` in interface `javax.xml.transform.SourceLocator`
  Returns:
    -1

### relationshipTo

    public abstract int relationshipTo(SchemaType other)

  Determine the relationship of this schema type to another schema type.

  Parameters:
    `other` - the other schema type
  Returns:
    `Type.SAME_TYPE` if the types are the same; `Type.SUBSUMES` if the first type subsumes the second (that is, all instances of the second type are also instances of the first); `Type.SUBSUMED_BY` if the second type subsumes the first; `Type.OVERLAPS` if the two types overlap (have a non-empty intersection); `Type.DISJOINT` if the two types are disjoint (have an empty intersection)

### getDescription

    public java.lang.String getDescription()

  Get a description of this type for use in diagnostics. In the case of a named type, this is the same as the display name. In the case of a type known to be defined immediately within an element or attribute declaration, it is a phrase that identifies the containing declaration. In other cases, it is a phrase of the form "defined at line L of URI". The description is designed to be inserted in a context such as "the type X is ..."

### getContainingDeclarationName

    public int getContainingDeclarationName()

  Get the name of the containing element or attribute declaration, if any (and if known)

  Returns:
    the name of the containing declaration, as a NamePool fingerprint.

### containingDeclarationIsElement

    public boolean containingDeclarationIsElement()

  Determine whether the containing declaration is an element declaration or an attribute declaration

  Returns:
    true if the containin declaration is an element declaration, false if it is an attribute

### isSameType

    public boolean isSameType(SchemaType other)

  Test whether this is the same type as another type. They are considered to be the same type if they are derived from the same type definition in the original XML representation (which can happen when there are multiple includes of the same file)