Package com.saxonica.ee.schema
Class UserDefinedType
java.lang.Object
com.saxonica.ee.schema.SchemaStructure
com.saxonica.ee.schema.UserDefinedType
- All Implemented Interfaces:
UserSchemaComponent
,SourceLocator
,Location
,SchemaComponent
,SchemaType
,Locator
- Direct Known Subclasses:
UserComplexType
,UserSimpleType
public abstract class UserDefinedType
extends SchemaStructure
implements UserSchemaComponent, SchemaType
This class represents a user-defined simple type or complex type as defined in XML Schema.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Set
<UserComplexType> The set of all the types that are derived by extension from this typeprotected int
Flags used to implement the "final" and "block" attributes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
allowsDerivation
(int derivation) Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" propertyvoid
checkTypeDerivationIsOK
(SchemaType type, int block) Check that this type is validly derived from a given typeboolean
Determine whether the containing declaration is an element declaration or an attribute declarationReturns the base type that this type inherits from.int
Get the fingerprint of the name of the base type of this typeGet the reference to the base type.int
getBlock()
Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such asDerivation.DERIVATION_LIST
andDerivation.DERIVATION_EXTENSION
Get the name of the containing element or attribute declaration, if any (and if known).int
getDepth()
Get (and if necessary compute) the depth of the type in the type hierarchyint
Gets the integer code of the derivation method used to derive this type from its parent.Get a description of this type for use in diagnostics.Get the display name of the type: that is, a lexical QName with an arbitrary prefixGet the name of this type as an EQName, that is, a string in the format Q{uri}local.Get all the types defined as extensions of this type, transitivelyint
Get the types of derivation that are not permitted, by virtue of the "final" property.int
Get the fingerprint of the name of this typegetName()
Get the local name of this type if it has one.Get the NamePool in which the name of this type is definedGet the name of the type as a StructuredQNameGet the namespace URI of the name of this type if it has one.Get the name of the type as a StructuredQNameboolean
Test whether this is an anonymous typefinal boolean
Test whether this SchemaType is a complex typeboolean
isSameType
(SchemaType other) Test whether this is the same type as another type.static boolean
Compare two URIs, ignoring the "file:///" versus "file:/" differenceprotected void
registerExtensionType
(UserComplexType derived) Register another type as an extension of this typevoid
setBaseTypeReference
(TypeReference baseType) Sets the base type for this datatype.void
setContainingDeclaration
(StructuredQName declarationName, 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) Set the derivation method name.void
setExtendedTypes
(Set<UserComplexType> types) Set the set of types derived by extension from this onevoid
setFinalProhibitions
(int finalValue) Sets the value of the 'final' property, indicating which types of derivation are not allowed.void
setTypeName
(StructuredQName name, int fingerprint) Set the nameCode of the name of this type.toString()
Methods inherited from class com.saxonica.ee.schema.SchemaStructure
elaborate, fixup, getColumnNumber, getComponentAsFunction, getConfiguration, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, isValidationNeeded, lookForCycles, makeXPathExpressionPropertyRecord, saveLocation, setConfiguration, setFixupStatus, setGeneratedId, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatus, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getComponentAsFunction, getRedefinitionLevel, getValidationStatus
Methods inherited from interface net.sf.saxon.type.SchemaType
analyzeContentExpression, atomize, getSystemId, isAtomicType, isIdRefType, isIdType, isSimpleType
Methods inherited from interface com.saxonica.ee.schema.UserSchemaComponent
elaborate, fixup, lookForCycles, validate
-
Field Details
-
finalProhibitions
protected int finalProhibitionsFlags used to implement the "final" and "block" attributes -
extendedTypes
The set of all the types that are derived by extension from this type
-
-
Constructor Details
-
UserDefinedType
public UserDefinedType()Default constructor. For internal use only.
-
-
Method Details
-
getName
Get the local name of this type if it has one. Returns a conventional system-allocated name if the type is anonymous.- Specified by:
getName
in interfaceSchemaType
- Returns:
- the local name of the type component. Never null.
-
getTargetNamespace
Get the namespace URI of the name of this type if it has one. Returns a conventional system-allocated namespace if the type is anonymous.- Specified by:
getTargetNamespace
in interfaceSchemaType
- Returns:
- the target namespace of the type component. Never null.
-
getFingerprint
public int getFingerprint()Get the fingerprint of the name of this type- Specified by:
getFingerprint
in interfaceSchemaType
- Returns:
- the fingerprint. Returns an invented fingerprint for an anonymous type.
-
getTypeName
Get the name of the type as a StructuredQName- Returns:
- a StructuredQName identifying the type. In the case of an anonymous type, an internally-generated name is returned
-
getStructuredQName
Description copied from interface:SchemaType
Get the name of the type as a StructuredQName- Specified by:
getStructuredQName
in interfaceSchemaType
- Returns:
- a StructuredQName identifying the type. In the case of an anonymous type, an internally-generated name is returned
-
getEQName
Get the name of this type as an EQName, that is, a string in the format Q{uri}local.- Specified by:
getEQName
in interfaceSchemaType
- Returns:
- an EQName identifying the type. In the case of an anonymous type, an internally-generated name is returned
-
isAnonymousType
public boolean isAnonymousType()Test whether this is an anonymous type- Specified by:
isAnonymousType
in interfaceSchemaType
- Returns:
- true if this SchemaType is an anonymous type
-
setTypeName
Set the nameCode of the name of this type. For internal use only.- Parameters:
fingerprint
- the nameCode allocated in the namepool for this schema
-
getBaseTypeReference
Get the reference to the base type. The result is never null, except in the case of the type AnyType, which is the root of the type hierarchy.- Returns:
- a reference to the base type
-
getBaseTypeFingerprint
public int getBaseTypeFingerprint()Get the fingerprint of the name of the base type of this type- Returns:
- the fingerprint. Return an invented fingerprint for an anonymous type.
-
getDisplayName
Get the display name of the type: that is, a lexical QName with an arbitrary prefix- Specified by:
getDisplayName
in interfaceSchemaType
- Returns:
- a lexical QName identifying the type
-
isComplexType
public final boolean isComplexType()Test whether this SchemaType is a complex type- Specified by:
isComplexType
in interfaceSchemaType
- Returns:
- true if this SchemaType is a complex type
-
getBlock
public int getBlock()Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such asDerivation.DERIVATION_LIST
andDerivation.DERIVATION_EXTENSION
- Specified by:
getBlock
in interfaceSchemaType
- Returns:
- the value of the 'block' attribute for this type
-
getNamePool
Get the NamePool in which the name of this type is defined- Returns:
- the name pool
-
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.- Specified by:
getBaseType
in interfaceSchemaType
- Returns:
- the base type.
- Throws:
IllegalStateException
- if this type has no known base type. This can only arise during schema construction, since a type with an unknown base type cannot be used for validation
-
setBaseTypeReference
Sets the base type for this datatype. For internal use only.- Parameters:
baseType
- the base type which this type inherits from
-
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.- Specified by:
getDerivationMethod
in interfaceSchemaType
- Returns:
- a numeric code representing the derivation method, for example
Derivation.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- Specified by:
allowsDerivation
in interfaceSchemaType
- Parameters:
derivation
- the kind of derivation, for exampleDerivation.DERIVATION_LIST
- Returns:
- true if this kind of derivation is allowed
-
getFinalProhibitions
public int getFinalProhibitions()Get the types of derivation that are not permitted, by virtue of the "final" property.- Specified by:
getFinalProhibitions
in interfaceSchemaType
- Returns:
- the types of derivation that are not permitted, as a bit-significant integer
containing bits such as
Derivation.DERIVATION_EXTENSION
-
setDerivationMethodName
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 exampleDerivation.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
-
checkTypeDerivationIsOK
Check that this type is validly derived from a given type- Specified by:
checkTypeDerivationIsOK
in interfaceSchemaType
- Parameters:
type
- the type from which this type is derivedblock
- the derivations that are blocked by the relevant element declaration- Throws:
SchemaException
- if the derivation is not allowed
-
setContainingDeclaration
Set the name of the containing declaration (for diagnostics)- Parameters:
declarationName
- The name of the element or attribute declaration "owning" this anonymous type definitionisElement
- True if the owning declaration is an element declaration, false if it is an attribute declaration
-
getDescription
Get a description of this type for use in diagnostics. In the case of a named type, this is the EQName. 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 ..."- Specified by:
getDescription
in interfaceSchemaType
- Returns:
- text identifing the type, for use in a phrase such as "the type XXXX".
-
toString
-
getContainingDeclarationName
Get the name of the containing element or attribute declaration, if any (and if known).- Returns:
- the name of the containing declaration.
-
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
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)- Specified by:
isSameType
in interfaceSchemaType
- Parameters:
other
- the other type- Returns:
- true if this is the same type as other
-
isSameURI
Compare two URIs, ignoring the "file:///" versus "file:/" difference- Parameters:
s1
- the first URIs2
- the second URI- Returns:
- true if they are equivalent under these rules
-
registerExtensionType
Register another type as an extension of this type- Parameters:
derived
- the type that is derived from this one by extension
-
getExtensionTypes
Get all the types defined as extensions of this type, transitively- Returns:
- the set of complex types derived by extension from this type, either directly or indirectly
-
setExtendedTypes
Set the set of types derived by extension from this one- Parameters:
types
- the set of extended types
-
getDepth
public int getDepth()Get (and if necessary compute) the depth of the type in the type hierarchy
-