de.vc.io

## Class FileObjectStorage<T>

- java.lang.Object
- - de.vc.io.FileObjectStorage<T>

-     public class FileObjectStorage<T>
      extends java.lang.Object

  The file object storage stores and gets objects from a file. This can be used to swap objects to disc.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileObjectStorage()` Creates a new file object storage in a temporary file (created by File.tempFile).
    `FileObjectStorage(java.io.File storageFile)` Creates a new file object storage.
    `FileObjectStorage(java.io.File storageFile, boolean deleteOnFinalize)` Creates a new file object storage.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `appendObject(T o)`
    `protected T` | `bytes2object(byte[] bytes)`
    `void` | `clear()`
    `protected void` | `createIndex()`
    `protected void` | `finalize()`
    `protected java.io.RandomAccessFile` | `getAccess()`
    `java.util.Iterator<T>` | `getIterator()`
    `T` | `getObject(int index)`
    `java.io.File` | `getStorageFile()`
    `protected byte[]` | `object2bytes(T o)`
    `void` | `setDeleteOnFinalize(boolean delete)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FileObjectStorage

          public FileObjectStorage()
                            throws java.io.IOException

      Creates a new file object storage in a temporary file (created by File.tempFile). File is deleted automatically while finalizing.
      Throws:
        `java.io.IOException` - Is thrown if creating temp-file failed.

    - #### FileObjectStorage

          public FileObjectStorage(java.io.File storageFile)

      Creates a new file object storage. File is NOT deleted automatically while finalizing.
      Parameters:
        `storageFile` - File for storing objects.

    - #### FileObjectStorage

          public FileObjectStorage(java.io.File storageFile,
                           boolean deleteOnFinalize)

      Creates a new file object storage.
      Parameters:
        `storageFile` - File for storing objects.
        `deleteOnFinalize` - true, file is deleted during finalizing.

  - ### Method Detail

    - #### getStorageFile

          public java.io.File getStorageFile()

    - #### setDeleteOnFinalize

          public void setDeleteOnFinalize(boolean delete)

    - #### appendObject

          public void appendObject(T o)
                            throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getObject

          public T getObject(int index)

    - #### getIterator

          public java.util.Iterator<T> getIterator()

    - #### clear

          public void clear()

    - #### getAccess

          protected java.io.RandomAccessFile getAccess()
                                                throws java.io.FileNotFoundException

      Throws:
        `java.io.FileNotFoundException`

    - #### object2bytes

          protected byte[] object2bytes(T o)
                                 throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### bytes2object

          protected T bytes2object(byte[] bytes)
                            throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### finalize

          protected void finalize()
                           throws java.lang.Throwable

      Overrides:
        `finalize` in class `java.lang.Object`
      Throws:
        `java.lang.Throwable`

    - #### createIndex

          protected final void createIndex()

© 2003-2011 by Sascha Schmidt (vision-cloud.de). All Rights Reserved.