Package org.apache.uima.cas.impl
Class FeaturePathImpl
- java.lang.Object
-
- org.apache.uima.cas.impl.FeaturePathImpl
-
- All Implemented Interfaces:
FeaturePath
class FeaturePathImpl extends java.lang.Object implements FeaturePath
Implementation of the feature path interface.
-
-
Field Summary
Fields Modifier and Type Field Description private TypeImpl
boundBaseType
The Type used as the starting type for path validation This must be non-null if boundFeatures size > 0;private java.util.ArrayList<FeatureImpl>
boundFeatures
FeatureImpl array corresponding to feature path names.private static java.lang.String
BUILT_IN_FUNCTION_SEPARATOR
private byte
builtInFunction
The path's builtInFunction, or 0private static TOP
FEATURE_PATH_FAILED
private static java.lang.String
FEATURE_PATH_SEPARATOR
private java.util.ArrayList<java.lang.String>
featurePathElementNames
private static byte
FUNCTION_COVERED_TEXT
private static byte
FUNCTION_ID
private static java.lang.String
FUNCTION_NAME_COVERED_TEXT
private static java.lang.String
FUNCTION_NAME_ID
private static java.lang.String
FUNCTION_NAME_TYPE_NAME
private static byte
FUNCTION_TYPE_NAME
private static java.lang.String
MESSAGE_DIGEST
private static byte
NO_BUILT_IN_FUNCTION
private java.lang.String
originalBuiltInName
private boolean
pathStartsWithSlash
private FeatureImpl
targetFeature
private TypeImpl
targetType
-
Constructor Summary
Constructors Constructor Description FeaturePathImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addFeature(Feature feat)
Add a new feature at the end of the path.private void
appendBuiltInFunction(java.lang.StringBuilder sb)
private java.lang.String
evaluateBuiltInFunction(TOP returnFS)
evaluate the built-in function for the returned FeatureStructurejava.lang.Boolean
getBooleanValue(FeatureStructure fs)
Returns the Boolean value of a boolean valued feature path.java.lang.Byte
getByteValue(FeatureStructure fs)
Returns the Byte value of a byte valued feature path.java.lang.Double
getDoubleValue(FeatureStructure fs)
Returns the Double value of a double valued feature path.FeatureImpl
getFeature(int i)
Get feature at position.java.lang.String
getFeaturePath()
Returns the feature path as string.private java.lang.String
getFeaturePathString()
java.lang.Float
getFloatValue(FeatureStructure fs)
Returns the Float value of a float valued feature path.FeatureStructure
getFSValue(FeatureStructure fs)
Returns the FeatureStructure of a FeatureStructure valued feature path.java.lang.Integer
getIntValue(FeatureStructure fs)
Returns the Integer value of an integer valued feature path.java.lang.Long
getLongValue(FeatureStructure fs)
Returns the Long value of a long valued feature path.java.lang.Short
getShortValue(FeatureStructure fs)
Returns the Short value of a short valued feature path.java.lang.String
getStringValue(FeatureStructure fs)
Returns the String value of a string valued feature path.private TOP
getTargetFs(TOP fs)
evaluates the internal feature path for the given FeatureStructure returnsTypeClass
getTypClass(FeatureStructure fs)
Deprecated.Type
getType(FeatureStructure fs)
Returns the type of the feature path.TypeClass
getTypeClass(FeatureStructure fs)
Returns the type class of the feature path.java.lang.String
getValueAsString(FeatureStructure fs)
Returns the feature path value as string for the given FeatureStructure.void
initialize(java.lang.String featurePath)
Initialize the feature path object with the given feature path string.java.lang.String
ll_getValueAsString(int fsRef, LowLevelCAS llCas)
Returns the feature path value as string for the given FeatureStructure.private void
setTargetFeature(TOP currentFs, int i)
int
size()
Get length of path.private void
throwBuiltInFunctionException(java.lang.String typeName)
Method that throws the CASRuntimeException for an unsupported built-in functionvoid
typeInit(Type typeAtStartOfFeaturePath)
Check the feature path for the given type and initialize internal structures for faster access to the feature path value.private void
verifyNoBuiltInFunction()
-
-
-
Field Detail
-
MESSAGE_DIGEST
private static final java.lang.String MESSAGE_DIGEST
- See Also:
- Constant Field Values
-
FEATURE_PATH_SEPARATOR
private static final java.lang.String FEATURE_PATH_SEPARATOR
- See Also:
- Constant Field Values
-
BUILT_IN_FUNCTION_SEPARATOR
private static final java.lang.String BUILT_IN_FUNCTION_SEPARATOR
- See Also:
- Constant Field Values
-
NO_BUILT_IN_FUNCTION
private static final byte NO_BUILT_IN_FUNCTION
- See Also:
- Constant Field Values
-
FUNCTION_COVERED_TEXT
private static final byte FUNCTION_COVERED_TEXT
- See Also:
- Constant Field Values
-
FUNCTION_ID
private static final byte FUNCTION_ID
- See Also:
- Constant Field Values
-
FUNCTION_TYPE_NAME
private static final byte FUNCTION_TYPE_NAME
- See Also:
- Constant Field Values
-
FUNCTION_NAME_COVERED_TEXT
private static final java.lang.String FUNCTION_NAME_COVERED_TEXT
- See Also:
- Constant Field Values
-
FUNCTION_NAME_ID
private static final java.lang.String FUNCTION_NAME_ID
- See Also:
- Constant Field Values
-
FUNCTION_NAME_TYPE_NAME
private static final java.lang.String FUNCTION_NAME_TYPE_NAME
- See Also:
- Constant Field Values
-
FEATURE_PATH_FAILED
private static final TOP FEATURE_PATH_FAILED
-
builtInFunction
private byte builtInFunction
The path's builtInFunction, or 0
-
originalBuiltInName
private java.lang.String originalBuiltInName
-
featurePathElementNames
private final java.util.ArrayList<java.lang.String> featurePathElementNames
-
pathStartsWithSlash
private boolean pathStartsWithSlash
-
boundFeatures
private final java.util.ArrayList<FeatureImpl> boundFeatures
FeatureImpl array corresponding to feature path names. This can change for each evaluation of this FeaturePath instance against a different starting Feature Structure. It can be pre-set-up using typeInit. It has values for the first names in the featurePathElementNames which are always valid for a given starting type (set into boundBaseType).
-
targetFeature
private FeatureImpl targetFeature
-
targetType
private TypeImpl targetType
-
boundBaseType
private TypeImpl boundBaseType
The Type used as the starting type for path validation This must be non-null if boundFeatures size > 0;
-
-
Method Detail
-
addFeature
public void addFeature(Feature feat)
Description copied from interface:FeaturePath
Add a new feature at the end of the path.- Specified by:
addFeature
in interfaceFeaturePath
- Parameters:
feat
- The feature to be added.
-
getFeature
public FeatureImpl getFeature(int i)
Description copied from interface:FeaturePath
Get feature at position.- Specified by:
getFeature
in interfaceFeaturePath
- Parameters:
i
- The position in the path (starting at0
).- Returns:
- The feature, or
null
if there is no such feature.
-
size
public int size()
Description copied from interface:FeaturePath
Get length of path.- Specified by:
size
in interfaceFeaturePath
- Returns:
- An integer
>= 0
.
-
initialize
public void initialize(java.lang.String featurePath) throws CASException
Description copied from interface:FeaturePath
Initialize the feature path object with the given feature path string.- Specified by:
initialize
in interfaceFeaturePath
- Parameters:
featurePath
- The featurePath that is used for this feature path object.- Throws:
CASException
- Throws an exception if the feature path syntax is invalid.
-
typeInit
public void typeInit(Type typeAtStartOfFeaturePath) throws CASException
Description copied from interface:FeaturePath
Check the feature path for the given type and initialize internal structures for faster access to the feature path value.- Specified by:
typeInit
in interfaceFeaturePath
- Parameters:
typeAtStartOfFeaturePath
- The type the feature path should be used on.- Throws:
CASException
- Throws an exception if the feature path is not valid for the given type
-
getFeaturePath
public java.lang.String getFeaturePath()
Description copied from interface:FeaturePath
Returns the feature path as string.- Specified by:
getFeaturePath
in interfaceFeaturePath
- Returns:
- Returns the feature path as string.
-
getBooleanValue
public java.lang.Boolean getBooleanValue(FeatureStructure fs)
Description copied from interface:FeaturePath
Returns the Boolean value of a boolean valued feature path.- Specified by:
getBooleanValue
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path value- Returns:
- Returns the Boolean value of a boolean valued feature path or null if the feature path was not set
-
getByteValue
public java.lang.Byte getByteValue(FeatureStructure fs)
Description copied from interface:FeaturePath
Returns the Byte value of a byte valued feature path.- Specified by:
getByteValue
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path value- Returns:
- Returns the Byte value of a byte valued feature path or null if the feature path was not set
-
getDoubleValue
public java.lang.Double getDoubleValue(FeatureStructure fs)
Description copied from interface:FeaturePath
Returns the Double value of a double valued feature path.- Specified by:
getDoubleValue
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path value- Returns:
- Returns the Double value of a double valued feature path or null if the feature path was not set
-
getFloatValue
public java.lang.Float getFloatValue(FeatureStructure fs)
Description copied from interface:FeaturePath
Returns the Float value of a float valued feature path.- Specified by:
getFloatValue
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path value- Returns:
- Returns the Float value of a float valued feature path or null if the feature path was not set
-
getFSValue
public FeatureStructure getFSValue(FeatureStructure fs)
Description copied from interface:FeaturePath
Returns the FeatureStructure of a FeatureStructure valued feature path.- Specified by:
getFSValue
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path value- Returns:
- Returns the FeatureStructure value of a FeatureStructure valued feature path or null if the feature path was not set
-
getIntValue
public java.lang.Integer getIntValue(FeatureStructure fs)
Description copied from interface:FeaturePath
Returns the Integer value of an integer valued feature path.- Specified by:
getIntValue
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path value- Returns:
- Returns the Integer value of a integer valued feature path or null if the feature path was not set
-
getLongValue
public java.lang.Long getLongValue(FeatureStructure fs)
Description copied from interface:FeaturePath
Returns the Long value of a long valued feature path.- Specified by:
getLongValue
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path value- Returns:
- Returns the Long value of a long valued feature path or null if the feature path was not set
-
getShortValue
public java.lang.Short getShortValue(FeatureStructure fs)
Description copied from interface:FeaturePath
Returns the Short value of a short valued feature path.- Specified by:
getShortValue
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path value- Returns:
- Returns the Short value of a short valued feature path or null if the feature path was not set
-
getStringValue
public java.lang.String getStringValue(FeatureStructure fs)
Description copied from interface:FeaturePath
Returns the String value of a string valued feature path.- Specified by:
getStringValue
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path value- Returns:
- Returns the String value of a string valued feature path or null if the feature path was not set
-
getType
public Type getType(FeatureStructure fs)
Description copied from interface:FeaturePath
Returns the type of the feature path.- Specified by:
getType
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path type- Returns:
- Returns the type of the feature path or null if the feature path is not set.
-
getTypClass
@Deprecated public TypeClass getTypClass(FeatureStructure fs)
Deprecated.Description copied from interface:FeaturePath
Returns the type class of the feature path.- Specified by:
getTypClass
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path type class- Returns:
- Returns the type class of the feature path or null if the feature path is not set
-
getTypeClass
public TypeClass getTypeClass(FeatureStructure fs)
Description copied from interface:FeaturePath
Returns the type class of the feature path.- Specified by:
getTypeClass
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path type class- Returns:
- Returns the type class of the feature path or null if the feature path is not set
-
ll_getValueAsString
public java.lang.String ll_getValueAsString(int fsRef, LowLevelCAS llCas)
Description copied from interface:FeaturePath
Returns the feature path value as string for the given FeatureStructure. If the feature path contains a built-in function it is evaluated and the built-in function value is returned. If the feature path ends with an array the array is converted to a comma separated string.- Specified by:
ll_getValueAsString
in interfaceFeaturePath
- Parameters:
fsRef
- FeatureStructure reference (LowLevel API) to evaluate the feature path valuellCas
- LowLevelCAS for the fsRef- Returns:
- Returns the value of the feature path as String
-
getValueAsString
public java.lang.String getValueAsString(FeatureStructure fs)
Description copied from interface:FeaturePath
Returns the feature path value as string for the given FeatureStructure. If the feature path ends in a built-in function it is evaluated and the built-in function value is returned; this is the only method which evaluates built-in functions If the feature path ends with an array the array is converted to a comma separated string.- Specified by:
getValueAsString
in interfaceFeaturePath
- Parameters:
fs
- FeatureStructure to evaluate the feature path value- Returns:
- Returns the value of the feature path as String or null if the feature path was not set or some features along the path were null.
-
throwBuiltInFunctionException
private void throwBuiltInFunctionException(java.lang.String typeName)
Method that throws the CASRuntimeException for an unsupported built-in function- Parameters:
typeName
- type name that does not support the built-in function
-
evaluateBuiltInFunction
private java.lang.String evaluateBuiltInFunction(TOP returnFS)
evaluate the built-in function for the returned FeatureStructure- Parameters:
returnFS
- FeatureStructure that is returned- Returns:
- Returns the built-in function value for the given FS.
-
getTargetFs
private TOP getTargetFs(TOP fs)
evaluates the internal feature path for the given FeatureStructure returns- Parameters:
fs
- FeatureStructure to use as the starting point for the feature path- Returns:
- the Feature Structure result, or the Feature Structure to run feature or array extraction on, or the Feature Structure to run a built-in function on or null (meaning no fs was found that matched the path). For 0 element feature paths, this is the same as the argument. For null fs, the returned value is null;
-
setTargetFeature
private void setTargetFeature(TOP currentFs, int i)
-
verifyNoBuiltInFunction
private void verifyNoBuiltInFunction()
-
getFeaturePathString
private java.lang.String getFeaturePathString()
-
appendBuiltInFunction
private void appendBuiltInFunction(java.lang.StringBuilder sb)
-
-