Class UserDefinedType

    • 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
    • Constructor Detail

      • UserDefinedType

        public UserDefinedType()
        Default constructor. For internal use only.
    • 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 interface SchemaType
        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:
        getTargetNamespace in interface SchemaType
        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 interface SchemaType
        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 interface SchemaType
        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 interface SchemaType
        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 interface SchemaType
        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 interface SchemaType
        Returns:
        a lexical QName identifying the type
      • isComplexType

        public final boolean isComplexType()
        Test whether this SchemaType is a complex type
        Specified by:
        isComplexType in interface SchemaType
        Returns:
        true if this SchemaType is a complex 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 interface SchemaType
        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 interface SchemaType
        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 interface SchemaType
        Parameters:
        derivation - the kind of derivation, for example Derivation.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 interface SchemaType
        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 example Derivation.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 interface SchemaType
        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
      • 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 definition
        isElement - 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 interface SchemaType
        Returns:
        text identifing the type, for use in a phrase such as "the type XXXX".
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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 interface SchemaType
        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 URI
        s2 - 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