org.biojava.utils
Class FileAsList
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--org.biojava.utils.FileAsList
- All Implemented Interfaces:
- java.util.Collection, Commitable, java.util.List
- public abstract class FileAsList
- extends java.util.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.
- Author:
- Unknown, Keith James, Greg Cox
| Fields inherited from class java.util.AbstractList |
modCount |
|
Constructor Summary |
FileAsList(java.io.File mappedFile,
boolean mutable)
Creates a new FileAsList instance from an existing
backing file. |
FileAsList(java.io.File mappedFile,
int recordLength)
Creates a new FileAsList and corresponding backing
file. |
|
Method Summary |
boolean |
add(java.lang.Object o)
|
void |
clear()
|
void |
commit()
commit commits pending changes. |
protected abstract void |
generateRecord(byte[] buffer,
java.lang.Object item)
|
java.lang.Object |
get(int indx)
|
abstract java.util.Comparator |
getComparator()
|
java.util.Iterator |
iterator()
|
protected abstract java.lang.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. |
java.lang.Object |
set(int indx,
java.lang.Object o)
This always returns null, not the previous object. |
int |
size()
|
| Methods inherited from class java.util.AbstractList |
add, addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, subList |
| Methods inherited from class java.util.AbstractCollection |
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray |
FileAsList
public FileAsList(java.io.File mappedFile,
int recordLength)
throws java.io.IOException
- Creates a new
FileAsList and corresponding backing
file.
- Parameters:
mappedFile - a File used to back the
list. This file must not already exist.recordLength - an int byte record length.
- Throws:
java.io.IOException - if an error occurs.
FileAsList
public FileAsList(java.io.File mappedFile,
boolean mutable)
throws java.io.IOException
- Creates a new
FileAsList instance from an existing
backing file.
- Parameters:
mappedFile - a File used to back the
list. This file must already exist.mutable - true if this list should support edits, false otherwise
- Throws:
java.io.IOException - if an error occurs.
rawGet
public byte[] rawGet(int indx)
rawGet reads the record at the specified index as
a raw byte array.
- Parameters:
indx - an int list index.
- Returns:
- a
byte [] array containing the raw record
data.
get
public java.lang.Object get(int indx)
- Specified by:
get in interface java.util.List- Specified by:
get in class java.util.AbstractList
size
public int size()
- Specified by:
size in interface java.util.List- Specified by:
size in class java.util.AbstractCollection
add
public boolean add(java.lang.Object o)
- Specified by:
add in interface java.util.List- Overrides:
add in class java.util.AbstractList
set
public java.lang.Object set(int indx,
java.lang.Object o)
- This always returns null, not the previous object.
- Specified by:
set in interface java.util.List- Overrides:
set in class java.util.AbstractList
clear
public void clear()
- Specified by:
clear in interface java.util.List- Overrides:
clear in class java.util.AbstractList
commit
public void commit()
- Description copied from interface:
Commitable
commit commits pending changes.
- Specified by:
commit in interface Commitable
rollback
public void rollback()
- Description copied from interface:
Commitable
rollback reverses pending changes to restore
initial (or prior commit) state.
- Specified by:
rollback in interface Commitable
parseRecord
protected abstract java.lang.Object parseRecord(byte[] buffer)
generateRecord
protected abstract void generateRecord(byte[] buffer,
java.lang.Object item)
throws NestedException
NestedException
getComparator
public abstract java.util.Comparator getComparator()
iterator
public java.util.Iterator iterator()
- Specified by:
iterator in interface java.util.List- Overrides:
iterator in class java.util.AbstractList