public class TypeSystemImpl extends Object implements TypeSystemMgr, LowLevelTypeSystem
Modifier and Type | Field and Description |
---|---|
static int |
annotSofaFeatCode |
static int |
booleanArrayTypeCode |
TypeImpl |
booleanType |
static int |
byteArrayTypeCode |
TypeImpl |
byteType |
static int |
doubleArrayTypeCode |
TypeImpl |
doubleType |
static int |
endFeatCode |
static int |
floatArrayTypeCode |
TypeImpl |
floatType |
static int |
fsArrayTypeCode |
static int |
intArrayTypeCode |
TypeImpl |
intType |
static int |
longArrayTypeCode |
TypeImpl |
longType |
static int |
shortArrayTypeCode |
TypeImpl |
shortType |
static int |
sofaIdFeatCode |
static int |
sofaNumFeatCode |
static int |
sofaStringFeatCode |
TypeImpl |
sofaType |
static int |
startFeatCode |
static int |
stringArrayTypeCode |
TypeImpl |
stringType |
Map<TypeSystemImpl,CasTypeSystemMapper> |
typeSystemMappers
Type Mapping Objects
used in compressed binary (de)serialization
These are in an identity map, key = target type system
Threading: this map is used by multiple threads
Key = target type system, via a weak reference.
|
FEATURE_SEPARATOR, NAMESPACE_SEPARATOR
UNKNOWN_FEATURE_CODE, UNKNOWN_TYPE_CODE
Constructor and Description |
---|
TypeSystemImpl() |
TypeSystemImpl(CASImpl cas)
Deprecated.
Use 0 arg constructor. Type Systems are shared by many CASes, and can't point to
one. Change also your possible calls to ts.commit() - see comment on that method.
|
Modifier and Type | Method and Description |
---|---|
Feature |
addFeature(String featureName,
Type domainType,
Type rangeType)
Add an feature to the type system.
|
Feature |
addFeature(String featureName,
Type domainType,
Type rangeType,
boolean multipleReferencesAllowed)
Add an feature to the type system.
|
Type |
addStringSubtype(String typeName,
String[] stringList)
Inherit from String.
|
Type |
addTopType(String name)
Add a top type to the (empty) type system.
|
Type |
addType(String typeName,
Type mother)
Add a new type to the type system.
|
void |
commit()
Commit the type system.
|
boolean |
directlySubsumes(int t1,
int t2) |
Type |
getArrayType(Type componentType)
Obtain an array type with component type
componentType . |
Vector<Type> |
getDirectlySubsumedTypes(Type type)
Get a vector of the types directly subsumed by a given type.
|
List<Type> |
getDirectSubtypes(Type type)
Get a List of the types directly subsumed by a given type.
|
Iterator<Type> |
getDirectSubtypesIterator(Type type) |
Feature |
getFeature(String featureName)
Deprecated.
|
Feature |
getFeatureByFullName(String featureName)
Get an feature object for a given name.
|
Iterator<Feature> |
getFeatures()
Get a list of features, in no particular order.
|
Vector<Feature> |
getIntroFeatures(Type type) |
int |
getLargestTypeCode() |
LowLevelTypeSystem |
getLowLevelTypeSystem()
Return the low-level view of this type system.
|
int |
getNumberOfFeatures()
Get the overall number of features defined in the type system.
|
int |
getNumberOfTypes()
Get the overall number of types defined in the type system.
|
Type |
getParent(Type t)
Get the parent type for input type.
|
List<Type> |
getProperlySubsumedTypes(Type type)
Return the list of all types subsumed by the input type.
|
String[] |
getStringSet(int i) |
Type |
getTopType()
Get the top type, i.e., the root of the type system.
|
Type |
getType(String typeName)
Get a type object for a given name.
|
Iterator<Type> |
getTypeIterator()
Get an iterator over all types, in no particular order.
|
TypeNameSpace |
getTypeNameSpace(String name)
Create a type name space object for the name parameter.
|
int |
intro(int feat) |
boolean |
isAnnotationBaseOrSubtype(int typeCode) |
boolean |
isAnnotationOrSubtype(int typeCode) |
boolean |
isApprop(int type,
int feat)
Check if feature is appropriate for type (i.e., type is subsumed by domain type of feature).
|
boolean |
isCommitted()
Check if this instance has been committed.
|
boolean |
isType(int type) |
int[] |
ll_getAppropriateFeatures(int type)
Get an array of the appropriate features for this type.
|
int |
ll_getArrayType(int componentTypeCode)
Get the type code for the array type with
componentTypeCode as component type
code. |
int |
ll_getCodeForFeature(Feature feature)
Get the code for a given feature object.
|
int |
ll_getCodeForFeatureName(String featureName)
Get the feature code for a given feature name.
|
int |
ll_getCodeForType(Type type)
Get the code of an existing type object.
|
int |
ll_getCodeForTypeName(String typeName)
Get the type code for a given type name.
|
int |
ll_getComponentType(int arrayTypeCode)
Get the component type of an array type code.
|
int |
ll_getDomainType(int featureCode)
Get the domain type for a given feature.
|
Feature |
ll_getFeatureForCode(int featureCode)
Get a feature object for a given code.
|
int |
ll_getParentType(int typeCode)
Get the parent type for the input type.
|
int |
ll_getRangeType(int featureCode)
Get the range type for a given feature.
|
String[] |
ll_getStringSet(int typeCode)
Get the string set (sorted) for a string subtype.
|
int |
ll_getTypeClass(int typeCode)
Determine the type class of a type.
|
Type |
ll_getTypeForCode(int typeCode)
Get a type object for a given code.
|
boolean |
ll_isArrayType(int typeCode)
Check if
typeCode is the type code of an array type. |
boolean |
ll_isPrimitiveType(int typeCode)
Check if
typeCode is the type code of a primitive type. |
boolean |
ll_isRefType(int typeCode)
Checks if the type code is that of a reference type (anything that's not a basic type,
currently Integer, String, Float, Boolean, Byte, Short, Long, Double,
and subtypes of String - specifying allowed-values).
|
boolean |
ll_isStringSubtype(int type)
Check if type is a string subtype.
|
boolean |
ll_isValidTypeCode(int typeCode)
Check the input type code.
|
boolean |
ll_subsumes(int superType,
int type)
Check subsumption between two types.
|
int |
range(int feat)
Get the range type for a feature.
|
void |
setFeatureFinal(Type type)
Make type feature final in the sense that no new features can be added to this type.
|
void |
setInheritanceFinal(Type type)
Block any further inheritance from this type.
|
boolean |
subsumes(int superType,
int type)
Check if the first argument subsumes the second
|
boolean |
subsumes(Type superType,
Type subType)
Does one type inherit from the other?
|
String |
toString()
This writes out the type hierarchy in a human-readable form.
|
int |
unify(int t1,
int t2) |
public TypeImpl intType
public TypeImpl stringType
public TypeImpl floatType
public TypeImpl sofaType
public TypeImpl byteType
public TypeImpl booleanType
public TypeImpl shortType
public TypeImpl longType
public TypeImpl doubleType
public static final int intArrayTypeCode
public static final int floatArrayTypeCode
public static final int stringArrayTypeCode
public static final int fsArrayTypeCode
public static final int byteArrayTypeCode
public static final int booleanArrayTypeCode
public static final int shortArrayTypeCode
public static final int longArrayTypeCode
public static final int doubleArrayTypeCode
public static final int sofaNumFeatCode
public static final int sofaIdFeatCode
public static final int sofaStringFeatCode
public static final int annotSofaFeatCode
public static final int startFeatCode
public static final int endFeatCode
public final Map<TypeSystemImpl,CasTypeSystemMapper> typeSystemMappers
@Deprecated public TypeSystemImpl(CASImpl cas)
cas
- -public TypeSystemImpl()
public Type getParent(Type t)
TypeSystem
getParent
in interface TypeSystem
t
- The type we want to know the parent of.null
for the top type.public int ll_getParentType(int typeCode)
LowLevelTypeSystem
ll_getParentType
in interface LowLevelTypeSystem
typeCode
- The type code we want the parent for.public boolean isApprop(int type, int feat)
type
- -feat
- -public final int getLargestTypeCode()
public boolean isType(int type)
public Type getType(String typeName)
getType
in interface TypeSystem
typeName
- The name of the type.null
if no such type exists.public Feature getFeatureByFullName(String featureName)
getFeatureByFullName
in interface TypeSystem
featureName
- The name of the feature.null
if no such feature exists.public Type addType(String typeName, Type mother) throws CASAdminException
addType
in interface TypeSystemMgr
typeName
- The name of the new type.mother
- The type node under which the new type should be attached.null
if typeName
is already in use.CASAdminException
- If typeName
is not a legal type name, type system is locked, or
mother
is inheritance final.public Feature addFeature(String featureName, Type domainType, Type rangeType) throws CASAdminException
TypeSystemMgr
addFeature
in interface TypeSystemMgr
featureName
- The name of the new feature.domainType
- The type that defines the domain of the feature.rangeType
- The type that defines the range of the feature.null
if featureName
is already
in use for domainType
with the same range (if the range is different, an
exception is thrown).CASAdminException
- If featureName
is not a legal feature name, the type system is
locked or domainType
is feature final. Also if
featureName
has already been defined on domainType
(or a supertype) with a different range than rangeType
.public Feature addFeature(String featureName, Type domainType, Type rangeType, boolean multipleReferencesAllowed) throws CASAdminException
TypeSystemMgr
addFeature
in interface TypeSystemMgr
featureName
- The name of the new feature.domainType
- The type that defines the domain of the feature.rangeType
- The type that defines the range of the feature.multipleReferencesAllowed
- If the rangeType
is an array type, you can use this flag to enforce
that the feature value is not referenced anywhere else. This is currently only used
for XMI serialization. Defaults to true
.null
if featureName
is already
in use for domainType
with the same range (if the range is different, an
exception is thrown).CASAdminException
- If featureName
is not a legal feature name, the type system is
locked or domainType
is feature final. Also if
featureName
has already been defined on domainType
(or a supertype) with a different range than rangeType
.TypeSystemMgr.addFeature(String, Type, Type)
public Iterator<Type> getTypeIterator()
getTypeIterator
in interface TypeSystem
public Iterator<Feature> getFeatures()
TypeSystem
getFeatures
in interface TypeSystem
public Type getTopType()
getTopType
in interface TypeSystem
public List<Type> getProperlySubsumedTypes(Type type)
getProperlySubsumedTypes
in interface TypeSystem
type
- Input type.type
.public Vector<Type> getDirectlySubsumedTypes(Type type)
getDirectlySubsumedTypes
in interface TypeSystem
type
- The input type.public List<Type> getDirectSubtypes(Type type)
TypeSystem
getDirectSubtypes
in interface TypeSystem
type
- The input type.public Iterator<Type> getDirectSubtypesIterator(Type type)
type
- whose direct instantiable subtypes to iterate overpublic boolean directlySubsumes(int t1, int t2)
public boolean subsumes(Type superType, Type subType)
subsumes
in interface TypeSystem
superType
- Supertype.subType
- Subtype.true
iff sub
inherits from super
.public int[] ll_getAppropriateFeatures(int type)
ll_getAppropriateFeatures
in interface LowLevelTypeSystem
type
- Input type code.typeCode
.public int getNumberOfFeatures()
public int getNumberOfTypes()
public int intro(int feat)
feat
- -public int range(int feat)
feat
- -public int unify(int t1, int t2)
public Type addTopType(String name)
name
- -public boolean subsumes(int superType, int type)
superType
- -type
- -public boolean ll_subsumes(int superType, int type)
LowLevelTypeSystem
ll_subsumes
in interface LowLevelTypeSystem
superType
- -type
- -true
iff type1
subsumes type2
.public String toString()
public void commit()
TypeSystemMgr
commit
in interface TypeSystemMgr
TypeSystemMgr.commit()
public boolean isCommitted()
TypeSystemMgr
isCommitted
in interface TypeSystemMgr
true
iff this instance has been committed.TypeSystemMgr.isCommitted()
public boolean isAnnotationBaseOrSubtype(int typeCode)
typeCode
- for a typepublic boolean isAnnotationOrSubtype(int typeCode)
typeCode
- for a type@Deprecated public Feature getFeature(String featureName)
public void setFeatureFinal(Type type)
TypeSystemMgr
setFeatureFinal
in interface TypeSystemMgr
type
- The type to be made feature final.TypeSystemMgr.setFeatureFinal(org.apache.uima.cas.Type)
public void setInheritanceFinal(Type type)
TypeSystemMgr
setInheritanceFinal
in interface TypeSystemMgr
type
- the type to block subtypes onTypeSystemMgr.setInheritanceFinal(org.apache.uima.cas.Type)
public Type addStringSubtype(String typeName, String[] stringList) throws CASAdminException
TypeSystemMgr
addStringSubtype
in interface TypeSystemMgr
typeName
- The name of the type to be created.stringList
- The list of legal string values for this string type.null
if the type is already defined.CASAdminException
- If the type system is locked.TypeSystemMgr.addStringSubtype(java.lang.String, java.lang.String[])
public String[] getStringSet(int i)
public TypeNameSpace getTypeNameSpace(String name)
TypeSystem
getTypeNameSpace
in interface TypeSystem
name
- The name of the name space.TypeNameSpace
object corresponding to name
, or
null
, if name
is not a legal type name space identifier.public int ll_getCodeForTypeName(String typeName)
LowLevelTypeSystem
ll_getCodeForTypeName
in interface LowLevelTypeSystem
typeName
- The name of the type.0
means that the a type of that
name does not exist in the type system.public int ll_getCodeForType(Type type)
LowLevelTypeSystem
ll_getCodeForType
in interface LowLevelTypeSystem
type
- A type object.public int ll_getCodeForFeatureName(String featureName)
LowLevelTypeSystem
ll_getCodeForFeatureName
in interface LowLevelTypeSystem
featureName
- The name of the feature.0
means that the name does
not represent a feature in the type system.public int ll_getCodeForFeature(Feature feature)
LowLevelTypeSystem
ll_getCodeForFeature
in interface LowLevelTypeSystem
feature
- A feature object.public Type ll_getTypeForCode(int typeCode)
LowLevelTypeSystem
ll_getTypeForCode
in interface LowLevelTypeSystem
typeCode
- The code of the type.null
if typeCode
is not a valid type
code.public Feature ll_getFeatureForCode(int featureCode)
LowLevelTypeSystem
ll_getFeatureForCode
in interface LowLevelTypeSystem
featureCode
- The code of the feature.null
if featureCode
is not a valid
feature code.public int ll_getDomainType(int featureCode)
LowLevelTypeSystem
ll_getDomainType
in interface LowLevelTypeSystem
featureCode
- Input feature code.featureCode
.public int ll_getRangeType(int featureCode)
LowLevelTypeSystem
ll_getRangeType
in interface LowLevelTypeSystem
featureCode
- Input feature code.featureCode
.public LowLevelTypeSystem getLowLevelTypeSystem()
TypeSystem
getLowLevelTypeSystem
in interface TypeSystem
LowLevelTypeSystem
version of
this type system.public boolean ll_isStringSubtype(int type)
LowLevelTypeSystem
ll_isStringSubtype
in interface LowLevelTypeSystem
type
- The type to be checked.true
iff type
is a subtype of String.public boolean ll_isRefType(int typeCode)
LowLevelTypeSystem
ll_isRefType
in interface LowLevelTypeSystem
typeCode
- The type code to check.true
iff typeCode
is the type code of a reference type.public Type getArrayType(Type componentType)
TypeSystem
componentType
.getArrayType
in interface TypeSystem
componentType
- The type of the elements of the resulting array type. This can be any type, even
another array type.public final int ll_getTypeClass(int typeCode)
LowLevelTypeSystem
TYPE_CLASS_INVALID
-- Not a valid type code.TYPE_CLASS_INT
-- Integer type. TYPE_CLASS_FLOAT
-- Float type.TYPE_CLASS_STRING
-- String type.TYPE_CLASS_INTARRAY
-- Integer array.TYPE_CLASS_FLOATARRAY
-- Float array.TYPE_CLASS_STRINGARRAY
-- String array.TYPE_CLASS_FSARRAY
-- FS array.TYPE_CLASS_FS
-- FS type, i.e., all other types, including all user-defined
types.ll_getTypeClass
in interface LowLevelTypeSystem
typeCode
- The type code.TYPE_CLASS_INVALID
if the type code
argument does not represent a valid type code.public int ll_getArrayType(int componentTypeCode)
LowLevelTypeSystem
componentTypeCode
as component type
code.ll_getArrayType
in interface LowLevelTypeSystem
componentTypeCode
- The type code of the component type.UNKNOWN_TYPE_CODE
if componentTypeCode
is not
a valid type code.public boolean ll_isValidTypeCode(int typeCode)
LowLevelTypeSystem
ll_isValidTypeCode
in interface LowLevelTypeSystem
typeCode
- Type code to check.true
iff typeCode
is a valid type code.public boolean ll_isArrayType(int typeCode)
LowLevelTypeSystem
typeCode
is the type code of an array type.ll_isArrayType
in interface LowLevelTypeSystem
typeCode
- The type code to check.true
iff typeCode
is an array type code.public int ll_getComponentType(int arrayTypeCode)
LowLevelTypeSystem
ll_getComponentType
in interface LowLevelTypeSystem
arrayTypeCode
- The input array type code.UNKNOWN_TYPE_CODE
if arrayTypeCode
is not valid or not an array type.public boolean ll_isPrimitiveType(int typeCode)
LowLevelTypeSystem
typeCode
is the type code of a primitive type.ll_isPrimitiveType
in interface LowLevelTypeSystem
typeCode
- The type code to check.true
iff typeCode
is a primitive type code.public String[] ll_getStringSet(int typeCode)
LowLevelTypeSystem
ll_getStringSet
in interface LowLevelTypeSystem
typeCode
- Input type code; should be a string subtype.null
.Copyright © 2006–2021 The Apache Software Foundation. All rights reserved.