Interface CAS

  • All Superinterfaces:
    AbstractCas
    All Known Implementing Classes:
    CASImpl

    public interface CAS
    extends AbstractCas
    Object-oriented CAS (Common Analysis System) API.

    A CAS object provides the starting point for working with the CAS. It provides access to the type system, to indexes, iterators and filters (constraints). It also lets you create new annotations and other data structures. You can create a CAS object using static methods on the class CasCreationUtils.

    The CAS object is also the container that manages multiple Subjects of Analysis or Sofas. A Sofa represents some form of an unstructured artifact that is processed in a UIMA pipeline. The Java string called the "DocumentText" used in a UIMA text processing pipeline is an example of a Sofa. A Sofa can be analyzed independently using the standard UIMA programming model or analyzed together with other Sofas utilizing the Sofa programming model extensions.

    A Sofa is implemented as a built-in CAS type uima.cas.Sofa. Use CAS.createSofa() to instantiate a Sofa feature structure. The SofaFS class provides methods to set and get the features of a SofaFS. Although Sofas are implemented as standard feature structures, generic CAS APIs must never be used to create Sofas or set their features.

    Use getView(String) or getView(SofaFS) to obtain a view of a particular Sofa in the CAS. This view will provide access to the Sofa data (for example the document text) as well as the index repository, which contains metadata (annotations and other feature structures) about that Sofa.

    Use getTypeSystem() to access the type system. With a TypeSystem object, you can access the Type and Feature objects for the CAS built-in types. Note that this interface also provides constants for the names of the built-in types and features.

    • Field Detail

      • NAME_SPACE_UIMA_CAS

        static final java.lang.String NAME_SPACE_UIMA_CAS
        UIMA CAS name space.
        See Also:
        Constant Field Values
      • UIMA_CAS_PREFIX

        static final java.lang.String UIMA_CAS_PREFIX
        UIMA CAS name space prefix to prepend to type names (adds an extra period to the name space proper.
        See Also:
        Constant Field Values
      • TYPE_NAME_INTEGER

        static final java.lang.String TYPE_NAME_INTEGER
        Integer type.
        See Also:
        Constant Field Values
      • TYPE_NAME_FLOAT

        static final java.lang.String TYPE_NAME_FLOAT
        Float type.
        See Also:
        Constant Field Values
      • TYPE_NAME_STRING

        static final java.lang.String TYPE_NAME_STRING
        String type.
        See Also:
        Constant Field Values
      • TYPE_NAME_BOOLEAN

        static final java.lang.String TYPE_NAME_BOOLEAN
        Boolean type.
        See Also:
        Constant Field Values
      • TYPE_NAME_BYTE

        static final java.lang.String TYPE_NAME_BYTE
        Byte type.
        See Also:
        Constant Field Values
      • TYPE_NAME_SHORT

        static final java.lang.String TYPE_NAME_SHORT
        Short type.
        See Also:
        Constant Field Values
      • TYPE_NAME_LONG

        static final java.lang.String TYPE_NAME_LONG
        Long type.
        See Also:
        Constant Field Values
      • TYPE_NAME_DOUBLE

        static final java.lang.String TYPE_NAME_DOUBLE
        Double type.
        See Also:
        Constant Field Values
      • TYPE_NAME_ARRAY_BASE

        static final java.lang.String TYPE_NAME_ARRAY_BASE
        ArrayBase type.
        See Also:
        Constant Field Values
      • TYPE_NAME_FS_ARRAY

        static final java.lang.String TYPE_NAME_FS_ARRAY
        Feature structure array type.
        See Also:
        Constant Field Values
      • TYPE_NAME_INTEGER_ARRAY

        static final java.lang.String TYPE_NAME_INTEGER_ARRAY
        Integer array type.
        See Also:
        Constant Field Values
      • TYPE_NAME_FLOAT_ARRAY

        static final java.lang.String TYPE_NAME_FLOAT_ARRAY
        Float array type.
        See Also:
        Constant Field Values
      • TYPE_NAME_STRING_ARRAY

        static final java.lang.String TYPE_NAME_STRING_ARRAY
        String array type.
        See Also:
        Constant Field Values
      • TYPE_NAME_BOOLEAN_ARRAY

        static final java.lang.String TYPE_NAME_BOOLEAN_ARRAY
        Boolean array type.
        See Also:
        Constant Field Values
      • TYPE_NAME_BYTE_ARRAY

        static final java.lang.String TYPE_NAME_BYTE_ARRAY
        Byte array type.
        See Also:
        Constant Field Values
      • TYPE_NAME_SHORT_ARRAY

        static final java.lang.String TYPE_NAME_SHORT_ARRAY
        Short array type.
        See Also:
        Constant Field Values
      • TYPE_NAME_LONG_ARRAY

        static final java.lang.String TYPE_NAME_LONG_ARRAY
        Long array type.
        See Also:
        Constant Field Values
      • TYPE_NAME_DOUBLE_ARRAY

        static final java.lang.String TYPE_NAME_DOUBLE_ARRAY
        Double array type.
        See Also:
        Constant Field Values
      • TYPE_NAME_SOFA

        static final java.lang.String TYPE_NAME_SOFA
        Sofa type.
        See Also:
        Constant Field Values
      • TYPE_NAME_ANNOTATION_BASE

        static final java.lang.String TYPE_NAME_ANNOTATION_BASE
        Name of annotation base type.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_SOFANUM

        static final java.lang.String FEATURE_BASE_NAME_SOFANUM
        Base name of Sofa Number feature.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_SOFAID

        static final java.lang.String FEATURE_BASE_NAME_SOFAID
        Base name of Sofa ID feature.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_SOFAMIME

        static final java.lang.String FEATURE_BASE_NAME_SOFAMIME
        Base name of Sofa mime type feature.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_SOFAURI

        static final java.lang.String FEATURE_BASE_NAME_SOFAURI
        Base name of Sofa URI feature.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_SOFASTRING

        static final java.lang.String FEATURE_BASE_NAME_SOFASTRING
        Base name of Sofa string data feature.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_SOFAARRAY

        static final java.lang.String FEATURE_BASE_NAME_SOFAARRAY
        Base name of Sofa array fs data feature.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_FS_ARRAY

        static final java.lang.String FEATURE_BASE_NAME_FS_ARRAY
        Base name of FSArrayList fsArray feature. Base name of FSHashSet fsArray feature.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_INT_ARRAY

        static final java.lang.String FEATURE_BASE_NAME_INT_ARRAY
        Base name of FSArrayList fsArray feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_SOFANUM

        static final java.lang.String FEATURE_FULL_NAME_SOFANUM
        Qualified name of Sofa number feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_SOFAID

        static final java.lang.String FEATURE_FULL_NAME_SOFAID
        Qualified name of Sofa id feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_SOFAMIME

        static final java.lang.String FEATURE_FULL_NAME_SOFAMIME
        Qualified name of Sofa mime type feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_SOFAURI

        static final java.lang.String FEATURE_FULL_NAME_SOFAURI
        Qualified name of Sofa URI feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_SOFASTRING

        static final java.lang.String FEATURE_FULL_NAME_SOFASTRING
        Qualified name of Sofa string data feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_SOFAARRAY

        static final java.lang.String FEATURE_FULL_NAME_SOFAARRAY
        Qualified name of Sofa array fs data feature.
        See Also:
        Constant Field Values
      • SOFA_INDEX_NAME

        static final java.lang.String SOFA_INDEX_NAME
        Sofa Index name.
        See Also:
        Constant Field Values
      • NAME_DEFAULT_TEXT_SOFA

        @Deprecated
        static final java.lang.String NAME_DEFAULT_TEXT_SOFA
        Deprecated.
        As of v2.0, this is replaced by NAME_DEFAULT_SOFA, and the value has changed. In general, user code should not need to refer to this name.
        Sofa name for the default text sofa.
        See Also:
        Constant Field Values
      • NAME_DEFAULT_SOFA

        static final java.lang.String NAME_DEFAULT_SOFA
        Sofa name for the initial view's sofa.
        See Also:
        Constant Field Values
      • TYPE_NAME_LIST_BASE

        static final java.lang.String TYPE_NAME_LIST_BASE
        Abstract list base type.
        See Also:
        Constant Field Values
      • TYPE_NAME_FS_LIST

        static final java.lang.String TYPE_NAME_FS_LIST
        Feature structure list type.
        See Also:
        Constant Field Values
      • TYPE_NAME_NON_EMPTY_FS_LIST

        static final java.lang.String TYPE_NAME_NON_EMPTY_FS_LIST
        Non-empty feature structure list type.
        See Also:
        Constant Field Values
      • TYPE_NAME_EMPTY_FS_LIST

        static final java.lang.String TYPE_NAME_EMPTY_FS_LIST
        Empty feature structure list type.
        See Also:
        Constant Field Values
      • TYPE_NAME_INTEGER_LIST

        static final java.lang.String TYPE_NAME_INTEGER_LIST
        Integer list type.
        See Also:
        Constant Field Values
      • TYPE_NAME_NON_EMPTY_INTEGER_LIST

        static final java.lang.String TYPE_NAME_NON_EMPTY_INTEGER_LIST
        Non-empty integer list type.
        See Also:
        Constant Field Values
      • TYPE_NAME_EMPTY_INTEGER_LIST

        static final java.lang.String TYPE_NAME_EMPTY_INTEGER_LIST
        Empty integer list type.
        See Also:
        Constant Field Values
      • TYPE_NAME_FLOAT_LIST

        static final java.lang.String TYPE_NAME_FLOAT_LIST
        Float list type.
        See Also:
        Constant Field Values
      • TYPE_NAME_NON_EMPTY_FLOAT_LIST

        static final java.lang.String TYPE_NAME_NON_EMPTY_FLOAT_LIST
        Non-empty float list type.
        See Also:
        Constant Field Values
      • TYPE_NAME_EMPTY_FLOAT_LIST

        static final java.lang.String TYPE_NAME_EMPTY_FLOAT_LIST
        Empty float type.
        See Also:
        Constant Field Values
      • TYPE_NAME_STRING_LIST

        static final java.lang.String TYPE_NAME_STRING_LIST
        String list type.
        See Also:
        Constant Field Values
      • TYPE_NAME_NON_EMPTY_STRING_LIST

        static final java.lang.String TYPE_NAME_NON_EMPTY_STRING_LIST
        Non-empty string list type.
        See Also:
        Constant Field Values
      • TYPE_NAME_EMPTY_STRING_LIST

        static final java.lang.String TYPE_NAME_EMPTY_STRING_LIST
        Empty string list type.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_HEAD

        static final java.lang.String FEATURE_BASE_NAME_HEAD
        Base name of list head feature.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_TAIL

        static final java.lang.String FEATURE_BASE_NAME_TAIL
        Base name of list tail feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_FS_LIST_HEAD

        static final java.lang.String FEATURE_FULL_NAME_FS_LIST_HEAD
        Qualified name of fs list head feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_INTEGER_LIST_HEAD

        static final java.lang.String FEATURE_FULL_NAME_INTEGER_LIST_HEAD
        Qualified name of integer list head feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_FLOAT_LIST_HEAD

        static final java.lang.String FEATURE_FULL_NAME_FLOAT_LIST_HEAD
        Qualified name of float list head feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_STRING_LIST_HEAD

        static final java.lang.String FEATURE_FULL_NAME_STRING_LIST_HEAD
        Qualified name of string list head feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_FS_LIST_TAIL

        static final java.lang.String FEATURE_FULL_NAME_FS_LIST_TAIL
        Qualified name of fs list tail feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_INTEGER_LIST_TAIL

        static final java.lang.String FEATURE_FULL_NAME_INTEGER_LIST_TAIL
        Qualified name of integer list tail feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_FLOAT_LIST_TAIL

        static final java.lang.String FEATURE_FULL_NAME_FLOAT_LIST_TAIL
        Qualified name of float list tail feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_STRING_LIST_TAIL

        static final java.lang.String FEATURE_FULL_NAME_STRING_LIST_TAIL
        Qualified name of string list tail feature.
        See Also:
        Constant Field Values
      • NAME_SPACE_UIMA_TCAS

        static final java.lang.String NAME_SPACE_UIMA_TCAS
        Name of Text CAS name space.
        See Also:
        Constant Field Values
      • UIMA_TCAS_PREFIX

        static final java.lang.String UIMA_TCAS_PREFIX
        UIMA TCAS name space prefix to prepend to type names (adds an extra period to the name space proper.
        See Also:
        Constant Field Values
      • TYPE_NAME_ANNOTATION

        static final java.lang.String TYPE_NAME_ANNOTATION
        Name of annotation type.
        See Also:
        Constant Field Values
      • TYPE_NAME_DOCUMENT_ANNOTATION

        static final java.lang.String TYPE_NAME_DOCUMENT_ANNOTATION
        Name of document annotation type.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_SOFA

        static final java.lang.String FEATURE_BASE_NAME_SOFA
        Sofa ID feature that is the handle to a text Sofa.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_BEGIN

        static final java.lang.String FEATURE_BASE_NAME_BEGIN
        Base name of annotation begin feature.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_END

        static final java.lang.String FEATURE_BASE_NAME_END
        Base name of annotation end feature.
        See Also:
        Constant Field Values
      • FEATURE_BASE_NAME_LANGUAGE

        static final java.lang.String FEATURE_BASE_NAME_LANGUAGE
        Base name of document language feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_BEGIN

        static final java.lang.String FEATURE_FULL_NAME_BEGIN
        Fully qualified name of annotation begin feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_SOFA

        static final java.lang.String FEATURE_FULL_NAME_SOFA
        Fully qualified name of annotation sofa feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_END

        static final java.lang.String FEATURE_FULL_NAME_END
        Fully qualified name of annotation end feature.
        See Also:
        Constant Field Values
      • FEATURE_FULL_NAME_LANGUAGE

        static final java.lang.String FEATURE_FULL_NAME_LANGUAGE
        Fully qualified name of document language feature.
        See Also:
        Constant Field Values
      • STD_ANNOTATION_INDEX

        static final java.lang.String STD_ANNOTATION_INDEX
        Name of the built-in index on annotations.
        See Also:
        Constant Field Values
      • DEFAULT_LANGUAGE_NAME

        static final java.lang.String DEFAULT_LANGUAGE_NAME
        See Also:
        Constant Field Values
    • Method Detail

      • getJCas

        JCas getJCas()
              throws CASException
        Get the JCas view for this CAS view
        Returns:
        The JCas view for this CAS view
        Throws:
        CASException - not thrown in v3, but kept for backwards compatibility
      • getJCasImpl

        default JCasImpl getJCasImpl()
        Get the JCasImpl view for this CAS view
        Returns:
        the JCasImpl view for this CAS view
      • getCurrentView

        CAS getCurrentView()
        Get the Cas view that the current component should use. This should only be used by single-view components.
        Returns:
        the Cas view specified for the current component by Sofa mapping. Defaults to _InitialView if there is no Sofa mapping.
      • getSofa

        @Deprecated
        SofaFS getSofa​(SofaID sofaID)
        Deprecated.
        As of v2.0, use {#getView(String)}. From the view you can access the Sofa data, or call getSofa() if you truly need to access the SofaFS object.
        Get sofaFS for given Subject of Analysis ID.
        Parameters:
        sofaID - -
        Returns:
        The sofaFS.
      • getSofa

        SofaFS getSofa()
        Get the Sofa feature structure associated with this CAS view.
        Returns:
        The SofaFS associated with this CAS view.
      • createView

        CAS createView​(java.lang.String localViewName)
        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) or setSofaDataURI(String, String) on the CAS view returned by this method.

        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:
        CASRuntimeException - if a View with this name already exists in this CAS
      • getJCas

        JCas getJCas​(SofaFS aSofa)
              throws CASException
        Create a JCas view for a Sofa. Note: as of UIMA v2.0, can be replaced with getView(sofaFS).getJCas().
        Parameters:
        aSofa - a Sofa feature structure in this CAS.
        Returns:
        The JCas view for the given Sofa.
        Throws:
        CASException - -
      • getJCas

        @Deprecated
        JCas getJCas​(SofaID aSofaID)
              throws CASException
        Deprecated.
        As of v2.0, use getView(String) followed by getJCas().
        Create a JCas view for a Sofa. Note: this is provided for convenience. It is equivalent to getView(aSofaID).getJCas().
        Parameters:
        aSofaID - the ID of a Sofa defined in this CAS
        Returns:
        The view for the Sofa with ID aSofaID.
        Throws:
        CASException - if no Sofa with the given ID exists in this CAS
      • getView

        CAS getView​(java.lang.String localViewName)
        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:
        CASRuntimeException - if no View with this name exists in this CAS
      • getView

        CAS getView​(SofaFS aSofa)
        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
      • getLowLevelCAS

        LowLevelCAS getLowLevelCAS()
        Get an instance of the low-level CAS. Low-level and regular CAS can be used in parallel, all data is always contained in both.

        Note: This is for internal use.

        Returns:
        A low-level CAS.
        See Also:
        LowLevelCAS
      • getAnnotationType

        Type getAnnotationType()
        Get the type object for the annotation type.
        Returns:
        The annotation type.
      • getBeginFeature

        Feature getBeginFeature()
        Get the feature object for the annotation begin feature.
        Returns:
        The annotation begin feature.
      • getEndFeature

        Feature getEndFeature()
        Get the feature object for the annotation end feature.
        Returns:
        The annotation end feature.
      • getAnnotationIndex

        <T extends AnnotationFSAnnotationIndex<T> getAnnotationIndex()
        Get the standard annotation index.
        Type Parameters:
        T - either Annotation (if JCas is in use) or AnnotationImpl
        Returns:
        The standard annotation index.
      • getAnnotationIndex

        <T extends AnnotationFSAnnotationIndex<T> getAnnotationIndex​(Type type)
                                                                throws CASRuntimeException
        Get the standard annotation index restricted to a specific annotation type.
        Type Parameters:
        T - the topmost Java class corresponding to the type
        Parameters:
        type - The annotation type the index is restricted to.
        Returns:
        The standard annotation index, restricted to type.
        Throws:
        CASRuntimeException - When type is not an annotation type.
      • getAnnotationIndex

        default <T extends AnnotationFSAnnotationIndex<T> getAnnotationIndex​(java.lang.Class<T> clazz)
                                                                        throws CASRuntimeException
        Get the standard annotation index restricted to a specific annotation type.
        Type Parameters:
        T - the topmost Java class corresponding to the type
        Parameters:
        clazz - The annotation type the index is restricted to, specified as a JCas class
        Returns:
        The standard annotation index, restricted to type.
        Throws:
        CASRuntimeException - When type is not an annotation type.
      • createAnnotation

        <T extends AnnotationFSAnnotationFS createAnnotation​(Type type,
                                                               int begin,
                                                               int end)
        Create a new annotation. Note that you still need to insert the annotation into the index repository yourself.
        Type Parameters:
        T - the Java class corresponding to the type
        Parameters:
        type - The type of the annotation.
        begin - The start of the annotation.
        end - The end of the annotation.
        Returns:
        A new annotation object.
      • getDocumentAnnotation

        <T extends AnnotationFS> T getDocumentAnnotation()
        Get the Document Annotation. The Document Annotation has a string-valued feature called "language" where the document language is specified.
        Type Parameters:
        T - the Java class for the document annotation. Could be the JCas cover class or FeatureStructure
        Returns:
        The document annotation. If it doesn't exist, one is created. The return value is the JCas cover class or the plain Java cover class for FeatureStructures if there is no JCas cover class for this type.
      • setCurrentComponentInfo

        void setCurrentComponentInfo​(ComponentInfo info)
        Informs the CAS of relevant information about the component that is currently processing it. This is called by the framework automatically; users do not need to call it.
        Parameters:
        info - information about the component that is currently processing this CAS.
      • getTypeSystem

        TypeSystem getTypeSystem()
                          throws CASRuntimeException
        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
        SofaFS createSofa​(SofaID sofaID,
                          java.lang.String mimeType)
        Deprecated.
        As of v2.0, use createView(String) instead.
        Create a Subject of Analysis. The new sofaFS is automatically added to the SofaIndex.
        Parameters:
        sofaID - -
        mimeType - -
        Returns:
        The sofaFS.
      • getSofaIterator

        <T extends SofaFSFSIterator<T> getSofaIterator()
        Get iterator for all SofaFS in the CAS.
        Type Parameters:
        T - generic type of sofa iterator
        Returns:
        an iterator over SofaFS.
      • createFilteredIterator

        <T extends FeatureStructureFSIterator<T> createFilteredIterator​(FSIterator<T> it,
                                                                          FSMatchConstraint cons)
        Create an iterator over structures satisfying a given constraint. Constraints are described in the javadocs for ConstraintFactory and related classes.
        Type Parameters:
        T - - the type of the Feature Structure
        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 creating FSMatchConstraints.
        Returns:
        A constraint factory to create new FS constraints.
      • createFeaturePath

        FeaturePath createFeaturePath()
        Create a feature path. This is mainly useful for creating FSMatchConstraints.
        Returns:
        A new, empty feature path.
      • getIndexRepository

        FSIndexRepository getIndexRepository()
        Get the index repository.
        Returns:
        The index repository, or null if none is available.
      • fs2listIterator

        <T extends FeatureStructure> java.util.ListIterator<T> fs2listIterator​(FSIterator<T> it)
        Wrap a standard Java ListIterator around an FSListIterator. Use if you feel more comfortable with java style iterators.
        Type Parameters:
        T - The type of FeatureStructure
        Parameters:
        it - The FSListIterator to be wrapped.
        Returns:
        An equivalent ListIterator.
      • reset

        void reset()
            throws CASAdminException
        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:
        CASMgr
      • getViewName

        java.lang.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

        FeatureValuePath createFeatureValuePath​(java.lang.String featureValuePath)
                                         throws CASRuntimeException
        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

        void setDocumentText​(java.lang.String text)
                      throws CASRuntimeException
        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

        void setSofaDataString​(java.lang.String text,
                               java.lang.String mimetype)
                        throws CASRuntimeException
        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

        java.lang.String getDocumentText()
        Get the document text.
        Returns:
        The text being analyzed, or null if not set.
      • getSofaDataString

        java.lang.String getSofaDataString()
        Get the Sofa Data String (a.k.a. the document text).
        Returns:
        The Sofa data string, or null if not set.
      • setDocumentLanguage

        void setDocumentLanguage​(java.lang.String languageCode)
                          throws CASRuntimeException
        Sets the language for this document. This value sets the language feature of the special instance of DocumentAnnotation associated with this CAS.
        Parameters:
        languageCode - -
        Throws:
        CASRuntimeException - passthru
      • getDocumentLanguage

        java.lang.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

        void setSofaDataArray​(FeatureStructure array,
                              java.lang.String mime)
                       throws CASRuntimeException
        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, or null if not set.
      • setSofaDataURI

        void setSofaDataURI​(java.lang.String uri,
                            java.lang.String mime)
                     throws CASRuntimeException
        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

        java.lang.String getSofaDataURI()
        Get the Sofa data array.
        Returns:
        The Sofa URI being analyzed, or null if not set.
      • getSofaDataStream

        java.io.InputStream getSofaDataStream()
        Get the Sofa data as a byte stream.
        Returns:
        A stream handle to the Sofa Data, or null if not set.
      • getSofaMimeType

        java.lang.String getSofaMimeType()
        Get the mime type of the Sofa data being analyzed.
        Returns:
        the mime type of the Sofa
      • addFsToIndexes

        void addFsToIndexes​(FeatureStructure fs)
        Add a feature structure to all appropriate indexes in the repository associated with this CAS View. If no indexes exist for the type of FS that you are adding, then a bag (unsorted) index will be automatically created.

        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 call removeFsFromIndexes(...) on the FS, change the feature values, then call addFsToIndexes(...) again.

        Parameters:
        fs - The Feature Structure to be added.
        Throws:
        java.lang.NullPointerException - If the fs parameter is null.
      • removeFsFromIndexes

        void removeFsFromIndexes​(FeatureStructure fs)
        Remove a feature structure from all indexes in the repository associated with this CAS View. The remove operation removes the exact fs from the indexes, unlike operations such as moveTo which use the fs argument as a template. It is not an error if the FS is not present in the indexes.
        Parameters:
        fs - The Feature Structure to be removed.
        Throws:
        java.lang.NullPointerException - If the fs parameter is null.
      • getViewIterator

        <T extends CAS> java.util.Iterator<T> getViewIterator()
        Get iterator over all views in this CAS. Each view provides access to Sofa data and the index repository that contains metadata (annotations and other feature structures) pertaining to that Sofa.
        Type Parameters:
        T - generic type of returned view
        Returns:
        an iterator which returns all views. Each object returned by the iterator is of type CAS or a subtype.
      • getViewIterator

        java.util.Iterator<CAS> getViewIterator​(java.lang.String localViewNamePrefix)
        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 CAS.
      • createMarker

        Marker createMarker()
        Sets a mark and returns the marker object set with the current mark which can be used to query when certain FSs were created. This can then be used to identify FSs as added before or after the mark was set and to identify FSs modified after the mark is set. Note: this method may only be called from an application. Calling it from an annotator will trigger a runtime exception.
        Returns:
        a marker object.
      • protectIndexes

        java.lang.AutoCloseable protectIndexes()
        Call this method to set up a region, ended by a AutoCloseable.close() call on the returned object, You can use this or the 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.

        Returns:
        an object used to record things that need adding back
      • protectIndexes

        void protectIndexes​(java.lang.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. 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.
      • select

        default <T extends TOPSelectFSs<T> select()
        Type Parameters:
        T - the Type of the elements being accessed
        Returns:
        a newly created selection object for accessing feature structures
      • select

        default <T extends TOPSelectFSs<T> select​(Type type)
        Type Parameters:
        T - 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:
        java.lang.IllegalArgumentException - if no type is specified.
      • select

        default <T extends TOPSelectFSs<T> select​(java.lang.Class<T> clazz)
        Type Parameters:
        T - 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:
        java.lang.IllegalArgumentException - if no type is specified.
      • select

        default <T extends TOPSelectFSs<T> select​(int jcasType)
        Type Parameters:
        T - 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
        Throws:
        java.lang.IllegalArgumentException - if no type is specified.
      • select

        default <T extends TOPSelectFSs<T> select​(java.lang.String fullyQualifiedTypeName)
        Type Parameters:
        T - 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:
        java.lang.IllegalArgumentException - if no type is specified.
      • emptyList

        default <T extends TOPEmptyList emptyList​(java.lang.Class<T> clazz)
        Type Parameters:
        T - the type of the element of the list
        Parameters:
        clazz - a JCas class corresponding to the type (and subtypes of that type) to access
        Returns:
        a lazily created shared (for this CAS) empty list
      • emptyFloatList

        default EmptyFloatList emptyFloatList()
        Returns:
        a lazily created shared (for this CAS) empty list
      • emptyFSList

        default <T extends TOPEmptyFSList<T> emptyFSList()
        Type Parameters:
        T - the type of the elements of the FSList
        Returns:
        a lazily created shared (for this CAS) empty list
      • emptyIntegerList

        default EmptyIntegerList emptyIntegerList()
        Returns:
        a lazily created shared (for this CAS) empty list
      • emptyStringList

        default EmptyStringList emptyStringList()
        Returns:
        a lazily created shared (for this CAS) empty list
      • emptyArray

        default <T extends TOPCommonArrayFS<T> emptyArray​(java.lang.Class<T> clazz)
        Type Parameters:
        T - the type of the elements of the array
        Parameters:
        clazz - the class of the elements of the array
        Returns:
        a lazily created shared (for this CAS) 0-length array
      • emptyFloatArray

        default FloatArray emptyFloatArray()
        Returns:
        a lazily created shared (for this CAS) 0-length array
      • emptyFSArray

        default <T extends FeatureStructureFSArray<T> emptyFSArray()
        Type Parameters:
        T - the type of the elements of the FSArray
        Returns:
        a lazily created shared (for this CAS) 0-length FSarray
      • emptyFSArray

        default <T extends FeatureStructureFSArray<T> emptyFSArray​(Type type)
        Type Parameters:
        T - the type of the elements of the FSArray
        Parameters:
        type - the type of the elements of the FSArray
        Returns:
        a lazily created shared (for this CAS) 0-length subtype of FSarray holding elements of type element-type
      • emptyIntegerArray

        default IntegerArray emptyIntegerArray()
        Returns:
        a lazily created shared (for this CAS) 0-length array
      • emptyStringArray

        default StringArray emptyStringArray()
        Returns:
        a lazily created shared (for this CAS) 0-length array
      • emptyDoubleArray

        default DoubleArray emptyDoubleArray()
        Returns:
        a lazily created shared (for this CAS) 0-length array
      • emptyLongArray

        default LongArray emptyLongArray()
        Returns:
        a lazily created shared (for this CAS) 0-length array
      • emptyShortArray

        default ShortArray emptyShortArray()
        Returns:
        a lazily created shared (for this CAS) 0-length array
      • emptyByteArray

        default ByteArray emptyByteArray()
        Returns:
        a lazily created shared (for this CAS) 0-length array
      • emptyBooleanArray

        default BooleanArray emptyBooleanArray()
        Returns:
        a lazily created shared (for this CAS) 0-length array
      • getCasType

        default <T extends TOPType getCasType​(java.lang.Class<T> clazz)
        Type Parameters:
        T - the type of the JCas class
        Parameters:
        clazz - - a JCas class
        Returns:
        the corresponding Type, for this CAS
      • getAllIndexedFS

        default <T extends TOPFSIterator<T> getAllIndexedFS​(java.lang.Class<T> clazz)
        Gets an iterator over all indexed (in this CAS view) 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 Type and its subtypes, corresponding to the JCas clazz, in no particular order.
      • getAllIndexedFS

        default <T extends TOPFSIterator<T> getAllIndexedFS​(Type type)
        Gets an iterator over all indexed (in this CAS view) 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 JCas class the iterator uses
        Parameters:
        type - the type of Feature Structures to include (including subtypes)
        Returns:
        An iterator that returns all indexed FeatureStructures of the Type and its subtypes, corresponding to the JCas clazz, in no particular order.
      • getIndexedFSs

        default <T extends TOP> java.util.Collection<T> getIndexedFSs​(Type type)
        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

        default java.util.Collection<TOP> 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)
      • getIndexedFSs

        default <T extends TOP> java.util.Collection<T> getIndexedFSs​(java.lang.Class<T> clazz)
        Returns a 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)