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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.sf.saxon.type.SchemaComponent
SchemaComponent.ValidationStatus
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<UserComplexType>extendedTypesThe set of all the types that are derived by extension from this typeprotected intfinalProhibitionsFlags used to implement the "final" and "block" attributes-
Fields inherited from interface net.sf.saxon.type.SchemaComponent
COMPONENT_FUNCTION_TYPE
-
Fields inherited from interface net.sf.saxon.type.SchemaType
DERIVATION_EXTENSION, DERIVATION_LIST, DERIVATION_RESTRICTION, DERIVATION_UNION, DERIVE_BY_SUBSTITUTION
-
-
Constructor Summary
Constructors Constructor Description UserDefinedType()Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowsDerivation(int derivation)Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" propertyvoidcheckTypeDerivationIsOK(SchemaType type, int block)Check that this type is validly derived from a given typebooleancontainingDeclarationIsElement()Determine whether the containing declaration is an element declaration or an attribute declarationSchemaTypegetBaseType()Returns the base type that this type inherits from.intgetBaseTypeFingerprint()Get the fingerprint of the name of the base type of this typeTypeReferencegetBaseTypeReference()Get the reference to the base type.intgetBlock()Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such asSchemaType.DERIVATION_LISTandSchemaType.DERIVATION_EXTENSIONStructuredQNamegetContainingDeclarationName()Get the name of the containing element or attribute declaration, if any (and if known).intgetDerivationMethod()Gets the integer code of the derivation method used to derive this type from its parent.java.lang.StringgetDescription()Get a description of this type for use in diagnostics.java.lang.StringgetDisplayName()Get the display name of the type: that is, a lexical QName with an arbitrary prefixjava.lang.StringgetEQName()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, transitivelyintgetFinalProhibitions()Get the types of derivation that are not permitted, by virtue of the "final" property.intgetFingerprint()Get the fingerprint of the name of this typejava.lang.StringgetName()Get the local name of this type if it has one.NamePoolgetNamePool()Get the NamePool in which the name of this type is definedStructuredQNamegetStructuredQName()Get the name of the type as a StructuredQNamejava.lang.StringgetTargetNamespace()Get the namespace URI of the name of this type if it has one.StructuredQNamegetTypeName()Get the name of the type as a StructuredQNamebooleanisAnonymousType()Test whether this is an anonymous typebooleanisComplexType()Test whether this SchemaType is a complex typebooleanisSameType(SchemaType other)Test whether this is the same type as another type.static booleanisSameURI(java.lang.String s1, java.lang.String s2)Compare two URIs, ignoring the "file:///" versus "file:/" differenceprotected voidregisterExtensionType(UserComplexType derived)Register another type as an extension of this typevoidsetBaseTypeReference(TypeReference baseType)Sets the base type for this datatype.voidsetContainingDeclaration(StructuredQName declarationName, boolean isElement)Set the name of the containing declaration (for diagnostics)voidsetDerivationMethod(int method)Sets the derivation method code (without validating it)voidsetDerivationMethodName(java.lang.String method)Set the derivation method name.voidsetExtendedTypes(java.util.Set<UserComplexType> types)Set the set of types derived by extension from this onevoidsetFinalProhibitions(int finalValue)Sets the value of the 'final' property, indicating which types of derivation are not allowed.voidsetTypeName(StructuredQName name, int fingerprint)Set the nameCode of the name of this type.java.lang.StringtoString()-
Methods inherited from class com.saxonica.ee.schema.SchemaStructure
elaborate, fixup, getColumnNumber, getConfiguration, getFixupStatus, getGeneratedId, getLineNumber, getPublicId, getRedefinitionLevel, getSchemaDocumentURI, getSystemId, getValidationStatus, hasSameLocation, isValidationNeeded, lookForCycles, makeXPathExpressionPropertyRecord, saveLocation, setConfiguration, setFixupStatus, setGeneratedId, setLineNumber, setLocator, setRedefinitionLevel, setSchemaDocumentURI, setSystemId, setValidationStatus
-
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, getNearestNamedType, 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:
getNamein interfaceSchemaType- Returns:
- the local name of the type component. Never null.
-
getTargetNamespace
public java.lang.String 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:
getTargetNamespacein 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:
getFingerprintin 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:SchemaTypeGet the name of the type as a StructuredQName- Specified by:
getStructuredQNamein 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:
getEQNamein 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:
isAnonymousTypein 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:
getDisplayNamein interfaceSchemaType- Returns:
- a lexical QName identifying the type
-
isComplexType
public final boolean isComplexType()
Test whether this SchemaType is a complex type- Specified by:
isComplexTypein 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 asSchemaType.DERIVATION_LISTandSchemaType.DERIVATION_EXTENSION- Specified by:
getBlockin 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:
getBaseTypein 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:
getDerivationMethodin interfaceSchemaType- Returns:
- a numeric code representing the derivation method, for example
SchemaType.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:
allowsDerivationin interfaceSchemaType- Parameters:
derivation- the kind of derivation, for exampleSchemaType.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:
getFinalProhibitionsin interfaceSchemaType- Returns:
- the types of derivation that are not permitted, as a bit-significant integer
containing bits such as
SchemaType.DERIVATION_EXTENSION
-
setDerivationMethodName
public void setDerivationMethodName(java.lang.String method) throws SchemaExceptionSet 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 exampleSchemaType.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:
checkTypeDerivationIsOKin 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:
getDescriptionin interfaceSchemaType- Returns:
- text identifing the type, for use in a phrase such as "the type XXXX".
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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:
isSameTypein 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
-
-