public final class IndexCollection extends java.util.AbstractList<IndexValue> implements java.util.List<IndexValue>, java.io.Externalizable
A List of IndexValues which may be used to query the StateServer object
store for the set of objects with metadata matching the (positional) values specified in the
IndexCollection.
IndexCollections are fixed-length Lists where the length is defined by
the StateServer implementation. Not all index positions need have values. That is, an
IndexCollection may be sparsely filled in.
Since the index position of an item in an IndexCollection is semantically key, this
List implementation does not support List.add(E) or List.remove(java.lang.Object)
operations. It does support List.clear() by resetting the value in all index
positions to null. Similarly, it supports selective clearing via
clearRange(int, int).
| Modifier and Type | Field and Description |
|---|---|
static int |
MaxIndexValues
The fixed number of
IndexValues an IndexCollection may hold. |
| Constructor and Description |
|---|
IndexCollection() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(IndexValue o)
Adding to the end of an
IndexCollection is not supported. |
void |
add(int index,
IndexValue element)
Inserts the specified
IndexValue at the specified position in this list. |
void |
clear()
Clears all elements in the
IndexCollection by setting the IndexValue in
each index position to null. |
void |
clearRange(int fromIndex,
int toIndex)
Clears a range of elements in the
IndexCollection by setting the
IndexValues in the corresponding index positions to null. |
IndexValue |
get(int index)
Gets the element at the specified index.
|
boolean |
isEmpty()
|
void |
readExternal(java.io.ObjectInput in) |
IndexValue |
remove(int index)
Removes the element at the specified index of the
IndexCollection. |
protected void |
removeRange(int fromIndex,
int toIndex)
Removes from the list all of the elements whose index is between fromIndex
(inclusive) to
toIndex (exclusive). |
IndexValue |
set(int index,
IndexValue element)
Replaces the element at the specified position in this list with the specified element
(optional operation).
|
int |
size()
Gets the number of elements in the
IndexCollection. |
void |
writeExternal(java.io.ObjectOutput out) |
addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, subListaddAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitpublic static final int MaxIndexValues
IndexValues an IndexCollection may hold. This value
is currently 8.public IndexValue get(int index)
If no element has been assigned to a given index position, the get operation will return
null.
get in interface java.util.List<IndexValue>get in class java.util.AbstractList<IndexValue>index - The index of the element to get or set.null if no element has
been assigned to the given index position.java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 or index >= size()).public IndexValue set(int index, IndexValue element)
set in interface java.util.List<IndexValue>set in class java.util.AbstractList<IndexValue>index - the index of element to replace.element - the IndexValue to be stored at the specified position.IndexValue previously at the specified position.java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).public int size()
IndexCollection. Since the collection is
fixed-size, this method always returns MaxIndexValues.size in interface java.util.Collection<IndexValue>size in interface java.util.List<IndexValue>size in class java.util.AbstractCollection<IndexValue>MaxIndexValuespublic void clear()
IndexCollection by setting the IndexValue in
each index position to null.clear in interface java.util.Collection<IndexValue>clear in interface java.util.List<IndexValue>clear in class java.util.AbstractList<IndexValue>public void clearRange(int fromIndex,
int toIndex)
Clears a range of elements in the IndexCollection by setting the
IndexValues in the corresponding index positions to null.
fromIndex, inclusive, to index
toIndex, exclusive. (If fromIndex==toIndex, the range to be
cleared is empty.)fromIndex - the index of the first element (inclusive) to be cleared.toIndex - the index of the last element (exclusive) to be cleared.java.lang.IllegalArgumentException - if fromIndex > toIndexjava.lang.ArrayIndexOutOfBoundsException - if fromIndex < 0 or toIndex > size()public boolean isEmpty()
isEmpty in interface java.util.Collection<IndexValue>isEmpty in interface java.util.List<IndexValue>isEmpty in class java.util.AbstractCollection<IndexValue>true if this IndexCollection contains no (non-null)
IndexValues. Otherwise, false.public IndexValue remove(int index)
IndexCollection. All
elements in the list following the removed element are moved 1 position to the left. The
element at MaxIndexValues - 1 is set to null.remove in interface java.util.List<IndexValue>remove in class java.util.AbstractList<IndexValue>index - The zero-based index of the element to remove.protected void removeRange(int fromIndex,
int toIndex)
toIndex (exclusive). All elements in the list following
the removed elements are moved toIndex - fromIndex positions to the left.
The elements at positions (MaxIndexValues - (toIndex - fromIndex))
through MaxIndexValues-1) are set to null.removeRange in class java.util.AbstractList<IndexValue>fromIndex - the index of the first element (inclusive) to be removed.toIndex - the index of the last element (exclusive) to be removed.java.lang.IllegalArgumentException - if fromIndex > toIndexjava.lang.ArrayIndexOutOfBoundsException - if fromIndex < 0 or toIndex > size()public void add(int index,
IndexValue element)
throws java.lang.IndexOutOfBoundsException
Inserts the specified IndexValue at the specified position in this list. Shifts
the element currently at that position and any subsequent elements to the right (adds
one to their indices). The element at position
is removed from the collection.
MaxIndexValues-1
IndexCollections are fixed-length Lists, index must be
less than size().add in interface java.util.List<IndexValue>add in class java.util.AbstractList<IndexValue>index - index at which the specified element is to be inserted.element - the IndexValue to be inserted.java.lang.IndexOutOfBoundsException - index is out of range (index <
0 || index >= size()).public boolean add(IndexValue o)
IndexCollection is not supported.add in interface java.util.Collection<IndexValue>add in interface java.util.List<IndexValue>add in class java.util.AbstractList<IndexValue>java.lang.UnsupportedOperationException - when adding to the end of the IndexCollectionadd(int, IndexValue)public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOException