Package net.sf.saxon.type
Class TypeHierarchy
- java.lang.Object
- 
- net.sf.saxon.type.TypeHierarchy
 
- 
- Direct Known Subclasses:
- TypeHierarchyEE
 
 public class TypeHierarchy extends java.lang.ObjectThis 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.
- 
- 
Field SummaryFields Modifier and Type Field Description protected Configurationconfig
 - 
Constructor SummaryConstructors Constructor Description TypeHierarchy(Configuration config)Create the type hierarchy cache for a configuration
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SequenceIteratorapplyFunctionCoercion(SequenceIterator iterator, ItemType suppliedItemType, ItemType requiredItemType, Location locator)Apply function coercion when a function item is supplied as a parameter in a function callSequenceapplyFunctionConversionRules(Sequence value, SequenceType requiredType, RoleDiagnostic role, Location locator)Apply the function conversion rules to a value, given a required type.protected AffinitycomputeContentRelationship(ItemType t1, ItemType t2, java.util.Optional<IntSet> n1, java.util.Optional<IntSet> n2)Compute the relationship between the allowed content-types of two types, for example attribute(*, xs:integer) and attribute(xs:string).ConfigurationgetConfiguration()Get the Saxon configuration to which this type hierarchy belongsItemTypegetGenericFunctionItemType()static AffinityinverseRelationship(Affinity relation)booleanisSubType(ItemType subtype, ItemType supertype)Determine whether type A is type B or one of its subtypes, recursively.Affinityrelationship(ItemType t1, ItemType t2)Determine the relationship of one item type to another.AffinityschemaTypeRelationship(SchemaType s1, SchemaType s2)Get the relationship of two schema types to each otherAffinitysequenceTypeRelationship(SequenceType s1, SequenceType s2)Get the relationship of two sequence types to each other
 
- 
- 
- 
Field Detail- 
configprotected Configuration config 
 
- 
 - 
Constructor Detail- 
TypeHierarchypublic TypeHierarchy(Configuration config) Create the type hierarchy cache for a configuration- Parameters:
- config- the configuration
 
 
- 
 - 
Method Detail- 
applyFunctionConversionRulespublic Sequence applyFunctionConversionRules(Sequence value, SequenceType requiredType, RoleDiagnostic role, Location locator) throws XPathException Apply the function conversion rules to a value, given a required type.- Parameters:
- value- a value to be converted
- requiredType- the required type
- role- identifies the value to be converted in error messages
- locator- identifies the location for error messages
- Returns:
- the converted value
- Throws:
- XPathException- if the value cannot be converted to the required type
 
 - 
applyFunctionCoercionprotected SequenceIterator applyFunctionCoercion(SequenceIterator iterator, ItemType suppliedItemType, ItemType requiredItemType, Location locator) Apply function coercion when a function item is supplied as a parameter in a function call- 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)
- locator- information for diagnostics
- Returns:
- an iterator over the converted value
 
 - 
getConfigurationpublic Configuration getConfiguration() Get the Saxon configuration to which this type hierarchy belongs- Returns:
- the configuration
 
 - 
isSubTypepublic 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
 
 - 
relationshippublic Affinity 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:
- One of:
 - Affinity.SAME_TYPEif the types are the same;
- Affinity.SUBSUMESif the first type subsumes the second (that is, all instances of the second type are also instances of the first);
- Affinity.SUBSUMED_BYif the second type subsumes the first;
- Affinity.OVERLAPSif the two types overlap (have a non-empty intersection, but neither subsumes the other);
- Affinity.DISJOINTif the two types are disjoint (have an empty intersection)
 
 
 - 
computeContentRelationshipprotected Affinity computeContentRelationship(ItemType t1, ItemType t2, java.util.Optional<IntSet> n1, java.util.Optional<IntSet> n2) Compute the relationship between the allowed content-types of two types, for example attribute(*, xs:integer) and attribute(xs:string). Note that although such types are fairly meaningless in a non-schema-aware environment, they are permitted, and supported in Saxon-HE.- 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)
 
 - 
sequenceTypeRelationshippublic Affinity sequenceTypeRelationship(SequenceType s1, SequenceType s2) Get the relationship of two sequence types to each other- Parameters:
- s1- the first type
- s2- the second type
- Returns:
- the relationship, as one of the constants
         Affinity.SAME_TYPE,Affinity.SUBSUMES,Affinity.SUBSUMED_BY,Affinity.DISJOINT,Affinity.OVERLAPS
 
 - 
schemaTypeRelationshippublic Affinity schemaTypeRelationship(SchemaType s1, SchemaType s2) Get the relationship of two schema types to each other- Parameters:
- s1- the first type
- s2- the second type
- Returns:
- the relationship of the two types, as one of the constants
         Affinity.SAME_TYPE,Affinity.SUBSUMES,Affinity.SUBSUMED_BY,Affinity.DISJOINT,Affinity.OVERLAPS
 
 - 
getGenericFunctionItemTypepublic ItemType getGenericFunctionItemType() 
 
- 
 
-