net.sf.saxon.type
Class SchemaType

java.lang.Object
  extended by net.sf.saxon.type.SchemaType
All Implemented Interfaces:
Serializable, SourceLocator
Direct Known Subclasses:
AnyType, SimpleType

public abstract class SchemaType
extends Object
implements Serializable, SourceLocator

The base type for XML Schema types, such as complex types and simple types.

Version:
$Revision: 1.1 $ $Date: 2004/03/09 10:10:35 $
Author:
Keith Visco
See Also:
Serialized Form

Field Summary
static int ALL_DERIVATIONS
           
static int DERIVE_BY_EXTENSION
           
static int DERIVE_BY_LIST
           
static int DERIVE_BY_RESTRICTION
           
static int DERIVE_BY_SUBSTITUTION
           
static int DERIVE_BY_UNION
           
protected  int finalProhibitions
          Flags used to implement the "final" and "block" attributes
protected static int INVALID
           
protected static int UNVALIDATED
           
protected static int VALIDATED
           
protected 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()
           
 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 DERIVE_BY_LIST and DERIVE_BY_EXTENSION
 int getColumnNumber()
          Get the column number of the location where the type was defined.
 int getContainingDeclarationName()
           
 int getDerivationMethod()
          Gets the code of the derivation method used to derive this type from its parent.
 String getDescription()
          Get a description of this type for use in diagnostics
 String getDisplayName()
           
 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
 String getLocalName()
          Returns the local name of this type (null if none was defined)
 NamePool getNamePool()
          Get the NamePool in which this type is defined
 String getPublicId()
          Get the public ID of the location where the type was defined.
 String getSystemId()
          Get the system ID of the location where the type was defined
abstract  SequenceIterator getTypedValue(NodeInfo node)
          Get the typed value of a node that is annotated with this schema type
 boolean isComplexType()
          Returns true if this SchemaType is a ComplexType
abstract  boolean isSimpleType()
          Returns true if this SchemaType is a SimpleType
 boolean isValidRestriction(SchemaType base, SchemaMarker schema)
          Determine whether this type is a valid restriction of another 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(String method)
          Sets the derivation method name
 void setFinal(int value)
          Sets the value of the 'final' property, indicating which types of derivation are not allowed.
 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)
           
 void setLocalName(String localName)
          Sets the local name of this type
 void setLocator(SourceLocator locator)
          Set location information for diagnostics
 void setNamePool(NamePool pool)
          Set the NamePool in which the type is defined
 void setSystemId(String systemId)
           
 
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


DERIVE_BY_RESTRICTION

public static final int DERIVE_BY_RESTRICTION
See Also:
Constant Field Values

DERIVE_BY_EXTENSION

public static final int DERIVE_BY_EXTENSION
See Also:
Constant Field Values

DERIVE_BY_UNION

public static final int DERIVE_BY_UNION
See Also:
Constant Field Values

DERIVE_BY_LIST

public static final int DERIVE_BY_LIST
See Also:
Constant Field Values

DERIVE_BY_SUBSTITUTION

public static final int DERIVE_BY_SUBSTITUTION
See Also:
Constant Field Values

ALL_DERIVATIONS

public static final int ALL_DERIVATIONS
See Also:
Constant Field Values

validationPhase

protected int validationPhase
Flag used to check for cycles during validation


UNVALIDATED

protected static final int UNVALIDATED
See Also:
Constant Field Values

VALIDATING

protected static final int VALIDATING
See Also:
Constant Field Values

VALIDATED

protected static final int VALIDATED
See Also:
Constant Field Values

INVALID

protected static final int INVALID
See Also:
Constant Field Values
Constructor Detail

SchemaType

public SchemaType()
Default constructor

Method Detail

getFingerprint

public int getFingerprint()
Get the fingerprint of the name of this type

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

setFingerprint

public void setFingerprint(int fingerprint)
Set the fingerprint of the name of this type

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

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

getLocalName

public String getLocalName()
Returns the local name of this type (null if none was defined)


setLocalName

public void setLocalName(String localName)
Sets the local name of this type

Parameters:
localName - local name of the type

getDisplayName

public String getDisplayName()

isComplexType

public final boolean isComplexType()
Returns true if this SchemaType is a ComplexType

Returns:
true if this SchemaType is a ComplexType

isSimpleType

public abstract boolean isSimpleType()
Returns true if this SchemaType is a SimpleType

Returns:
true if this SchemaType is a SimpleType

getBlock

public int getBlock()
Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such as DERIVE_BY_LIST and DERIVE_BY_EXTENSION

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

getNamePool

public NamePool getNamePool()
Get the NamePool in which this type is defined


setNamePool

public void setNamePool(NamePool pool)
Set the NamePool in which the type is defined

Parameters:
pool - the NamePool

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 parent type.

setBaseType

public void setBaseType(SchemaType baseType)
                 throws SchemaException
Sets the base type for this datatype

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

getDerivationMethod

public int getDerivationMethod()
Gets the code of the derivation method used to derive this type from its parent. Return zero for primitive types.

Returns:
a code, for example DERIVE_BY_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, e.g. DERIVE_BY_LIST
Returns:
true if this kind of derivation is allowed

setDerivationMethodName

public void setDerivationMethodName(String method)
                             throws SchemaException
Sets the derivation method name

Throws:
SchemaException

setDerivationMethod

public void setDerivationMethod(int method)
Sets the derivation method code (without validating it)


setFinal

public void setFinal(int value)
              throws SchemaException
Sets the value of the 'final' property, indicating which types of derivation are not allowed.

Parameters:
value - the value of the final property, as a bit-significant integer
Throws:
SchemaException - when the value is not a valid value.

setFinalProhibitions

public void setFinalProhibitions(int finalValue)
Sets the value of the 'final' property, indicating which types of derivation are not allowed.

Parameters:
finalValue - the bit-significant code representing the final property.

checkDerivation

public void checkDerivation(SchemaType type,
                            int block)
                     throws SchemaException
Check that this type is validly derived from a given type

Throws:
SchemaException

getTypedValue

public abstract SequenceIterator getTypedValue(NodeInfo node)
                                        throws XPathException
Get the typed value of a node that is annotated with this schema type

Throws:
XPathException

setContainingDeclaration

public void setContainingDeclaration(int fingerprint,
                                     boolean isElement)
Set the name of the containing declaration (for diagnostics)


setLocator

public void setLocator(SourceLocator locator)
Set location information for diagnostics


setSystemId

public void setSystemId(String systemId)

setLineNumber

public void setLineNumber(int lineNumber)

getSystemId

public String getSystemId()
Get the system ID of the location where the type was defined

Specified by:
getSystemId in interface SourceLocator

getLineNumber

public int getLineNumber()
Get the line number of the location where the type was defined

Specified by:
getLineNumber in interface SourceLocator

getPublicId

public String getPublicId()
Get the public ID of the location where the type was defined. This is always null.

Specified by:
getPublicId in interface SourceLocator

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 SourceLocator

getDescription

public String getDescription()
Get a description of this type for use in diagnostics


getContainingDeclarationName

public int getContainingDeclarationName()

containingDeclarationIsElement

public boolean containingDeclarationIsElement()

isValidRestriction

public boolean isValidRestriction(SchemaType base,
                                  SchemaMarker schema)
                           throws SchemaException
Determine whether this type is a valid restriction of another type

Throws:
SchemaException