net.sf.saxon.type

Class TypeHierarchy

Implemented Interfaces:
Serializable

public class TypeHierarchy
extends java.lang.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.

Field Summary

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

TypeHierarchy(Configuration config)
Create the type hierarchy cache for a configuration

Method Summary

Configuration
getConfiguration()
Get the Saxon configuration to which this type hierarchy belongs
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.
static int
schemaTypeRelationship(SchemaType s1, SchemaType s2)
Get the relationship of two schema types to each other

Field Details

DISJOINT

public static final int DISJOINT
Constant denoting relationship between two types: A is disjoint from B
Field Value:
4

OVERLAPS

public static final int OVERLAPS
Constant denoting relationship between two types: A overlaps B
Field Value:
3

SAME_TYPE

public static final int SAME_TYPE
Constant denoting relationship between two types: A is the same type as B
Field Value:
0

SUBSUMED_BY

public static final int SUBSUMED_BY
Constant denoting relationship between two types: A is subsumed by B
Field Value:
2

SUBSUMES

public static final int SUBSUMES
Constant denoting relationship between two types: A subsumes B
Field Value:
1

Constructor Details

TypeHierarchy

public TypeHierarchy(Configuration config)
Create the type hierarchy cache for a configuration
Parameters:
config - the configuration

Method Details

getConfiguration

public Configuration getConfiguration()
Get the Saxon configuration to which this type hierarchy belongs
Returns:
the configuration

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

isSubType

public boolean isSubType(ItemType subtype,
                         ItemType supertype)
Determine whether type A is type B or one of its subtypes, recursively
Parameters:
subtype - identifies the first type
supertype - identifies the second type
Returns:
true if the first type is the second type or a (direct or indirect) subtype of 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)

schemaTypeRelationship

public static int 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 SAME_TYPE, SUBSUMES, SUBSUMED_BY, DISJOINT