net.sf.saxon.type

## Class TypeHierarchy

- java.lang.Object
- - net.sf.saxon.type.TypeHierarchy

- All Implemented Interfaces:
    Serializable

      public class TypeHierarchy
      extends Object
      implements Serializable

  This class exists to provide answers to questions about the type hierarchy. Because such questions are potentially expensive, it caches the answers. There is one instance of this class for a Configuration.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Configuration` | `config`
    `static int` | `DISJOINT` Constant denoting relationship between two types: A is disjoint from B
    `static int` | `OVERLAPS` Constant denoting relationship between two types: A overlaps B
    `static int` | `SAME_TYPE` Constant denoting relationship between two types: A is the same type as B
    `static int` | `SUBSUMED_BY` Constant denoting relationship between two types: A is subsumed by B
    `static int` | `SUBSUMES` Constant denoting relationship between two types: A subsumes B

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TypeHierarchy(Configuration config)` Create the type hierarchy cache for a configuration

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected SequenceIterator` | `applyFunctionCoercion(SequenceIterator iterator, ItemType suppliedItemType, ItemType requiredItemType, RoleLocator role, SourceLocator locator)` Apply function coercion when function items are supplied as arguments to a function call.
    `Sequence` | `applyFunctionConversionRules(Sequence value, SequenceType requiredType, RoleLocator role, SourceLocator locator)` Apply the function conversion rules to a value, given a required type.
    `protected int` | `computeContentRelationship(ItemType t1, ItemType t2, IntSet n1, IntSet n2)` Compute the relationship between the allowed content-types of two types
    `Configuration` | `getConfiguration()` Get the Saxon configuration to which this type hierarchy belongs
    `ItemType` | `getGenericFunctionItemType()`
    `boolean` | `isIdCode(int typeCode)` Test whether a type annotation code represents the type xs:ID or one of its subtypes
    `boolean` | `isIdrefsCode(int typeCode)` Test whether a type annotation code represents the type xs:IDREF, xs:IDREFS or one of their subtypes
    `boolean` | `isSubType(ItemType subtype, ItemType supertype)` Determine whether type A is type B or one of its subtypes, recursively.
    `int` | `relationship(ItemType t1, ItemType t2)` Determine the relationship of one item type to another.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### config

          protected Configuration config

    - #### SAME_TYPE

          public static final int SAME_TYPE

      Constant denoting relationship between two types: A is the same type as B
      See Also:
        Constant Field Values

    - #### SUBSUMES

          public static final int SUBSUMES

      Constant denoting relationship between two types: A subsumes B
      See Also:
        Constant Field Values

    - #### SUBSUMED_BY

          public static final int SUBSUMED_BY

      Constant denoting relationship between two types: A is subsumed by B
      See Also:
        Constant Field Values

    - #### OVERLAPS

          public static final int OVERLAPS

      Constant denoting relationship between two types: A overlaps B
      See Also:
        Constant Field Values

    - #### DISJOINT

          public static final int DISJOINT

      Constant denoting relationship between two types: A is disjoint from B
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TypeHierarchy

          public TypeHierarchy(Configuration config)

      Create the type hierarchy cache for a configuration
      Parameters:
        `config` - the configuration

  - ### Method Detail

    - #### applyFunctionConversionRules

          public Sequence applyFunctionConversionRules(Sequence value,
                                              SequenceType requiredType,
                                              RoleLocator role,
                                              SourceLocator locator)
                                                throws XPathException

      Apply the function conversion rules to a value, given a required type. The parameter type S represents the supplied type, R the required type
      Parameters:
        `value` - a value to be converted
        `requiredType` - the required type
      Returns:
        the converted value
      Throws:
        `XPathException` - if the value cannot be converted to the required type

    - #### applyFunctionCoercion

          protected SequenceIterator applyFunctionCoercion(SequenceIterator iterator,
                                               ItemType suppliedItemType,
                                               ItemType requiredItemType,
                                               RoleLocator role,
                                               SourceLocator locator)

      Apply function coercion when function items are supplied as arguments to a function call. This does not happen in Saxon-HE, so the implementation is subclassed in Saxon-PE/EE
      Parameters:
        `iterator` - An iterator over the supplied value of the parameter
        `suppliedItemType` - the item type of the supplied value
        `requiredItemType` - the required item type (typically a function item type)
        `role` - information for diagnostics
        `locator` - information for diagnostics
      Returns:
        an iterator over the converted value

    - #### getConfiguration

          public Configuration getConfiguration()

      Get the Saxon configuration to which this type hierarchy belongs
      Returns:
        the configuration

    - #### isSubType

          public boolean isSubType(ItemType subtype,
                          ItemType supertype)

      Determine whether type A is type B or one of its subtypes, recursively. "Subtype" here means a type that is subsumed, that is, a type whose instances are a subset of the instances of the other type.
      Parameters:
        `subtype` - identifies the first type
        `supertype` - identifies the second type
      Returns:
        true if the first type is the second type or is subsumed by the second type

    - #### relationship

          public int relationship(ItemType t1,
                         ItemType t2)

      Determine the relationship of one item type to another.
      Parameters:
        `t1` - the first item type
        `t2` - the second item type
      Returns:
        `SAME_TYPE` if the types are the same; `SUBSUMES` if the first type subsumes the second (that is, all instances of the second type are also instances of the first); `SUBSUMED_BY` if the second type subsumes the first; `OVERLAPS` if the two types overlap (have a non-empty intersection, but neither subsumes the other); `DISJOINT` if the two types are disjoint (have an empty intersection)

    - #### computeContentRelationship

          protected int computeContentRelationship(ItemType t1,
                                       ItemType t2,
                                       IntSet n1,
                                       IntSet n2)

      Compute the relationship between the allowed content-types of two types
      Parameters:
        `t1` - the first type
        `t2` - the second types
        `n1` - the set of element names allowed by the first type
        `n2` - the set of element names allowed by the second type
      Returns:
        the relationship (same type, subsumes, overlaps, subsumed-by)

    - #### getGenericFunctionItemType

          public ItemType getGenericFunctionItemType()

    - #### isIdCode

          public boolean isIdCode(int typeCode)

      Test whether a type annotation code represents the type xs:ID or one of its subtypes
      Parameters:
        `typeCode` - the type annotation to be tested
      Returns:
        true if the type annotation represents an xs:ID

    - #### isIdrefsCode

          public boolean isIdrefsCode(int typeCode)

      Test whether a type annotation code represents the type xs:IDREF, xs:IDREFS or one of their subtypes
      Parameters:
        `typeCode` - the type annotation to be tested
      Returns:
        true if the type annotation represents an xs:IDREF or xs:IDREFS or a subtype thereof

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.