Package org.apache.uima.jcas.cas
Class FSArrayList<T extends TOP>
- java.lang.Object
-
- org.apache.uima.cas.impl.FeatureStructureImplC
-
- org.apache.uima.jcas.cas.TOP
-
- org.apache.uima.jcas.cas.FSArrayList<T>
-
- 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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.uima.cas.impl.FeatureStructureImplC
FeatureStructureImplC.PrintReferences
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.invoke.CallSite
_FC_fsArray
static java.lang.String
_FeatName_fsArray
private static java.lang.invoke.MethodHandle
_FH_fsArray
static java.lang.String
_TypeName
private static java.util.List<? extends TOP>
EMPTY_LIST
The Constant EMPTY_LIST.private java.util.List<T>
fsArray_asList
lifecycle - starts as the empty list - set when _init_from_cas_data() - set to null when update (add/remove) happens.private java.util.ArrayList<T>
fsArrayList
lifecycle - starts as empty array list - becomes non-empty when updated (add) -- used from that point on.static int
type
static int
typeIndexID
-
Fields inherited from class org.apache.uima.jcas.cas.TOP
_singleton
-
Fields inherited from class org.apache.uima.cas.impl.FeatureStructureImplC
_casView, _id, DISABLE_RUNTIME_FEATURE_VALIDATION, DISABLE_RUNTIME_FEATURE_VALUE_VALIDATION, IS_ENABLE_RUNTIME_FEATURE_VALIDATION, IS_ENABLE_RUNTIME_FEATURE_VALUE_VALIDATION, IS_V2_PRETTY_PRINT, V2_PRETTY_PRINT
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FSArrayList()
Never called.FSArrayList(TypeImpl type, CASImpl casImpl)
Internal - constructor used by generatorFSArrayList(JCas jcas)
FSArrayList(JCas jcas, int length)
Make a new ArrayList with an initial size .
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
_init_from_cas_data()
void
_save_to_cas_data()
This method is called by the framework before serialization of an instance of this JCas class.FeatureStructureImplC
_superClone()
FeatureStructure[]
_toArrayForSelect()
void
add(int index, T element)
boolean
add(T e)
boolean
addAll(int index, java.util.Collection<? extends T> c)
boolean
addAll(java.util.Collection<? extends T> c)
void
clear()
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> c)
<E extends FeatureStructure>
voidcopyFromArray(E[] src, int srcPos, int destPos, int length)
Copy from array.void
copyFromArray(java.lang.String[] src, int srcPos, int destPos, int length)
Not supported, will throw UnsupportedOperationException.<E extends FeatureStructure>
voidcopyToArray(int srcPos, E[] dest, int destPos, int length)
Copy to array.void
copyToArray(int srcPos, java.lang.String[] dest, int destPos, int length)
Copies an array of Feature Structures to an Array of Strings.void
copyValuesFrom(CommonArrayFS v)
Copy values from another array of the same kindstatic <E extends TOP,F extends FeatureStructure>
FSArrayList<E>create(JCas jcas, F[] a)
Convenience - create a FSArrayList from an existing Array.boolean
equals(java.lang.Object o)
A feature structure is equal to another feature structure iff it is identical in the underlying representation.void
forEach(java.util.function.Consumer<? super T> action)
T
get(int i)
private FSArray
getFsArray()
getter for fsArray - gets internal use - holds the contentsint
getTypeIndexID()
private java.util.List<T>
gl()
gets either the array list object, or a list operating over the original FS Array.private java.util.List<T>
gl_read_pear(java.util.List<T> baseItems)
Supports reading only, no update or removeint
hashCode()
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.int
indexOf(java.lang.Object o)
boolean
isEmpty()
java.util.Iterator<T>
iterator()
int
lastIndexOf(java.lang.Object o)
java.util.ListIterator<T>
listIterator()
java.util.ListIterator<T>
listIterator(int index)
private void
maybeStartUsingArrayList()
Maybe start using array list.java.util.stream.Stream<T>
parallelStream()
T
remove(int index)
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
removeIf(java.util.function.Predicate<? super T> filter)
void
replaceAll(java.util.function.UnaryOperator<T> operator)
boolean
retainAll(java.util.Collection<?> c)
T
set(int i, T v)
updates the i-th value of the FSArrayList.private void
setFsArray(FSArray v)
setter for fsArray - sets internal use - holds the contentsint
size()
return the size of the array.void
sort(java.util.Comparator<? super T> c)
java.util.Spliterator<T>
spliterator()
java.util.stream.Stream<T>
stream()
java.util.List<T>
subList(int fromIndex, int toIndex)
TOP[]
toArray()
returns TOP[] because can't make array of T Note: converts to pear trampolines.<U> U[]
toArray(U[] a)
java.lang.String
toString()
-
Methods inherited from class org.apache.uima.jcas.cas.TOP
_createJCasHashMapReserve, _createSearchKey
-
Methods inherited from class org.apache.uima.cas.impl.FeatureStructureImplC
_copyIntAndRefArraysEqTypesFrom, _copyIntAndRefArraysFrom, _copyIntArrayEqTypesFrom, _getBooleanValueNc, _getBooleanValueNc, _getByteValueNc, _getByteValueNc, _getDoubleValueNc, _getDoubleValueNc, _getFeatFromAdjOffset, _getFeatureValueNc, _getFeatureValueNc, _getFloatValueNc, _getFloatValueNc, _getIntLikeValue, _getIntValueNc, _getIntValueNc, _getLongValueNc, _getLongValueNc, _getRefValueCommon, _getShortValueNc, _getShortValueNc, _getStringValueNc, _getStringValueNc, _getTypeCode, _getTypeImpl, _getView, _id, _inSetSortedIndex, _isJCasHashMapReserve, _isPearTrampoline, _maybeGetBaseForPearFs, _maybeGetBaseForPearFs, _maybeGetPearFs, _maybeGetPearFs, _resetInSetSortedIndex, _setBooleanValueNcNj, _setBooleanValueNcNj, _setBooleanValueNfc, _setByteValueNcNj, _setByteValueNcNj, _setByteValueNfc, _setDoubleValueNcNj, _setDoubleValueNcNj, _setDoubleValueNfc, _setFeatureValueNcNj, _setFeatureValueNcNj, _setFeatureValueNcWj, _setFloatValueNcNj, _setFloatValueNcNj, _setFloatValueNfc, _setInSetSortedIndexed, _setIntLikeValue, _setIntLikeValueNcNj, _setIntValueCJ, _setIntValueNcNj, _setIntValueNcNj, _setIntValueNfc, _setIntValueNfcCJ, _setJCasHashMapReserve, _setLongValueCJ, _setLongValueNcNj, _setLongValueNcNj, _setLongValueNfc, _setLongValueNfcCJ, _setPearTrampoline, _setRefValueCJ, _setRefValueCommon, _setRefValueCommonWj, _setRefValueNfcCJ, _setShortValueNcNj, _setShortValueNcNj, _setShortValueNfc, _setStringValueNcNj, _setStringValueNcWj, _setStringValueNfc, _setTypeImpl, addStringOrPrimitive, addToIndexes, addToIndexes, addToIndexes, clone, compare, getAddress, getBooleanValue, getByteValue, getCAS, getCASImpl, getDoubleValue, getFeatureValue, getFeatureValueAsString, getFloatValue, getIntValue, getLongValue, getLowLevelCas, getShortValue, getStringValue, getType, prettyPrint, prettyPrint, prettyPrint, prettyPrint, prettyPrint, prettyPrint, prettyPrintShort, removeFromIndexes, removeFromIndexes, removeFromIndexes, setBooleanValue, setByteValue, setDoubleValue, setFeatureValue, setFeatureValueFromString, setFloatValue, setIntValue, setLongValue, setShortValue, setStringValue, toShortString, toString, wrapGetIntCatchException
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.uima.cas.CommonArrayFS
getValuesAsCommaSeparatedString, toStringArray
-
Methods inherited from interface org.apache.uima.cas.FeatureStructure
_getTypeCode, _id, clone, getAddress, getBooleanValue, getByteValue, getCAS, getDoubleValue, getFeatureValue, getFeatureValueAsString, getFloatValue, getIntValue, getJCas, getLongValue, getShortValue, getStringValue, getType, setBooleanValue, setByteValue, setDoubleValue, setFeatureValue, setFeatureValueFromString, setFloatValue, setIntValue, setLongValue, setShortValue, setStringValue
-
Methods inherited from interface org.apache.uima.jcas.cas.SelectViaCopyToArray
_getView, select, select, select, select, select
-
Methods inherited from interface org.apache.uima.UimaSerializable
_reset_cas_data, clone
-
Methods inherited from interface org.apache.uima.UimaSerializableFSs
_save_fsRefs_to_cas_data
-
-
-
-
Field Detail
-
EMPTY_LIST
private static final java.util.List<? extends TOP> EMPTY_LIST
The Constant EMPTY_LIST.
-
_TypeName
public static final java.lang.String _TypeName
- See Also:
- Constant Field Values
-
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 totype
- 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 JCaslength
- initial size
-
-
Method Detail
-
getTypeIndexID
public int getTypeIndexID()
- Overrides:
getTypeIndexID
in classTOP
- 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.
-
_init_from_cas_data
public void _init_from_cas_data()
- Specified by:
_init_from_cas_data
in interfaceUimaSerializable
-
_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 interfaceUimaSerializable
-
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
-
size
public int size()
return the size of the array.
-
copyFromArray
public <E extends FeatureStructure> void copyFromArray(E[] src, int srcPos, int destPos, int length)
Copy from array.- Type Parameters:
E
- the type of the source array being copied from- Parameters:
src
- -srcPos
- -destPos
- -length
- -- See Also:
ArrayFS.copyFromArray(FeatureStructure[], int, int, int)
-
copyToArray
public <E extends FeatureStructure> void copyToArray(int srcPos, E[] dest, int destPos, int length)
Copy to array.- Type Parameters:
E
- the type of the elements of the Array being copied into- Parameters:
srcPos
- -dest
- -destPos
- -length
- -- See Also:
ArrayFS.copyToArray(int, FeatureStructure[], int, int)
-
toArray
public TOP[] toArray()
returns TOP[] because can't make array of T Note: converts to pear trampolines.
-
_toArrayForSelect
public FeatureStructure[] _toArrayForSelect()
- Specified by:
_toArrayForSelect
in interfaceSelectViaCopyToArray<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 interfaceCommonArrayFS<T extends TOP>
- Parameters:
src
- the srcsrcPos
- the src posdestPos
- the dest poslength
- 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 interfaceCommonArrayFS<T extends TOP>
- Parameters:
srcPos
- The index of the first element to copy.dest
- The array to copy to.destPos
- Where to start copying intodest
.length
- The number of elements to copy.- Throws:
java.lang.ArrayIndexOutOfBoundsException
- IfsrcPos < 0
orlength > size()
ordestPos + length > destArray.length
.
-
copyValuesFrom
public void copyValuesFrom(CommonArrayFS v)
Description copied from interface:CommonArrayFS
Copy values from another array of the same kind- Specified by:
copyValuesFrom
in interfaceCommonArrayFS<T extends TOP>
- Parameters:
v
- the other array
-
create
public static <E extends TOP,F extends FeatureStructure> FSArrayList<E> create(JCas jcas, F[] a)
Convenience - create a FSArrayList from an existing Array.- Type Parameters:
E
- generic type of returned FSF
- generic type of the elements of the array argument- Parameters:
jcas
- -a
- -- Returns:
- -
-
_superClone
public FeatureStructureImplC _superClone()
- Specified by:
_superClone
in interfaceUimaSerializable
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(java.lang.Object o)
-
indexOf
public int indexOf(java.lang.Object o)
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
-
toArray
public <U> U[] toArray(U[] a)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classFeatureStructureImplC
-
add
public boolean add(T e)
-
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 interfacejava.util.Collection<T extends TOP>
- Specified by:
equals
in interfaceFeatureStructure
- Specified by:
equals
in interfacejava.util.List<T extends TOP>
- Overrides:
equals
in classFeatureStructureImplC
-
add
public void add(int index, T element)
-
remove
public boolean remove(java.lang.Object o)
-
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 interfacejava.util.Collection<T extends TOP>
- Specified by:
hashCode
in interfaceFeatureStructure
- Specified by:
hashCode
in interfacejava.util.List<T extends TOP>
- Overrides:
hashCode
in classFeatureStructureImplC
- Returns:
- The hash code.
-
clear
public void clear()
-
addAll
public boolean addAll(java.util.Collection<? extends T> c)
-
addAll
public boolean addAll(int index, java.util.Collection<? extends T> c)
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
stream
public java.util.stream.Stream<T> stream()
-
parallelStream
public java.util.stream.Stream<T> parallelStream()
-
listIterator
public java.util.ListIterator<T> listIterator(int index)
-
listIterator
public java.util.ListIterator<T> listIterator()
-
iterator
public java.util.Iterator<T> iterator()
-
subList
public java.util.List<T> subList(int fromIndex, int toIndex)
-
forEach
public void forEach(java.util.function.Consumer<? super T> action)
-
spliterator
public java.util.Spliterator<T> spliterator()
-
removeIf
public boolean removeIf(java.util.function.Predicate<? super T> filter)
-
replaceAll
public void replaceAll(java.util.function.UnaryOperator<T> operator)
-
-