Class FSArrayList<T extends TOP>

  • Type Parameters:
    T - the generic type
    All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>, java.util.RandomAccess, CommonArrayFS<T>, FeatureStructure, FeatureStructureImpl, SelectViaCopyToArray<T>, UimaSerializable, UimaSerializableFSs

    public class FSArrayList<T extends TOP>
    extends TOP
    implements UimaSerializableFSs, CommonArrayFS<T>, SelectViaCopyToArray<T>, java.util.List<T>, java.util.RandomAccess, java.lang.Cloneable

    An ArrayList type containing Feature Structures, for UIMA

    • Has all the methods of List
    • Implements the select(...) APIs

    Implementation notes:

    • Uses UimaSerializable APIs
    • two implementations of the array list:
      • one uses the original FSArray, via an asList wrapper
      • This is used until an add or remove operation;
      • switches to ArrayList, resetting the original FSArray to null
    • This enables operation without creating the Java Object in use cases of deserializing and referencing when updating is not being used.
    • The values stored internally are non-PEAR ones.
    • The get/set/add operations convert to/from PEAR ones as needed
    • Field Detail

      • EMPTY_LIST

        private static final java.util.List<? extends TOP> EMPTY_LIST
        The Constant EMPTY_LIST.
      • typeIndexID

        public static final int typeIndexID
      • type

        public static final int type
      • fsArrayList

        private final java.util.ArrayList<T extends TOP> fsArrayList
        lifecycle - starts as empty array list - becomes non-empty when updated (add) -- used from that point on.
      • fsArray_asList

        private java.util.List<T extends TOP> fsArray_asList
        lifecycle - starts as the empty list - set when _init_from_cas_data() - set to null when update (add/remove) happens.
      • _FeatName_fsArray

        public static final java.lang.String _FeatName_fsArray
        See Also:
        Constant Field Values
      • _FC_fsArray

        private static final java.lang.invoke.CallSite _FC_fsArray
      • _FH_fsArray

        private static final java.lang.invoke.MethodHandle _FH_fsArray
    • Constructor Detail

      • FSArrayList

        protected FSArrayList()
        Never called. Disable default constructor
      • FSArrayList

        public FSArrayList​(TypeImpl type,
                           CASImpl casImpl)
        Internal - constructor used by generator
        Parameters:
        casImpl - the CAS this Feature Structure belongs to
        type - the type of this Feature Structure
      • FSArrayList

        public FSArrayList​(JCas jcas)
        Parameters:
        jcas - JCas to which this Feature Structure belongs
      • FSArrayList

        public FSArrayList​(JCas jcas,
                           int length)
        Make a new ArrayList with an initial size .
        Parameters:
        jcas - The JCas
        length - initial size
    • Method Detail

      • getTypeIndexID

        public int getTypeIndexID()
        Overrides:
        getTypeIndexID in class TOP
        Returns:
        index of the type
      • getFsArray

        private FSArray getFsArray()
        getter for fsArray - gets internal use - holds the contents
        Returns:
        value of the feature
      • setFsArray

        private void setFsArray​(FSArray v)
        setter for fsArray - sets internal use - holds the contents
        Parameters:
        v - value to set into the feature
      • maybeStartUsingArrayList

        private void maybeStartUsingArrayList()
        Maybe start using array list.
      • _save_to_cas_data

        public void _save_to_cas_data()
        Description copied from interface: UimaSerializable
        This method is called by the framework before serialization of an instance of this JCas class. The implementation should save whatever data is needed into Features of this JCas class that can be serialized by UIMA.
        Specified by:
        _save_to_cas_data in interface UimaSerializable
      • gl

        private java.util.List<T> gl()
        gets either the array list object, or a list operating over the original FS Array. Note: these forms will get/set the non Pear form of elements
        Returns:
        the list
      • gl_read_pear

        private java.util.List<T> gl_read_pear​(java.util.List<T> baseItems)
        Supports reading only, no update or remove
        Returns:
        a list backed by gl(), where the items are pear converted
      • get

        public T get​(int i)
        Specified by:
        get in interface java.util.List<T extends TOP>
      • set

        public T set​(int i,
                     T v)
        updates the i-th value of the FSArrayList.
        Specified by:
        set in interface java.util.List<T extends TOP>
        Parameters:
        i - the i
        v - the v
        Returns:
        the t
      • size

        public int size()
        return the size of the array.
        Specified by:
        size in interface java.util.Collection<T extends TOP>
        Specified by:
        size in interface CommonArrayFS<T extends TOP>
        Specified by:
        size in interface java.util.List<T extends TOP>
        Returns:
        the int
      • toArray

        public TOP[] toArray()
        returns TOP[] because can't make array of T Note: converts to pear trampolines.
        Specified by:
        toArray in interface java.util.Collection<T extends TOP>
        Specified by:
        toArray in interface java.util.List<T extends TOP>
      • copyFromArray

        public void copyFromArray​(java.lang.String[] src,
                                  int srcPos,
                                  int destPos,
                                  int length)
        Not supported, will throw UnsupportedOperationException.
        Specified by:
        copyFromArray in interface CommonArrayFS<T extends TOP>
        Parameters:
        src - the src
        srcPos - the src pos
        destPos - the dest pos
        length - the length
      • copyToArray

        public void copyToArray​(int srcPos,
                                java.lang.String[] dest,
                                int destPos,
                                int length)
        Copies an array of Feature Structures to an Array of Strings. The strings are the "toString()" representation of the feature structures. If in Pear context, the Pear form is used.
        Specified by:
        copyToArray in interface CommonArrayFS<T extends TOP>
        Parameters:
        srcPos - The index of the first element to copy.
        dest - The array to copy to.
        destPos - Where to start copying into dest.
        length - The number of elements to copy.
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - If srcPos < 0 or length > size() or destPos + length > destArray.length.
      • create

        public static <E extends TOP,​F extends FeatureStructureFSArrayList<E> create​(JCas jcas,
                                                                                             F[] a)
        Convenience - create a FSArrayList from an existing Array.
        Type Parameters:
        E - generic type of returned FS
        F - generic type of the elements of the array argument
        Parameters:
        jcas - -
        a - -
        Returns:
        -
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<T extends TOP>
        Specified by:
        containsAll in interface java.util.List<T extends TOP>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<T extends TOP>
        Specified by:
        isEmpty in interface CommonArrayFS<T extends TOP>
        Specified by:
        isEmpty in interface java.util.List<T extends TOP>
        Returns:
        true if the array is empty
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<T extends TOP>
        Specified by:
        contains in interface java.util.List<T extends TOP>
      • indexOf

        public int indexOf​(java.lang.Object o)
        Specified by:
        indexOf in interface java.util.List<T extends TOP>
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object o)
        Specified by:
        lastIndexOf in interface java.util.List<T extends TOP>
      • toArray

        public <U> U[] toArray​(U[] a)
        Specified by:
        toArray in interface java.util.Collection<T extends TOP>
        Specified by:
        toArray in interface java.util.List<T extends TOP>
      • add

        public boolean add​(T e)
        Specified by:
        add in interface java.util.Collection<T extends TOP>
        Specified by:
        add in interface java.util.List<T extends TOP>
      • equals

        public boolean equals​(java.lang.Object o)
        Description copied from interface: FeatureStructure
        A feature structure is equal to another feature structure iff it is identical in the underlying representation.
        Specified by:
        equals in interface java.util.Collection<T extends TOP>
        Specified by:
        equals in interface FeatureStructure
        Specified by:
        equals in interface java.util.List<T extends TOP>
        Overrides:
        equals in class FeatureStructureImplC
      • add

        public void add​(int index,
                        T element)
        Specified by:
        add in interface java.util.List<T extends TOP>
      • remove

        public T remove​(int index)
        Specified by:
        remove in interface java.util.List<T extends TOP>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<T extends TOP>
        Specified by:
        remove in interface java.util.List<T extends TOP>
      • hashCode

        public int hashCode()
        Description copied from interface: FeatureStructure
        Will return a hash code that's consistent with equality, i.e., if two FSs are equal, they will also return the same hash code.
        Specified by:
        hashCode in interface java.util.Collection<T extends TOP>
        Specified by:
        hashCode in interface FeatureStructure
        Specified by:
        hashCode in interface java.util.List<T extends TOP>
        Overrides:
        hashCode in class FeatureStructureImplC
        Returns:
        The hash code.
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<T extends TOP>
        Specified by:
        clear in interface java.util.List<T extends TOP>
      • addAll

        public boolean addAll​(java.util.Collection<? extends T> c)
        Specified by:
        addAll in interface java.util.Collection<T extends TOP>
        Specified by:
        addAll in interface java.util.List<T extends TOP>
      • addAll

        public boolean addAll​(int index,
                              java.util.Collection<? extends T> c)
        Specified by:
        addAll in interface java.util.List<T extends TOP>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<T extends TOP>
        Specified by:
        removeAll in interface java.util.List<T extends TOP>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<T extends TOP>
        Specified by:
        retainAll in interface java.util.List<T extends TOP>
      • stream

        public java.util.stream.Stream<T> stream()
        Specified by:
        stream in interface java.util.Collection<T extends TOP>
      • parallelStream

        public java.util.stream.Stream<T> parallelStream()
        Specified by:
        parallelStream in interface java.util.Collection<T extends TOP>
      • listIterator

        public java.util.ListIterator<T> listIterator​(int index)
        Specified by:
        listIterator in interface java.util.List<T extends TOP>
      • listIterator

        public java.util.ListIterator<T> listIterator()
        Specified by:
        listIterator in interface java.util.List<T extends TOP>
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.util.Collection<T extends TOP>
        Specified by:
        iterator in interface java.lang.Iterable<T extends TOP>
        Specified by:
        iterator in interface java.util.List<T extends TOP>
      • subList

        public java.util.List<T> subList​(int fromIndex,
                                         int toIndex)
        Specified by:
        subList in interface java.util.List<T extends TOP>
      • forEach

        public void forEach​(java.util.function.Consumer<? super T> action)
        Specified by:
        forEach in interface java.lang.Iterable<T extends TOP>
      • spliterator

        public java.util.Spliterator<T> spliterator()
        Specified by:
        spliterator in interface java.util.Collection<T extends TOP>
        Specified by:
        spliterator in interface java.lang.Iterable<T extends TOP>
        Specified by:
        spliterator in interface java.util.List<T extends TOP>
      • removeIf

        public boolean removeIf​(java.util.function.Predicate<? super T> filter)
        Specified by:
        removeIf in interface java.util.Collection<T extends TOP>
      • replaceAll

        public void replaceAll​(java.util.function.UnaryOperator<T> operator)
        Specified by:
        replaceAll in interface java.util.List<T extends TOP>
      • sort

        public void sort​(java.util.Comparator<? super T> c)
        Specified by:
        sort in interface java.util.List<T extends TOP>