Interface JCas
- All Superinterfaces:
AbstractCas
- All Known Implementing Classes:
JCasImpl
A JCas
object provides the starting point for working with the CAS using Java Cover
Classes for each type, generated by the utility JCasGen.
This interface extends the CAS Interface, providing all the same functionality, plus some specific to the JCas.
It supports the creation of new instances of CAS types, using the normal Java "new" operator.
You can create a JCas
object from a CAS object by calling the getJCas() method on
the CAS object.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a feature structure to all appropriate indexes in the repository associated with this CAS View.default void
checkArrayBounds
(int fsRef, int pos) Create a feature path.createFeatureValuePath
(String featureValuePath) Create a feature-value path from a string.<T extends FeatureStructure>
FSIterator<T>createFilteredIterator
(FSIterator<T> it, FSMatchConstraint cons) Create an iterator over structures satisfying a given constraint.createSofa
(SofaID sofaID, String mimeType) Deprecated.createView
(String sofaID) Create a view and its underlying Sofa (subject of analysis).default <T extends TOP>
CommonArrayFSemptyArray
(Class<T> clazz) default BooleanArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance.default ByteArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance.default DoubleArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance.default FloatArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance.default EmptyFloatList
default FSArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance.emptyFSArray
(Class<T> clazz) Retrieve a lazily-created constant from the cas which holds a 0-length instance of a subtype of FSArray.default <T extends TOP>
EmptyFSList<T>default IntegerArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance.default EmptyIntegerList
default LongArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance.default ShortArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance.default StringArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance.default EmptyStringList
<T extends FeatureStructure>
ListIterator<T>fs2listIterator
(FSIterator<T> it) Wrap a standard JavaListIterator
around an FSListIterator.<T extends TOP>
FSIterator<T>getAllIndexedFS
(Class<T> clazz) Gets an iterator over all indexed FeatureStructures of the specified Type (and any of its subtypes).default <T extends TOP>
FSIterator<T>getAllIndexedFS
(Type type) Gets an iterator over all indexed FeatureStructures of the specified Type (and any of its subtypes).Get the standard annotation index.<T extends Annotation>
AnnotationIndex<T>getAnnotationIndex
(int type) Get the standard annotation index restricted to a specific annotation type.<T extends Annotation>
AnnotationIndex<T>getAnnotationIndex
(Class<T> clazz) Get the standard annotation index restricted to a specific annotation type.<T extends Annotation>
AnnotationIndex<T>getAnnotationIndex
(Type type) Get the standard annotation index restricted to a specific annotation type.getCas()
getCasType
(int i) Given Foo.type, return the corresponding CAS Type object.getCasType
(Class<? extends FeatureStructure> clazz) Return the UIMA Type object corresponding to this JCas's JCas cover class (Note: different JCas's, with different type systems, may share the same cover class impl)Get a constraint factory.Gets the document annotation.Gets the language code for this document from the language feature of the special instance of the DocumentationAnnotation associated with this CAS.Get the document text.default FloatArray
Deprecated.renamed emptyXXXArraydefault FSArray
Deprecated.renamed emptyXXXArrayRetrieve an index according to a label and a type specified using a JCas class.default Collection<TOP>
Returns an unmodifiable collection of all of the FSs that are indexed in this view, in an arbitrary order.default <T extends TOP>
Collection<T>getIndexedFSs
(Class<T> clazz) Returns an unmodifiable collection of all the FSs that are indexed in this view, in an arbitrary order.default <T extends TOP>
Collection<T>getIndexedFSs
(Type type) Returns an unmodifiable collection of all the FSs that are indexed in this view, in an arbitrary order.Get the index repository.default IntegerArray
Deprecated.renamed emptyXXXArrayCreate a JCas view for a Sofa.default <T extends TOP>
TgetJfsFromCaddr
(int casAddr) Gets the JCas-based interface to the Index Repository.getRequiredFeature
(Type t, String s) default Feature
getRequiredFeatureDE
(Type t, String s, String rangeName, boolean featOkTst) Deprecated.getSofa()
Get the Sofa feature structure associated with this JCas view.Deprecated.As of v2.0, use {#getView(String)}.Get the Sofa data array.Get the Sofa data as a byte stream.Get the Sofa Data String (a.k.a.Get the Sofa data array.Get iterator for all SofaFS in the CAS.Get the mime type of the Sofa data being analyzed.default StringArray
Deprecated.renamed emptyXXXArraygetType
(int i) Backwards Compatibility only - throws unsupported operation exception In UIMA V2, this previously got the JCas _Type instance for a particular CAS type constant In UIMA V3, there is no _Type instance, so this throws an exceptionDeprecated.use instance.jcasType instead - fasterReturn the type system of this CAS instance.Get the view for a Sofa (subject of analysis).Get the view for a Sofa (subject of analysis).Get iterator over all views in this JCas.getViewIterator
(String localViewNamePrefix) Get iterator over all views with the given name prefix.Get the view name.void
Deprecated.not required, does nothingCall this method to set up a region, ended by a close() call on the returned object, You can use this or theprotectIndexes(Runnable)
method to protected the indexes.void
protectIndexes
(Runnable runnable) Runs the code in the runnable inside a protection block, where any modifications to features done while in this block will be done in a way to protect any indexes which otherwise might become corrupted by the update action; the protection is achieved by temporarily removing the FS (if it is in the indexes), before the update happens.default void
putJfsFromCaddr
(int casAddr, FeatureStructure fs) Deprecated.void
removeAllExcludingSubtypes
(int i) Remove all feature structures of a given type (excluding subtypes) from all indexes in the repository associated with this CAS View.default <T extends TOP>
voidremoveAllExcludingSubtypes
(Class<T> clazz) Remove all instances of just this type, excluding subtypes, from all indexes in the repository view.void
removeAllIncludingSubtypes
(int i) Remove all feature structures of a given type (including subtypes) from all indexes in the repository associated with this CAS View.default <T extends TOP>
voidremoveAllIncludingSubtypes
(Class<T> clazz) Remove all instances of type, including all subtypes from all indexes in the repository view.void
Remove a feature structure from all indexes in the repository associated with this CAS View.void
reset()
Reset the CAS, emptying it of all content.select()
select
(int jcasType) void
setDocumentLanguage
(String languageCode) Sets the language for this document.void
setDocumentText
(String text) Set the document text.void
setSofaDataArray
(FeatureStructure array, String mime) Set the Sofa data as an ArrayFS.void
setSofaDataString
(String text, String mimetype) Set the document text.void
setSofaDataURI
(String uri, String mime) Set the Sofa data as a URI.int
size()
Estimate the memory consumption of this CAS instance (in bytes).default void
throwFeatMissing
(String feat, String type) Methods inherited from interface org.apache.uima.cas.AbstractCas
release
-
Field Details
-
INVALID_FEATURE_CODE
static final int INVALID_FEATURE_CODE(internal use)- See Also:
-
-
Method Details
-
getFSIndexRepository
FSIndexRepository getFSIndexRepository()- Returns:
- the FSIndexRepository object for this Cas
-
getLowLevelIndexRepository
LowLevelIndexRepository getLowLevelIndexRepository() -
getCas
CAS getCas()- Returns:
- the CAS object for this JCas instantiation
-
getCasImpl
CASImpl getCasImpl() -
getLowLevelCas
LowLevelCAS getLowLevelCas() -
getType
Backwards Compatibility only - throws unsupported operation exception In UIMA V2, this previously got the JCas _Type instance for a particular CAS type constant In UIMA V3, there is no _Type instance, so this throws an exception- Parameters:
i
- the CAS type constant, written as Foo.type- Returns:
- none - throws an exception
-
getType
Deprecated.use instance.jcasType instead - fasterget the JCas x_Type instance for a particular Java instance of a type- Parameters:
instance
- instance- Returns:
- the associated xxx_Type instance
-
getCasType
Given Foo.type, return the corresponding CAS Type object. This is useful in the methods which require a CAS Type, for instance iterator creation.- Parameters:
i
- - index returned by Foo.type- Returns:
- the CAS Java Type object for this CAS Type.
-
getRequiredType
- Throws:
CASException
-
getRequiredFeature
- Throws:
CASException
-
getRequiredFeatureDE
@Deprecated default Feature getRequiredFeatureDE(Type t, String s, String rangeName, boolean featOkTst) Deprecated. -
putJfsFromCaddr
Deprecated. -
getJfsFromCaddr
-
checkArrayBounds
default void checkArrayBounds(int fsRef, int pos) -
throwFeatMissing
-
getSofa
Deprecated.As of v2.0, use {#getView(String)}. From the view you can access the Sofa data, or callgetSofa()
if you truly need to access the SofaFS object.- Parameters:
sofaID
- -- Returns:
- the Sofa
-
getSofa
Sofa getSofa()Get the Sofa feature structure associated with this JCas view.- Returns:
- The SofaFS associated with this JCas view.
-
createView
Create a view and its underlying Sofa (subject of analysis). The view provides access to the Sofa data and the index repository that contains metadata (annotations and other feature structures) pertaining to that Sofa.This method creates the underlying Sofa feature structure, but does not set the Sofa data. Setting ths Sofa data must be done by calling
setSofaDataArray(FeatureStructure, String)
,setSofaDataString(String, String)
orsetSofaDataURI(String, String)
on the JCas view returned by this method.- Parameters:
sofaID
- the local view name, before any sofa name mapping is done, for this view (note: this is the same as the associated Sofa name).- Returns:
- The view corresponding to this local name.
- Throws:
CASException
- - if a View with this name already exists in this CAS
-
getJCas
Create a JCas view for a Sofa.- Parameters:
sofa
- a Sofa feature structure in this CAS.- Returns:
- The JCas view for the given Sofa.
- Throws:
CASException
- -
-
getJFSIndexRepository
JFSIndexRepository getJFSIndexRepository()Gets the JCas-based interface to the Index Repository. Provides the same functionality asgetFSIndexRepository()
except that the methods that take a "type" argument take type arguments obtainable easily from the JCas type.- Returns:
- the JCas-based interface to the index repository
-
getDocumentAnnotationFs
TOP getDocumentAnnotationFs()Gets the document annotation. The object returned from this method can be typecast to org.apache.uima.jcas.tcas.DocumentAnnotation if that class is loaded (it may not be...)The reason that the return type of this method is not DocumentAnnotation is because that class may not be loaded, or it may be loaded under a different class loader when using the UIMA Extension ClassLoader to load annotator classes.
- Returns:
- The one instance of the DocumentAnnotation annotation.
- See Also:
-
getStringArray0L
Deprecated.renamed emptyXXXArrayA constant for each cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same valuee because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset.- Returns:
- 0-length instance of a StringArray
-
emptyStringArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset.- Returns:
- 0-length instance of a StringArray
-
getIntegerArray0L
Deprecated.renamed emptyXXXArrayRetrieve a lazily-created constant from the cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset.- Returns:
- 0-length instance of an IntegerArray
-
emptyIntegerArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset.- Returns:
- 0-length instance of an IntegerArray
-
getFloatArray0L
Deprecated.renamed emptyXXXArrayRetrieve a lazily-created constant from the cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset.- Returns:
- 0-length instance of a FloatArray
-
emptyFloatArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset.- Returns:
- 0-length instance of a FloatArray
-
getFSArray0L
Deprecated.renamed emptyXXXArrayRetrieve a lazily-created constant from the cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset. See also the CAS API- Returns:
- 0-length instance of a FSArray
-
emptyFSArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset. See also the CAS API- Returns:
- 0-length instance of a FSArray
-
emptyFSArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance of a subtype of FSArray. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset. See also the CAS API- Type Parameters:
T
- the particular FeatureStructure type- Parameters:
clazz
- the class of the component type the array is to contain- Returns:
- 0-length instance of a FSArray, which is associated with the element type T
-
emptyByteArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset.- Returns:
- 0-length instance of a ByteArray
-
emptyShortArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset.- Returns:
- 0-length instance of a ShortArray
-
emptyLongArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset.- Returns:
- 0-length instance of a LongArray
-
emptyDoubleArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset.- Returns:
- 0-length instance of a DoubleArray
-
emptyBooleanArray
Retrieve a lazily-created constant from the cas which holds a 0-length instance. Since this can be a common value, we avoid creating multiple copies of it. All uses can use the same value because it is not updatable (it has no subfields). This is initialized lazily on first reference, and reset when the CAS is reset.- Returns:
- 0-length instance of a DoubleArray
-
processInit
Deprecated.not required, does nothinginitialize the JCas for new Cas content. Not used, does nothing. -
getView
Get the view for a Sofa (subject of analysis). The view provides access to the Sofa data and the index repository that contains metadata (annotations and other feature structures) pertaining to that Sofa.- Parameters:
localViewName
- the local name, before any sofa name mapping is done, for this view (note: this is the same as the associated Sofa name).- Returns:
- The view corresponding to this local name.
- Throws:
CASException
- passthru
-
getView
Get the view for a Sofa (subject of analysis). The view provides access to the Sofa data and the index repository that contains metadata (annotations and other feature structures) pertaining to that Sofa.- Parameters:
aSofa
- a Sofa feature structure in the CAS- Returns:
- The view for the given Sofa
- Throws:
CASException
- passthru
-
getTypeSystem
Return the type system of this CAS instance.- Returns:
- The type system, or
null
if none is available. - Throws:
CASRuntimeException
- If the type system has not been committed.
-
createSofa
Deprecated.As of v2.0, usecreateView(String)
instead.Create a Subject of Analysis. The new sofaFS is automatically added to the SofaIndex.- Parameters:
sofaID
- the SofA IDmimeType
- the mime type- Returns:
- The sofaFS.
-
getSofaIterator
FSIterator<SofaFS> getSofaIterator()Get iterator for all SofaFS in the CAS.- Returns:
- an iterator over SofaFS.
-
createFilteredIterator
<T extends FeatureStructure> FSIterator<T> createFilteredIterator(FSIterator<T> it, FSMatchConstraint cons) Create an iterator over structures satisfying a given constraint. Constraints are described in the javadocs forConstraintFactory
and related classes.- Type Parameters:
T
- the particular FeatureStructure type- Parameters:
it
- The input iterator.cons
- The constraint specifying what structures should be returned.- Returns:
- An iterator over FSs.
-
getConstraintFactory
ConstraintFactory getConstraintFactory()Get a constraint factory. A constraint factory is a simple way of creatingFSMatchConstraints
.- Returns:
- A constraint factory to create new FS constraints.
-
createFeaturePath
FeaturePath createFeaturePath()Create a feature path. This is mainly useful for creatingFSMatchConstraints
.- Returns:
- A new, empty feature path.
-
getIndexRepository
FSIndexRepository getIndexRepository()Get the index repository.- Returns:
- The index repository, or
null
if none is available.
-
fs2listIterator
Wrap a standard JavaListIterator
around an FSListIterator. Use if you feel more comfortable with java style iterators.- Type Parameters:
T
- The particular Feature Structure type- Parameters:
it
- TheFSListIterator
to be wrapped.- Returns:
- An equivalent
ListIterator
.
-
reset
Reset the CAS, emptying it of all content. Feature structures and iterators will no longer be valid. Note: this method may only be called from an application. Calling it from an annotator will trigger a runtime exception.- Throws:
CASRuntimeException
- When called out of sequence.CASAdminException
- See Also:
-
getViewName
String getViewName()Get the view name. The view name is the same as the name of the view's Sofa, retrieved by getSofa().getSofaID(), except for the initial View before its Sofa has been created.- Returns:
- The name of the view
-
size
int size()Estimate the memory consumption of this CAS instance (in bytes).- Returns:
- The estimated memory used by this CAS instance.
-
createFeatureValuePath
Create a feature-value path from a string.- Parameters:
featureValuePath
- String representation of the feature-value path.- Returns:
- Feature-value path object.
- Throws:
CASRuntimeException
- If the input string is not well-formed.
-
setDocumentText
Set the document text. Once set, Sofa data is immutable, and cannot be set again until the CAS has been reset.- Parameters:
text
- The text to be analyzed.- Throws:
CASRuntimeException
- If the Sofa data has already been set.
-
setSofaDataString
Set the document text. Once set, Sofa data is immutable, and cannot be set again until the CAS has been reset.- Parameters:
text
- The text to be analyzed.mimetype
- The mime type of the data- Throws:
CASRuntimeException
- If the Sofa data has already been set.
-
getDocumentText
String getDocumentText()Get the document text.- Returns:
- The text being analyzed.
-
getSofaDataString
String getSofaDataString()Get the Sofa Data String (a.k.a. the document text).- Returns:
- The Sofa data string.
-
setDocumentLanguage
Sets the language for this document. This value sets the language feature of the special instance of DocumentAnnotation associated with this CAS.- Parameters:
languageCode
- the language code- Throws:
CASRuntimeException
- passthru
-
getDocumentLanguage
String getDocumentLanguage()Gets the language code for this document from the language feature of the special instance of the DocumentationAnnotation associated with this CAS.- Returns:
- language identifier
-
setSofaDataArray
Set the Sofa data as an ArrayFS. Once set, Sofa data is immutable, and cannot be set again until the CAS has been reset.- Parameters:
array
- The ArrayFS to be analyzed.mime
- The mime type of the data- Throws:
CASRuntimeException
- If the Sofa data has already been set.
-
getSofaDataArray
FeatureStructure getSofaDataArray()Get the Sofa data array.- Returns:
- The Sofa Data being analyzed.
-
setSofaDataURI
Set the Sofa data as a URI. Once set, Sofa data is immutable, and cannot be set again until the CAS has been reset.- Parameters:
uri
- The URI of the data to be analyzed.mime
- The mime type of the data- Throws:
CASRuntimeException
- If the Sofa data has already been set.
-
getSofaDataURI
String getSofaDataURI()Get the Sofa data array.- Returns:
- The Sofa Data being analyzed.
-
getSofaDataStream
InputStream getSofaDataStream()Get the Sofa data as a byte stream.- Returns:
- A stream handle to the Sofa Data.
-
getSofaMimeType
String getSofaMimeType()Get the mime type of the Sofa data being analyzed.- Returns:
- the mime type of the Sofa
-
addFsToIndexes
Add a feature structure to all appropriate indexes in the repository associated with this CAS View.Important: after you have called
addFsToIndexes(...)
on a FS, do not change the values of any features used for indexing. If you do, the index will become corrupted and may be unusable. If you need to change an index feature value, first callremoveFsFromIndexes(...)
on the FS, change the feature values, then calladdFsToIndexes(...)
again.- Parameters:
fs
- The Feature Structure to be added.- Throws:
NullPointerException
- If thefs
parameter isnull
.
-
removeFsFromIndexes
Remove a feature structure from all indexes in the repository associated with this CAS View.- Parameters:
fs
- The Feature Structure to be removed.- Throws:
NullPointerException
- If thefs
parameter isnull
.
-
removeAllIncludingSubtypes
void removeAllIncludingSubtypes(int i) Remove all feature structures of a given type (including subtypes) from all indexes in the repository associated with this CAS View.- Parameters:
i
- the CAS type constant, written as Foo.type (for a given JCas Type) or anInstanceOfFoo.getTypeIndexID(), for an instance
-
removeAllIncludingSubtypes
Remove all instances of type, including all subtypes from all indexes in the repository view.- Type Parameters:
T
- the type to remove- Parameters:
clazz
- the JCas class of the type to remove. To remove all use TOP.class- Throws:
NullPointerException
- if theclazz
parameter isnull
.
-
removeAllExcludingSubtypes
void removeAllExcludingSubtypes(int i) Remove all feature structures of a given type (excluding subtypes) from all indexes in the repository associated with this CAS View.- Parameters:
i
- the CAS type constant, written as Foo.type (for a given JCas Type) or anInstanceOfFoo.getTypeIndexID(), for an instance
-
removeAllExcludingSubtypes
Remove all instances of just this type, excluding subtypes, from all indexes in the repository view.- Type Parameters:
T
- the type to remove- Parameters:
clazz
- the JCas Class of the type to remove- Throws:
NullPointerException
- if thetype
parameter isnull
.
-
getCasType
Return the UIMA Type object corresponding to this JCas's JCas cover class (Note: different JCas's, with different type systems, may share the same cover class impl)- Parameters:
clazz
- a JCas cover class- Returns:
- the corresponding UIMA Type object
-
getAnnotationIndex
AnnotationIndex<Annotation> getAnnotationIndex()Get the standard annotation index.- Returns:
- The standard annotation index.
-
getAnnotationIndex
Get the standard annotation index restricted to a specific annotation type.- Type Parameters:
T
- the Java class corresponding to type- Parameters:
type
- The annotation type the index is restricted to.- Returns:
- The standard annotation index, restricted to
type
. - Throws:
CASRuntimeException
-
getAnnotationIndex
Get the standard annotation index restricted to a specific annotation type.- Type Parameters:
T
- the Java class corresponding to type- Parameters:
type
- The annotation type the index is restricted to, passed as an integer using the form MyAnnotationType.type- Returns:
- The standard annotation index, restricted to
type
. - Throws:
CASRuntimeException
- -
-
getAnnotationIndex
<T extends Annotation> AnnotationIndex<T> getAnnotationIndex(Class<T> clazz) throws CASRuntimeException Get the standard annotation index restricted to a specific annotation type.- Type Parameters:
T
- the Java class clazz- Parameters:
clazz
- The JCas cover class for the annotation type the index is restricted to,- Returns:
- The standard annotation index, restricted to
type
. - Throws:
CASRuntimeException
- -
-
getAllIndexedFS
Gets an iterator over all indexed FeatureStructures of the specified Type (and any of its subtypes). The elements are returned in arbitrary order, and duplicates (if they exist) are not removed.- Type Parameters:
T
- the Java clazz of the returned types- Parameters:
type
- - the type specifying which type and subtypes are included- Returns:
- An iterator that returns all indexed FeatureStructures of the JCas clazz and its subtypes, in no particular order.
-
getAllIndexedFS
Gets an iterator over all indexed FeatureStructures of the specified Type (and any of its subtypes). The elements are returned in arbitrary order, and duplicates (if they exist) are not removed.- Type Parameters:
T
- the Java clazz- Parameters:
clazz
- - the JCas Java class specifing which type and subtypes are included- Returns:
- An iterator that returns all indexed FeatureStructures of the JCas clazz and its subtypes, in no particular order.
-
getIndexedFSs
Returns an unmodifiable collection of all the FSs that are indexed in this view, in an arbitrary order. Subsequent modifications to the indexes do not affect this collection.- Type Parameters:
T
- The Java class associated with type- Parameters:
type
- the type of Feature Structures to include (including subtypes)- Returns:
- an unmodifiable, unordered collection of all indexed (in this view) Feature Structures of the specified type (including subtypes)
-
getIndexedFSs
Returns an unmodifiable collection of all the FSs that are indexed in this view, in an arbitrary order. Subsequent modifications to the indexes do not affect this collection.- Type Parameters:
T
- The Java class associated with type- Parameters:
clazz
- The JCas class corresponding to the type- Returns:
- an unmodifiable, unordered collection of all indexed (in this view) Feature Structures of the specified type (including subtypes)
-
getIndexedFSs
Returns an unmodifiable collection of all of the FSs that are indexed in this view, in an arbitrary order. Subsequent modifications to the indexes do not affect this collection.- Returns:
- an unmodifiable, unordered collection of all indexed (in this view) Feature Structures of the specified type (including subtypes)
-
getViewIterator
Get iterator over all views in this JCas. Each view provides access to Sofa data and the index repository that contains metadata (annotations and other feature structures) pertaining to that Sofa.- Returns:
- an iterator which returns all views. Each object returned by the iterator is of type JCas.
- Throws:
CASException
- -
-
getViewIterator
Get iterator over all views with the given name prefix. Each view provides access to Sofa data and the index repository that contains metadata (annotations and other feature structures) pertaining to that Sofa.When passed the prefix namePrefix, the iterator will return all views who name is either exactly equal to namePrefix or is of the form namePrefix
.
suffix, where suffix can be any String.- Parameters:
localViewNamePrefix
- the local name prefix, before any sofa name mapping is done, for this view (note: this is the same as the associated Sofa name prefix).- Returns:
- an iterator which returns all views with the given name prefix. Each object returned by the iterator is of type JCas.
- Throws:
CASException
- -
-
protectIndexes
AutoCloseable protectIndexes()Call this method to set up a region, ended by a close() call on the returned object, You can use this or theprotectIndexes(Runnable)
method to protected the indexes.This approach allows arbitrary code between the protectIndexes and the associated close method.
The close method is best done in a finally block, or using the try-with-resources statement in Java 8.
- Returns:
- an object used to record things that need adding back
-
protectIndexes
Runs the code in the runnable inside a protection block, where any modifications to features done while in this block will be done in a way to protect any indexes which otherwise might become corrupted by the update action; the protection is achieved by temporarily removing the FS (if it is in the indexes), before the update happens. At the end of the block, affected indexes have any removed-under-the-covers FSs added back.- Parameters:
runnable
- code to execute while protecting the indexes.
-
getIndex
Retrieve an index according to a label and a type specified using a JCas class. The type is used to narrow down the index of a more general type to a more specific one. Generics: T is the associated Java cover class for the type.- Type Parameters:
T
- the Java clazz- Parameters:
label
- The name of the index.clazz
- The JCas class (mostly likely written as MyJCasClass.class), which must correspond to a subtype of the type of the index.- Returns:
- The specified, or
null
if an index with that name doesn't exist. - Throws:
CASRuntimeException
- Whenclazz
doesn't correspond to a subtype of the index's type.
-
select
- Type Parameters:
T
- the Type of the elements being accessed- Returns:
- a newly created selection object for accessing feature structures
-
select
- Type Parameters:
N
- the Type of the elements being accessed- Parameters:
type
- specifies the type (and subtypes of that type) to access- Returns:
- a newly created selection object for accessing feature structures of that type and its subtypes
- Throws:
IllegalArgumentException
- if no type is specified.
-
select
- Type Parameters:
N
- the Type of the elements being accessed- Parameters:
clazz
- a JCas class corresponding to the type (and subtypes of that type) to access- Returns:
- a newly created selection object for accessing feature structures of that type and its subtypes
- Throws:
IllegalArgumentException
- if no type is specified.
-
select
- Type Parameters:
N
- the Type of the elements being accessed- Parameters:
jcasType
- the "type" field from the JCas class corresponding to the type (and subtypes of that type) to access- Returns:
- a newly created selection object for accessing feature structures of that type and its subtypes
-
select
- Type Parameters:
N
- the Type of the elements being accessed- Parameters:
fullyQualifiedTypeName
- the string name of the type to access- Returns:
- a newly created selection object for accessing feature structures of that type and its subtypes
- Throws:
IllegalArgumentException
- if no type is specified.
-
emptyList
- Type Parameters:
T
- the type of the list, e.g FloatList- Parameters:
clazz
- the JCas class of the list, e.g. FloatList.class- Returns:
- - the shared (in this CAS) instance of the empty list (immutable)
-
emptyFloatList
- Returns:
- a lazily created shared (for this CAS) empty list
-
emptyFSList
- Type Parameters:
T
- the type of the FeatureStructures in the FSList- Returns:
- a lazily created shared (for this CAS) empty list
-
emptyIntegerList
- Returns:
- a lazily created shared (for this CAS) empty list
-
emptyStringList
- Returns:
- a lazily created shared (for this CAS) empty list
-
emptyArray
- Type Parameters:
T
- the type of the list, e.g FloatArray- Parameters:
clazz
- the JCas class of the Array, e.g. FloatArray.class- Returns:
- a shared (in this CAS) instance of the empty array (immutable)
-
createView(String)
instead.