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, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
public 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 List
get
in class AbstractList
public int size()
size
in interface Collection
size
in interface List
size
in class AbstractCollection
public boolean add(Object o)
add
in interface Collection
add
in interface List
add
in class AbstractList
public Object set(int indx, Object o)
set
in interface List
set
in class AbstractList
public void clear()
clear
in interface Collection
clear
in interface List
clear
in class AbstractList
public void commit()
Commitable
commit
commits pending changes.commit
in interface Commitable
public void rollback()
Commitable
rollback
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 Commitable
protected abstract Object parseRecord(byte[] buffer)
protected abstract void generateRecord(byte[] buffer, Object item) throws IOException
IOException
public abstract Comparator getComparator()
public Iterator iterator()
iterator
in interface Iterable
iterator
in interface Collection
iterator
in interface List
iterator
in class AbstractList
Copyright © 2014 BioJava. All rights reserved.