T
- The type of object which can be read by this listpublic abstract class AbstractStreamBackedList<T extends Readable> extends AbstractSequentialList<T> implements RandomisableList<T>
Modifier and Type | Field and Description |
---|---|
protected Class<T> |
clz
The class from which to generate an instance of items held in the list
|
protected int |
consumed
Number of bytes read
|
protected int |
headerLength
The length (in bytes) of the header which identifies the stream type
|
protected boolean |
isBinary
Does the stream hold binary data (as opposed to ASCII)
|
protected int |
recordLength
The length (in bytes) of each item held in the list
|
protected int |
size
The size of the list
|
modCount
Modifier | Constructor and Description |
---|---|
protected |
AbstractStreamBackedList(InputStream stream,
int size,
boolean isBinary,
int headerLength,
int recordLength,
Class<T> clz)
Instantiate the list and all instance variables.
|
protected |
AbstractStreamBackedList(InputStream stream,
int size,
boolean isBinary,
int headerLength,
int recordLength,
Class<T> clz,
String charset)
Instantiate the list and all instance variables.
|
Modifier and Type | Method and Description |
---|---|
int |
consumed()
Get the number of records consumed so far
|
ListIterator<T> |
listIterator(int index) |
protected T |
newElementInstance()
Override this id your instances can't be constructed with a no-args ctr
|
RandomisableList<T> |
randomSubList(int nelem)
This method creates a random sublist in ram from elements consumed
from the target list.
|
protected T |
readRecord(DataInput input) |
protected T |
readRecordASCII(Scanner br) |
int |
remaining()
Get the number of records remaining in the stream
|
int |
size() |
add, addAll, get, iterator, remove, set
add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, subList, toArray, toArray
parallelStream, removeIf, stream
protected final Class<T extends Readable> clz
protected final int size
protected final boolean isBinary
protected final int headerLength
protected final int recordLength
protected int consumed
protected AbstractStreamBackedList(InputStream stream, int size, boolean isBinary, int headerLength, int recordLength, Class<T> clz)
stream
- the streamsize
- number of elementsisBinary
- is the stream binaryheaderLength
- how long is the headerrecordLength
- how long is each elementclz
- what class instantiates elements in the listUnsupportedEncodingException
protected AbstractStreamBackedList(InputStream stream, int size, boolean isBinary, int headerLength, int recordLength, Class<T> clz, String charset) throws UnsupportedEncodingException
stream
- the streamsize
- number of elementsisBinary
- is the stream binaryheaderLength
- how long is the headerrecordLength
- how long is each elementcharset
- if the stream is not binary, the charsetName which is sent to the internal InputStreamReaderclz
- what class instantiates elements in the listUnsupportedEncodingException
protected T newElementInstance()
protected T readRecord(DataInput input) throws IOException
IOException
protected T readRecordASCII(Scanner br) throws IOException
IOException
public ListIterator<T> listIterator(int index)
listIterator
in interface List<T extends Readable>
listIterator
in class AbstractSequentialList<T extends Readable>
public int size()
public int consumed()
public int remaining()
public RandomisableList<T> randomSubList(int nelem)
randomSubList
in interface RandomisableList<T extends Readable>
nelem
- number of elements to extractRandomisableList.randomSubList(int)