public abstract class FileAsList extends AbstractList implements Commitable
FileAsList creates a writable List
implementation backed by a random access file. There is a
restriction on the record length that the string representation of
that integer may not be longer than 4 bytes. This is because a
fixed 4 byte leader is used to encode the record length in the
file.modCount| Constructor and Description |
|---|
FileAsList(File mappedFile,
boolean mutable)
Creates a new
FileAsList instance from an existing
backing file. |
FileAsList(File mappedFile,
int recordLength)
Creates a new
FileAsList and corresponding backing
file. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Object o) |
void |
clear() |
void |
commit()
commit commits pending changes. |
protected abstract void |
generateRecord(byte[] buffer,
Object item) |
Object |
get(int indx) |
abstract Comparator |
getComparator() |
Iterator |
iterator() |
protected abstract Object |
parseRecord(byte[] buffer) |
byte[] |
rawGet(int indx)
rawGet reads the record at the specified index as
a raw byte array. |
void |
rollback()
rollback reverses pending changes to restore
initial (or prior commit) state. |
Object |
set(int indx,
Object o)
This always returns null, not the previous object.
|
int |
size() |
add, addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, subListaddAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringpublic FileAsList(File mappedFile, int recordLength) throws IOException
FileAsList and corresponding backing
file.mappedFile - a File used to back the
list. This file must not already exist.recordLength - an int byte record length.IOException - if an error occurs.public FileAsList(File mappedFile, boolean mutable) throws IOException
FileAsList instance from an existing
backing file.mappedFile - a File used to back the
list. This file must already exist.mutable - true if this list should support edits, false otherwiseIOException - if an error occurs.public byte[] rawGet(int indx)
rawGet reads the record at the specified index as
a raw byte array.indx - an int list index.byte [] array containing the raw record
data.public Object get(int indx)
get in interface Listget in class AbstractListpublic int size()
size in interface Collectionsize in interface Listsize in class AbstractCollectionpublic boolean add(Object o)
add in interface Collectionadd in interface Listadd in class AbstractListpublic Object set(int indx, Object o)
set in interface Listset in class AbstractListpublic void clear()
clear in interface Collectionclear in interface Listclear in class AbstractListpublic void commit()
Commitablecommit commits pending changes.commit in interface Commitablepublic void rollback()
Commitablerollback reverses pending changes to restore
initial (or prior commit) state. This always succededs or raises an
unchecked exception.
If the rollback fails, you must raise an AssertionFailure.rollback in interface Commitableprotected abstract Object parseRecord(byte[] buffer)
protected abstract void generateRecord(byte[] buffer, Object item) throws IOException
IOExceptionpublic abstract Comparator getComparator()
public Iterator iterator()
iterator in interface Iterableiterator in interface Collectioniterator in interface Listiterator in class AbstractListCopyright © 2014 BioJava. All rights reserved.