org.simantics.databoard.file
Class FileList<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<T>
          extended by org.simantics.databoard.file.RandomAccessBinaryList<T>
              extended by org.simantics.databoard.file.FileList<T>
All Implemented Interfaces:
java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>, java.util.RandomAccess, IFileList<T>

public class FileList<T>
extends RandomAccessBinaryList<T>
implements IFileList<T>, java.util.RandomAccess

FileList is a file based implementation of a List collection. add() serializes the object to a file and get() deserializes.

Set, remove, insert and add operations flushes modifications to disk before returning.

Each operation may throw RuntimeIOException

Entry position index is on open if the file has variable width data type (eg. String). The entire file is scanned through.

Author:
Toni Kalajainen

Constructor Summary
FileList(java.io.File file)
          Create new random access list of Variants (Object) backed by a file
FileList(java.io.File file, Binding binding)
          Create new random access list backed by a file
FileList(java.io.File file, Binding binding, long startPos)
          Create new random access list backed by a file using the default binary serialization.
FileList(java.io.File file, Binding binding, long startPos, SerializationFormat format)
          Create new random access list backed by a file
FileList(java.io.File file, java.lang.Class<T> clazz)
          Create new random access list backed by a file
FileList(java.io.File file, java.lang.Class<T> clazz, long startPos)
          Create new random access list backed by a file
FileList(java.lang.String file, Binding binding)
          Create new random access list backed by a file
FileList(java.lang.String file, java.lang.Class<T> clazz)
          Create new random access list backed by a file
 
Method Summary
 void close()
          Flushes the caches and closes the file handle.
 java.io.File getFile()
          Get the mapped file
 
Methods inherited from class org.simantics.databoard.file.RandomAccessBinaryList
add, addAll, addAll, get, getBinding, isOpen, remove, removeRange, set, setAll, size
 
Methods inherited from class java.util.AbstractList
add, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.simantics.databoard.file.IFileList
getBinding, removeRange
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 

Constructor Detail

FileList

public FileList(java.io.File file)
         throws java.io.IOException,
                BindingConstructionException,
                SerializerConstructionException,
                SerializationException
Create new random access list of Variants (Object) backed by a file

Parameters:
file -
Throws:
java.io.IOException
BindingConstructionException
SerializationException
SerializerConstructionException

FileList

public FileList(java.io.File file,
                java.lang.Class<T> clazz)
         throws java.io.IOException,
                BindingConstructionException,
                SerializerConstructionException,
                SerializationException
Create new random access list backed by a file

Parameters:
file -
clazz -
Throws:
java.io.IOException
BindingConstructionException
SerializationException
SerializerConstructionException

FileList

public FileList(java.lang.String file,
                java.lang.Class<T> clazz)
         throws java.io.IOException,
                BindingConstructionException,
                SerializerConstructionException,
                SerializationException
Create new random access list backed by a file

Parameters:
file -
clazz -
Throws:
java.io.IOException
BindingConstructionException
SerializationException
SerializerConstructionException

FileList

public FileList(java.lang.String file,
                Binding binding)
         throws java.io.IOException,
                SerializerConstructionException,
                SerializationException
Create new random access list backed by a file

Parameters:
file -
binding -
Throws:
java.io.IOException
SerializationException
SerializerConstructionException

FileList

public FileList(java.io.File file,
                Binding binding)
         throws java.io.IOException,
                SerializerConstructionException,
                SerializationException
Create new random access list backed by a file

Parameters:
file -
binding -
Throws:
java.io.IOException
SerializationException
SerializerConstructionException

FileList

public FileList(java.io.File file,
                java.lang.Class<T> clazz,
                long startPos)
         throws java.io.IOException,
                BindingConstructionException,
                SerializerConstructionException,
                SerializationException
Create new random access list backed by a file

Parameters:
file -
clazz -
startPos -
Throws:
java.io.IOException
BindingConstructionException
SerializationException
SerializerConstructionException

FileList

public FileList(java.io.File file,
                Binding binding,
                long startPos)
         throws java.io.IOException,
                SerializationException,
                SerializerConstructionException
Create new random access list backed by a file using the default binary serialization.

Parameters:
file - file
binding -
startPos - The position of the first sample in file
Throws:
java.io.IOException
SerializationException - Error with the file, could not build entry index table
SerializerConstructionException

FileList

public FileList(java.io.File file,
                Binding binding,
                long startPos,
                SerializationFormat format)
         throws java.io.IOException,
                SerializerConstructionException,
                SerializationException
Create new random access list backed by a file

Parameters:
file - file
binding -
startPos - The position of the first sample in file
format - serialization format
Throws:
java.io.IOException
SerializerConstructionException - could not create serializer, never thrown with BinarySerializationFormat
SerializationException - Error with the file, could not build entry index
Method Detail

close

public void close()
Flushes the caches and closes the file handle.

Specified by:
close in interface IFileList<T>
Overrides:
close in class RandomAccessBinaryList<T>

getFile

public java.io.File getFile()
Description copied from interface: IFileList
Get the mapped file

Specified by:
getFile in interface IFileList<T>
Overrides:
getFile in class RandomAccessBinaryList<T>
Returns:
file