Package com.saxonica.ee.schema
Class UserDefinedType
- java.lang.Object
-
- com.saxonica.ee.schema.SchemaStructure
-
- com.saxonica.ee.schema.UserDefinedType
-
- All Implemented Interfaces:
UserSchemaComponent
,javax.xml.transform.SourceLocator
,Location
,SchemaComponent
,SchemaType
,org.xml.sax.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
Fields Modifier and Type Field Description protected java.util.Set<UserComplexType>
extendedTypes
The set of all the types that are derived by extension from this typeprotected int
finalProhibitions
Flags used to implement the "final" and "block" attributes
-
Constructor Summary
Constructors Constructor Description UserDefinedType()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
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
containingDeclarationIsElement()
Determine whether the containing declaration is an element declaration or an attribute declarationSchemaType
getBaseType()
Returns the base type that this type inherits from.int
getBaseTypeFingerprint()
Get the fingerprint of the name of the base type of this typeTypeReference
getBaseTypeReference()
Get 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
StructuredQName
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 prefixjava.lang.String
getEQName()
Get the name of this type as an EQName, that is, a string in the format Q{uri}local.java.util.Set<UserComplexType>
getExtensionTypes()
Get all the types defined as extensions of this type, transitivelyint
getFinalProhibitions()
Get the types of derivation that are not permitted, by virtue of the "final" property.int
getFingerprint()
Get the fingerprint of the name of this typejava.lang.String
getName()
Get the local name of this type if it has one.NamePool
getNamePool()
Get the NamePool in which the name of this type is definedStructuredQName
getStructuredQName()
Get the name of the type as a StructuredQNameNamespaceUri
getTargetNamespace()
Get the namespace URI of the name of this type if it has one.StructuredQName
getTypeName()
Get the name of the type as a StructuredQNameboolean
isAnonymousType()
Test whether this is an anonymous typeboolean
isComplexType()
Test whether this SchemaType is a complex typeboolean
isSameType(SchemaType other)
Test whether this is the same type as another type.static boolean
isSameURI(java.lang.String s1, java.lang.String s2)
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(java.lang.String method)
Set the derivation method name.void
setExtendedTypes(java.util.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.java.lang.String
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 Detail
-
finalProhibitions
protected int finalProhibitions
Flags used to implement the "final" and "block" attributes
-
extendedTypes
protected java.util.Set<UserComplexType> extendedTypes
The set of all the types that are derived by extension from this type
-
-
Method Detail
-
getName
public java.lang.String 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
public NamespaceUri 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
public StructuredQName 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
public StructuredQName 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
public java.lang.String 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
public void setTypeName(StructuredQName name, int fingerprint)
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
public TypeReference 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
public java.lang.String 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
public NamePool getNamePool()
Get the NamePool in which the name of this type is defined- Returns:
- the name pool
-
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.- Specified by:
getBaseType
in interfaceSchemaType
- Returns:
- the base type.
- Throws:
java.lang.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
public void setBaseTypeReference(TypeReference baseType)
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
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 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
public void checkTypeDerivationIsOK(SchemaType type, int block) throws SchemaException
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
public void setContainingDeclaration(StructuredQName declarationName, boolean isElement)
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
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 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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getContainingDeclarationName
public StructuredQName 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
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)- Specified by:
isSameType
in interfaceSchemaType
- Parameters:
other
- the other type- Returns:
- true if this is the same type as other
-
isSameURI
public static boolean isSameURI(java.lang.String s1, java.lang.String s2)
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
protected void registerExtensionType(UserComplexType derived)
Register another type as an extension of this type- Parameters:
derived
- the type that is derived from this one by extension
-
getExtensionTypes
public java.util.Set<UserComplexType> 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
public void setExtendedTypes(java.util.Set<UserComplexType> types)
Set the set of types derived by extension from this one- Parameters:
types
- the set of extended types
-
-