Class LocalUnionType

    • Constructor Detail

      • LocalUnionType

        public LocalUnionType​(java.util.List<AtomicType> memberTypes)
        Creates a new Union type.
        Parameters:
        memberTypes - the atomic member types of the union
      • LocalUnionType

        public LocalUnionType​(AtomicType... memberTypes)
    • Method Detail

      • getGenre

        public Genre getGenre()
        Get the genre of this item
        Specified by:
        getGenre in interface ItemType
        Returns:
        the genre
      • getTypeName

        public StructuredQName getTypeName()
        Description copied from interface: PlainType
        Get the name of this type as a structured QName
        Specified by:
        getTypeName in interface PlainType
        Specified by:
        getTypeName in interface UnionType
        Returns:
        the name of this type. If the type is anonymous, an internally-generated type name is returned
      • getMemberTypes

        public java.util.List<? extends AtomicType> getMemberTypes()
      • isAtomicType

        public boolean isAtomicType()
        Ask whether this Simple Type is an atomic type
        Specified by:
        isAtomicType in interface ItemType
        Returns:
        false, this is not an atomic type
      • containsListType

        public boolean containsListType()
        Ask whether this union type includes any list types among its members
        Specified by:
        containsListType in interface UnionType
        Returns:
        true of one of the member types is a list type
      • isPlainType

        public boolean isPlainType()
        Ask whether this Union type is a "plain type", defined as a union type whose member types are all atomic types or plain unions. That is, it disallows unions that are derived by restriction from another union. The significance of this is that an atomic value will never match a non-plain union type
        Specified by:
        isPlainType in interface ItemType
        Returns:
        true if this is ANY_ATOMIC_TYPE or a subtype thereof, or a "plain" union type (that is, unions of atomic types that impose no further restrictions). Return false if this is a union type whose member types are not all known.
      • getResultTypeOfCast

        public SequenceType getResultTypeOfCast()
        Get the SequenceType that most accurately describes the result of casting a value to this union type
        Specified by:
        getResultTypeOfCast in interface UnionType
        Returns:
        the most precise SequenceType for the result of casting
      • isIdType

        public boolean isIdType()
        Ask whether this type is an ID type. This is defined to be any simple type who typed value may contain atomic values of type xs:ID: that is, it includes types derived from ID by restriction, list, or union. Note that for a node to be treated as an ID in XSD 1.0, its typed value must be a *single* atomic value of type ID; the type of the node, however, can still allow a list or union. This changes in XSD 1.1, where a list of IDs is allowed.
      • isIdRefType

        public boolean isIdRefType()
        Ask whether this type is an IDREF or IDREFS type. This is defined to be any simple type who typed value may contain atomic values of type xs:IDREF: that is, it includes types derived from IDREF or IDREFS by restriction, list, or union
      • isBuiltInType

        public boolean isBuiltInType()
        Determine whether this is a built-in type or a user-defined type
      • isListType

        public boolean isListType()
        Determine whether this is a list type
      • isUnionType

        public boolean isUnionType()
        Return true if this type is a union type (that is, if its variety is union)
        Returns:
        true for a union type
      • getUType

        public UType getUType()
        Get the corresponding UType. A UType is a union of primitive item types.
        Specified by:
        getUType in interface ItemType
        Returns:
        the smallest UType that subsumes this item type
      • getBasicAlphaCode

        public java.lang.String getBasicAlphaCode()
        Get an alphabetic code representing the type, or at any rate, the nearest built-in type from which this type is derived. The codes are designed so that for any two built-in types A and B, alphaCode(A) is a prefix of alphaCode(B) if and only if A is a supertype of B.
        Specified by:
        getBasicAlphaCode in interface ItemType
        Returns:
        the alphacode for the nearest containing built-in type
      • isNamespaceSensitive

        public boolean isNamespaceSensitive()
        Test whether this type is namespace sensitive, that is, if a namespace context is needed to translate between the lexical space and the value space. This is true for types derived from, or containing, QNames and NOTATIONs
        Specified by:
        isNamespaceSensitive in interface HyperType
        Returns:
        true if any of the member types is namespace-sensitive, or if namespace sensitivity cannot be determined because there are components missing from the schema.
      • validateContent

        public ValidationFailure validateContent​(UnicodeString value,
                                                 NamespaceResolver nsResolver,
                                                 ConversionRules rules)
        Check whether a given input string is valid according to this SimpleType
        Parameters:
        value - the input string to be checked
        nsResolver - a namespace resolver used to resolve namespace prefixes if the type is namespace sensitive. The value supplied may be null; in this case any namespace-sensitive content will throw an UnsupportedOperationException.
        rules - the configuration-wide conversion rules
        Returns:
        null if validation succeeds; return a ValidationFailure describing the validation failure if validation fails
        Throws:
        java.lang.UnsupportedOperationException - if the type is namespace-sensitive and no namespace resolver is supplied
      • checkAgainstFacets

        public ValidationFailure checkAgainstFacets​(AtomicValue value,
                                                    ConversionRules rules)
        Validate an atomic value, which is known to be an instance of one of the member types of the union, against any facets (pattern facets or enumeration facets) defined at the level of the union itself.
        Specified by:
        checkAgainstFacets in interface UnionType
        Parameters:
        value - the Atomic Value to be checked. This must be an instance of a member type of the union
        rules - the ConversionRules for the Configuration
        Returns:
        a ValidationFailure if the value is not valid; null if it is valid.
      • getTypedValue

        public AtomicValue getTypedValue​(UnicodeString value,
                                         NamespaceResolver resolver,
                                         ConversionRules rules)
                                  throws ValidationException
        Description copied from interface: UnionType
        Get the typed value corresponding to a given string value, assuming it is valid against this type
        Specified by:
        getTypedValue in interface UnionType
        Parameters:
        value - the string value
        resolver - a namespace resolver used to resolve any namespace prefixes appearing in the content of values. Can supply null, in which case any namespace-sensitive content will be rejected.
        rules - the conversion rules from the configuration
        Returns:
        the atomic sequence comprising the typed value. The objects returned by this SequenceIterator will all be of type AtomicValue,
        Throws:
        ValidationException - if the supplied value is not in the lexical space of the data type
      • matches

        public boolean matches​(Item item,
                               TypeHierarchy th)
        Test whether a given item conforms to this type
        Specified by:
        matches in interface ItemType
        Specified by:
        matches in interface PlainType
        Parameters:
        item - The item to be tested
        th - The type hierarchy
        Returns:
        true if the item is an instance of this type; false otherwise
      • getPrimitiveType

        public int getPrimitiveType()
        Method defined in ItemType: get a primitive supertype in the ItemType type hierarchy
        Specified by:
        getPrimitiveType in interface ItemType
        Returns:
        StandardNames.XS_ANY_ATOMIC_TYPE
      • getAtomizedItemType

        public PlainType getAtomizedItemType()
        Description copied from interface: ItemType
        Get the item type of the atomic values that will be produced when an item of this type is atomized
        Specified by:
        getAtomizedItemType in interface ItemType
        Returns:
        the best available item type of the atomic values that will be produced when an item of this type is atomized, or null if it is known that atomization will throw an error.
      • isAtomizable

        public boolean isAtomizable​(TypeHierarchy th)
        Description copied from interface: ItemType
        Ask whether values of this type are atomizable
        Specified by:
        isAtomizable in interface ItemType
        Parameters:
        th - the type hierarchy cache
        Returns:
        true if some or all instances of this type can be successfully atomized; false if no instances of this type can be atomized
      • getPlainMemberTypes

        public java.util.List<? extends PlainType> getPlainMemberTypes()
        Get the list of plain types that are subsumed by this type
        Specified by:
        getPlainMemberTypes in interface PlainType
        Specified by:
        getPlainMemberTypes in interface UnionType
        Returns:
        for an atomic type, the type itself; for a plain union type, the list of plain types in its transitive membership, in declaration order
      • getDefaultPriority

        public double getDefaultPriority()
        Get the default priority when this ItemType is used as an XSLT pattern
        Specified by:
        getDefaultPriority in interface ItemType
        Returns:
        the default priority. For a union type this is defined as the product of the default priorities of the member types. Because the priorities of member types are in the range 0 to 1, their product is also in the range 0 to 1.
      • toString

        public java.lang.String toString()
        Produce a string representation of the type name. If the type is anonymous, an internally-allocated type name will be returned.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the name of the atomic type in the form Q{uri}local
      • toExportString

        public java.lang.String toExportString()
        Description copied from interface: ItemType
        Return a string representation of this ItemType suitable for use in stylesheet export files. This differs from the result of toString() in that it will not contain any references to anonymous types. Note that it may also use the Saxon extended syntax for union types and tuple types. The default implementation returns the result of calling toString().
        Specified by:
        toExportString in interface ItemType
        Returns:
        the string representation as an instance of the XPath SequenceType construct