Class JCasImpl
- All Implemented Interfaces:
AbstractCas,JCas
-
Field Summary
Fields inherited from interface org.apache.uima.jcas.JCas
INVALID_FEATURE_CODE -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFsToIndexes(FeatureStructure instance) Add a feature structure to all appropriate indexes in the repository associated with this CAS View.static voidCreate a feature path.createFeatureValuePath(String featureValuePath) Create a feature-value path from a string.<T extends FeatureStructure>
FSIterator<T>createFilteredIterator(FSIterator<T> it, FSMatchConstraint constraint) Create an iterator over structures satisfying a given constraint.createSofa(SofaID sofaID, String mimeType) Create a Subject of Analysis.createView(String sofaID) Create a view and its underlying Sofa (subject of analysis).<T extends FeatureStructure>
ListIterator<T>fs2listIterator(FSIterator<T> it) Wrap a standard JavaListIteratoraround 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).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.Deprecated.Deprecated.Retrieve an index according to a label and a type specified using a JCas class.Get the index repository.Deprecated.static JCasImplcreates a new JCas instance that corresponds to a CAS instance.Create a JCas view for a Sofa.Gets the JCas-based interface to the Index Repository.getRequiredFeature(Type t, String s) getSofa()Get the Sofa feature structure associated with this JCas view.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.Deprecated.getType(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 exceptionget the JCas x_Type instance for a particular Java instance of a typeReturn 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.voidinitialize the JCas for new Cas content.Call this method to set up a region, ended by a close() call on the returned object, You can use this or theJCas.protectIndexes(Runnable)method to protected the indexes.voidprotectIndexes(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.voidrelease()Default implementation that returns this CAS to its CasManager by callingCasOwner.releaseCas(AbstractCas).voidremoveAllExcludingSubtypes(int i) Remove all feature structures of a given type (excluding subtypes) from all indexes in the repository associated with this CAS View.voidremoveAllIncludingSubtypes(int i) Remove all feature structures of a given type (including subtypes) from all indexes in the repository associated with this CAS View.voidremoveFsFromIndexes(FeatureStructure instance) Remove a feature structure from all indexes in the repository associated with this CAS View.voidreset()Reset the CAS, emptying it of all content.voidsetDocumentLanguage(String language) Sets the language for this document.voidsetDocumentText(String text) Set the document text.voidProvides this CAS with a handle to the CASOwner that owns it.voidsetSofaDataArray(FeatureStructure array, String mime) Set the Sofa data as an ArrayFS.voidsetSofaDataString(String text, String mime) Set the document text.voidsetSofaDataURI(String uri, String mime) Set the Sofa data as a URI.intsize()Estimate the memory consumption of this CAS instance (in bytes).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.uima.jcas.JCas
checkArrayBounds, emptyArray, emptyBooleanArray, emptyByteArray, emptyDoubleArray, emptyFloatArray, emptyFloatList, emptyFSArray, emptyFSArray, emptyFSList, emptyIntegerArray, emptyIntegerList, emptyList, emptyLongArray, emptyShortArray, emptyStringArray, emptyStringList, getAllIndexedFS, getIndexedFSs, getIndexedFSs, getIndexedFSs, getJfsFromCaddr, getRequiredFeatureDE, putJfsFromCaddr, removeAllExcludingSubtypes, removeAllIncludingSubtypes, select, select, select, select, select, throwFeatMissing
-
Method Details
-
getFSIndexRepository
- Specified by:
getFSIndexRepositoryin interfaceJCas- Returns:
- the FSIndexRepository object for this Cas
-
getLowLevelIndexRepository
- Specified by:
getLowLevelIndexRepositoryin interfaceJCas
-
getCas
-
getCasImpl
- Specified by:
getCasImplin interfaceJCas
-
getLowLevelCas
- Specified by:
getLowLevelCasin interfaceJCas
-
getTypeSystem
Description copied from interface:JCasReturn the type system of this CAS instance.- Specified by:
getTypeSystemin interfaceJCas- Returns:
- The type system, or
nullif none is available.
-
getType
Description copied from interface:JCasBackwards 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 -
getType
Description copied from interface:JCasget the JCas x_Type instance for a particular Java instance of a type -
getCasType
Description copied from interface:JCasGiven Foo.type, return the corresponding CAS Type object. This is useful in the methods which require a CAS Type, for instance iterator creation.- Specified by:
getCasTypein interfaceJCas- Parameters:
i- - index returned by Foo.type- Returns:
- the CAS Java Type object for this CAS Type.
-
createFS
-
getJCas
creates a new JCas instance that corresponds to a CAS instance. Will be called once by the UIMA framework when it creates the CAS.- Parameters:
cas- a CAS instance- Returns:
- newly created and initialized JCas // * @throws CASException -
-
getRequiredType
- Specified by:
getRequiredTypein interfaceJCas- Throws:
CASException
-
getRequiredFeature
- Specified by:
getRequiredFeaturein interfaceJCas- Throws:
CASException
-
clearData
-
reset
public void reset()Description copied from interface:JCasReset 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. -
getSofa
-
getSofa
Description copied from interface:JCasGet the Sofa feature structure associated with this JCas view. -
createView
Description copied from interface:JCasCreate 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
JCas.setSofaDataArray(FeatureStructure, String),JCas.setSofaDataString(String, String)orJCas.setSofaDataURI(String, String)on the JCas view returned by this method.- Specified by:
createViewin interfaceJCas- 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
Description copied from interface:JCasCreate a JCas view for a Sofa.- Specified by:
getJCasin interfaceJCas- Parameters:
sofa- a Sofa feature structure in this CAS.- Returns:
- The JCas view for the given Sofa.
- Throws:
CASException- -
-
getSofaIterator
Description copied from interface:JCasGet iterator for all SofaFS in the CAS.- Specified by:
getSofaIteratorin interfaceJCas- Returns:
- an iterator over SofaFS.
-
getJFSIndexRepository
Description copied from interface:JCasGets the JCas-based interface to the Index Repository. Provides the same functionality asJCas.getFSIndexRepository()except that the methods that take a "type" argument take type arguments obtainable easily from the JCas type.- Specified by:
getJFSIndexRepositoryin interfaceJCas- Returns:
- the JCas-based interface to the index repository
-
getDocumentAnnotationFs
Description copied from interface:JCasGets 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.
- Specified by:
getDocumentAnnotationFsin interfaceJCas- Returns:
- The one instance of the DocumentAnnotation annotation.
- See Also:
-
getDocumentText
Description copied from interface:JCasGet the document text.- Specified by:
getDocumentTextin interfaceJCas- Returns:
- The text being analyzed.
-
getSofaDataString
Description copied from interface:JCasGet the Sofa Data String (a.k.a. the document text).- Specified by:
getSofaDataStringin interfaceJCas- Returns:
- The Sofa data string.
-
getSofaDataArray
Description copied from interface:JCasGet the Sofa data array.- Specified by:
getSofaDataArrayin interfaceJCas- Returns:
- The Sofa Data being analyzed.
-
getSofaDataURI
Description copied from interface:JCasGet the Sofa data array.- Specified by:
getSofaDataURIin interfaceJCas- Returns:
- The Sofa Data being analyzed.
-
getSofaMimeType
Description copied from interface:JCasGet the mime type of the Sofa data being analyzed.- Specified by:
getSofaMimeTypein interfaceJCas- Returns:
- the mime type of the Sofa
-
setDocumentText
Description copied from interface:JCasSet the document text. Once set, Sofa data is immutable, and cannot be set again until the CAS has been reset.- Specified by:
setDocumentTextin interfaceJCas- Parameters:
text- The text to be analyzed.- Throws:
CASRuntimeException- If the Sofa data has already been set.
-
setSofaDataString
Description copied from interface:JCasSet the document text. Once set, Sofa data is immutable, and cannot be set again until the CAS has been reset.- Specified by:
setSofaDataStringin interfaceJCas- Parameters:
text- The text to be analyzed.mime- The mime type of the data- Throws:
CASRuntimeException- If the Sofa data has already been set.
-
setSofaDataArray
Description copied from interface:JCasSet the Sofa data as an ArrayFS. Once set, Sofa data is immutable, and cannot be set again until the CAS has been reset.- Specified by:
setSofaDataArrayin interfaceJCas- Parameters:
array- The ArrayFS to be analyzed.mime- The mime type of the data- Throws:
CASRuntimeException- If the Sofa data has already been set.
-
setSofaDataURI
Description copied from interface:JCasSet the Sofa data as a URI. Once set, Sofa data is immutable, and cannot be set again until the CAS has been reset.- Specified by:
setSofaDataURIin interfaceJCas- 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.
-
getDocumentLanguage
Description copied from interface:JCasGets the language code for this document from the language feature of the special instance of the DocumentationAnnotation associated with this CAS.- Specified by:
getDocumentLanguagein interfaceJCas- Returns:
- language identifier
-
setDocumentLanguage
Description copied from interface:JCasSets the language for this document. This value sets the language feature of the special instance of DocumentAnnotation associated with this CAS.- Specified by:
setDocumentLanguagein interfaceJCas- Parameters:
language- the language code- Throws:
CASRuntimeException- passthru
-
getSofaDataStream
Description copied from interface:JCasGet the Sofa data as a byte stream.- Specified by:
getSofaDataStreamin interfaceJCas- Returns:
- A stream handle to the Sofa Data.
-
getConstraintFactory
Description copied from interface:JCasGet a constraint factory. A constraint factory is a simple way of creatingFSMatchConstraints.- Specified by:
getConstraintFactoryin interfaceJCas- Returns:
- A constraint factory to create new FS constraints.
-
createFeaturePath
Description copied from interface:JCasCreate a feature path. This is mainly useful for creatingFSMatchConstraints.- Specified by:
createFeaturePathin interfaceJCas- Returns:
- A new, empty feature path.
-
createFilteredIterator
public <T extends FeatureStructure> FSIterator<T> createFilteredIterator(FSIterator<T> it, FSMatchConstraint constraint) Description copied from interface:JCasCreate an iterator over structures satisfying a given constraint. Constraints are described in the javadocs forConstraintFactoryand related classes.- Specified by:
createFilteredIteratorin interfaceJCas- Type Parameters:
T- the particular FeatureStructure type- Parameters:
it- The input iterator.constraint- The constraint specifying what structures should be returned.- Returns:
- An iterator over FSs.
-
getStringArray0L
Deprecated.Description copied from interface:JCasA 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.- Specified by:
getStringArray0Lin interfaceJCas- Returns:
- 0-length instance of a StringArray
-
getIntegerArray0L
Deprecated.Description copied from interface:JCasRetrieve 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.- Specified by:
getIntegerArray0Lin interfaceJCas- Returns:
- 0-length instance of an IntegerArray
-
getFloatArray0L
Deprecated.Description copied from interface:JCasRetrieve 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.- Specified by:
getFloatArray0Lin interfaceJCas- Returns:
- 0-length instance of a FloatArray
-
getFSArray0L
Deprecated.Description copied from interface:JCasRetrieve 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- Specified by:
getFSArray0Lin interfaceJCas- Returns:
- 0-length instance of a FSArray
-
processInit
public void processInit()Description copied from interface:JCasinitialize the JCas for new Cas content. Not used, does nothing.- Specified by:
processInitin interfaceJCas
-
setOwner
Description copied from class:AbstractCas_ImplBaseProvides this CAS with a handle to the CASOwner that owns it. This is called by the framework when a CAS instance is created. This handle is used to implement the release() method by returning the CAS to its CasOwner.- Overrides:
setOwnerin classAbstractCas_ImplBase- Parameters:
aCasOwner- -
-
release
public void release()Description copied from class:AbstractCas_ImplBaseDefault implementation that returns this CAS to its CasManager by callingCasOwner.releaseCas(AbstractCas).- Specified by:
releasein interfaceAbstractCas- Overrides:
releasein classAbstractCas_ImplBase
-
getView
Description copied from interface:JCasGet 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.- Specified by:
getViewin interfaceJCas- 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
Description copied from interface:JCasGet 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.- Specified by:
getViewin interfaceJCas- Parameters:
aSofa- a Sofa feature structure in the CAS- Returns:
- The view for the given Sofa
- Throws:
CASException- passthru
-
addFsToIndexes
Description copied from interface:JCasAdd 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.- Specified by:
addFsToIndexesin interfaceJCas- Parameters:
instance- The Feature Structure to be added.
-
removeFsFromIndexes
Description copied from interface:JCasRemove a feature structure from all indexes in the repository associated with this CAS View.- Specified by:
removeFsFromIndexesin interfaceJCas- Parameters:
instance- The Feature Structure to be removed.
-
removeAllIncludingSubtypes
public void removeAllIncludingSubtypes(int i) Description copied from interface:JCasRemove all feature structures of a given type (including subtypes) from all indexes in the repository associated with this CAS View.- Specified by:
removeAllIncludingSubtypesin interfaceJCas- Parameters:
i- the CAS type constant, written as Foo.type (for a given JCas Type) or anInstanceOfFoo.getTypeIndexID(), for an instance
-
removeAllExcludingSubtypes
public void removeAllExcludingSubtypes(int i) Description copied from interface:JCasRemove all feature structures of a given type (excluding subtypes) from all indexes in the repository associated with this CAS View.- Specified by:
removeAllExcludingSubtypesin interfaceJCas- Parameters:
i- the CAS type constant, written as Foo.type (for a given JCas Type) or anInstanceOfFoo.getTypeIndexID(), for an instance
-
fs2listIterator
Description copied from interface:JCasWrap a standard JavaListIteratoraround an FSListIterator. Use if you feel more comfortable with java style iterators.- Specified by:
fs2listIteratorin interfaceJCas- Type Parameters:
T- The particular Feature Structure type- Parameters:
it- TheFSListIteratorto be wrapped.- Returns:
- An equivalent
ListIterator. - See Also:
-
createFeatureValuePath
Description copied from interface:JCasCreate a feature-value path from a string.- Specified by:
createFeatureValuePathin interfaceJCas- Parameters:
featureValuePath- String representation of the feature-value path.- Returns:
- Feature-value path object.
- Throws:
CASRuntimeException- If the input string is not well-formed.
-
createSofa
Description copied from interface:JCasCreate a Subject of Analysis. The new sofaFS is automatically added to the SofaIndex.- Specified by:
createSofain interfaceJCas- Parameters:
sofaID- the SofA IDmimeType- the mime type- Returns:
- The sofaFS.
-
getIndexRepository
Description copied from interface:JCasGet the index repository.- Specified by:
getIndexRepositoryin interfaceJCas- Returns:
- The index repository, or
nullif none is available.
-
getViewName
Description copied from interface:JCasGet 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.- Specified by:
getViewNamein interfaceJCas- Returns:
- The name of the view
-
size
public int size()Description copied from interface:JCasEstimate the memory consumption of this CAS instance (in bytes). -
getAnnotationIndex
Description copied from interface:JCasGet the standard annotation index.- Specified by:
getAnnotationIndexin interfaceJCas- Returns:
- The standard annotation index.
-
getAnnotationIndex
public <T extends Annotation> AnnotationIndex<T> getAnnotationIndex(Type type) throws CASRuntimeException Description copied from interface:JCasGet the standard annotation index restricted to a specific annotation type.- Specified by:
getAnnotationIndexin interfaceJCas- 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
public <T extends Annotation> AnnotationIndex<T> getAnnotationIndex(int type) throws CASRuntimeException Description copied from interface:JCasGet the standard annotation index restricted to a specific annotation type.- Specified by:
getAnnotationIndexin interfaceJCas- 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
Description copied from interface:JCasGet the standard annotation index restricted to a specific annotation type.- Specified by:
getAnnotationIndexin interfaceJCas- 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.
-
getViewIterator
Description copied from interface:JCasGet 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.- Specified by:
getViewIteratorin interfaceJCas- Returns:
- an iterator which returns all views. Each object returned by the iterator is of type JCas.
- Throws:
CASException- -
-
getViewIterator
Description copied from interface:JCasGet 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.- Specified by:
getViewIteratorin interfaceJCas- 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
Description copied from interface:JCasCall this method to set up a region, ended by a close() call on the returned object, You can use this or theJCas.protectIndexes(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.
- Specified by:
protectIndexesin interfaceJCas- Returns:
- an object used to record things that need adding back
-
protectIndexes
Description copied from interface:JCasRuns 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.- Specified by:
protectIndexesin interfaceJCas- Parameters:
runnable- code to execute while protecting the indexes.
-
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)- Specified by:
getCasTypein interfaceJCas- Parameters:
clazz- a JCas cover class- Returns:
- the corresponding UIMA Type object
-
getAllIndexedFS
Description copied from interface:JCasGets 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.- Specified by:
getAllIndexedFSin interfaceJCas- 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.
-
getIndex
Description copied from interface:JCasRetrieve 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.- Specified by:
getIndexin interfaceJCas- 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
nullif an index with that name doesn't exist.
-