Package db.buffers

# Class BufferFileAdapter

java.lang.Object
db.buffers.BufferFileAdapter

All Implemented Interfaces:
  `BufferFile`

Direct Known Subclasses:
  `ManagedBufferFileAdapter`

public class BufferFileAdapter extends Object implements BufferFile
`BufferFileAdapter` provides a BufferFile implementation which wraps a BufferFileHandle.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BufferFileAdapter(BufferFileHandle remoteBufferFile)`
  Constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clearParameters()`
  Deletes all parameters
  `void`
  `close()`
  Close the buffer file.
  `boolean`
  `delete()`
  Delete this buffer file if writable.
  `void`
  `dispose()`
  Dispose of this buffer file object.
  `DataBuffer`
  `get(DataBuffer buf, int index)`
  Get the specified buffer.
  `int`
  `getBufferSize()`
  Return the actual size of a user data buffer.
  `int[]`
  `getFreeIndexes()`
  Returns the list of free indexes sorted by value.
  `int`
  `getIndexCount()`
  Returns the number of allocated buffer indexes.
  `int`
  `getParameter(String name)`
  Get a the stored value for a named parameter.
  `String[]`
  `getParameterNames()`
  Returns a list of all parameter names.
  `boolean`
  `isReadOnly()`
  Returns true if this file may not be modified via the buffer put method.
  `boolean`
  `isRemote()`
  Determine if this file is remotely accessed
  `void`
  `put(DataBuffer buf, int index)`
  Store a data buffer at the specified block index.
  `void`
  `setFreeIndexes(int[] indexes)`
  Sets the list of free buffer indexes.
  `void`
  `setParameter(String name, int value)`
  Set the integer value for a named parameter.
  `boolean`
  `setReadOnly()`
  If file is open read-write, the modified contents are flushed and the file re-opened as read-only.

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

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

- ## Constructor Details

  - ### BufferFileAdapter

    public BufferFileAdapter(BufferFileHandle remoteBufferFile)
    Constructor.
    Parameters:
      `remoteBufferFile` - remote buffer file handle

- ## Method Details

  - ### getParameter

    public int getParameter(String name) throws NoSuchElementException, IOException
    Description copied from interface: `BufferFile`
    Get a the stored value for a named parameter.
    Specified by:
      `getParameter` in interface `BufferFile`
    Parameters:
      `name` - parameter name
    Returns:
      integer value
    Throws:
      `NoSuchElementException` - thrown if parameter not found
      `IOException`

  - ### setParameter

    public void setParameter(String name, int value) throws IOException
    Description copied from interface: `BufferFile`
    Set the integer value for a named parameter.
    Specified by:
      `setParameter` in interface `BufferFile`
    Parameters:
      `name` - parameter name
      `value` - parameter value
    Throws:
      `IOException`

  - ### clearParameters

    public void clearParameters() throws IOException
    Description copied from interface: `BufferFile`
    Deletes all parameters
    Specified by:
      `clearParameters` in interface `BufferFile`
    Throws:
      `IOException`

  - ### getParameterNames

    public String[] getParameterNames() throws IOException
    Description copied from interface: `BufferFile`
    Returns a list of all parameter names.
    Specified by:
      `getParameterNames` in interface `BufferFile`
    Throws:
      `IOException`

  - ### getBufferSize

    public int getBufferSize() throws IOException
    Description copied from interface: `BufferFile`
    Return the actual size of a user data buffer. This value should be used when constructing DataBuffer objects.
    Specified by:
      `getBufferSize` in interface `BufferFile`
    Returns:
      DataBuffer data size as a number of bytes
    Throws:
      `IOException` - if an I/O error occurs

  - ### getIndexCount

    public int getIndexCount() throws IOException
    Description copied from interface: `BufferFile`
    Returns the number of allocated buffer indexes. When a new buffer is allocated, and the file size grows, the buffer will remain allocated although it may be added to the list of free-indexes. A file will never shrink in size due to this permanent allocation.
    Specified by:
      `getIndexCount` in interface `BufferFile`
    Throws:
      `IOException`

  - ### getFreeIndexes

    public int[] getFreeIndexes() throws IOException
    Description copied from interface: `BufferFile`
    Returns the list of free indexes sorted by value. The management of the free-index-list is implementation specific.
    Specified by:
      `getFreeIndexes` in interface `BufferFile`
    Throws:
      `IOException`

  - ### setFreeIndexes

    public void setFreeIndexes(int[] indexes) throws IOException
    Description copied from interface: `BufferFile`
    Sets the list of free buffer indexes. The management of the free-index-list is implementation specific.
    Specified by:
      `setFreeIndexes` in interface `BufferFile`
    Parameters:
      `indexes` -
    Throws:
      `IOException`

  - ### isReadOnly

    public boolean isReadOnly() throws IOException
    Description copied from interface: `BufferFile`
    Returns true if this file may not be modified via the buffer put method. A read-only file may be considered "updateable" if the canSave method returns true. The term "updateable" means that a Save file can be obtained via the getSaveFile method.
    Specified by:
      `isReadOnly` in interface `BufferFile`
    Throws:
      `IOException` - if an I/O error occurs

  - ### setReadOnly

    public boolean setReadOnly() throws IOException
    Description copied from interface: `BufferFile`
    If file is open read-write, the modified contents are flushed and the file re-opened as read-only. This is also used to commit a new version if the file had been modified for update.
    Specified by:
      `setReadOnly` in interface `BufferFile`
    Returns:
      true if successfully transitioned from read-write to read-only
    Throws:
      `IOException` - if an I/O error occurs

  - ### close

    public void close() throws IOException
    Description copied from interface: `BufferFile`
    Close the buffer file. If the file was open for write access, all buffers are flushed and the file header updated. Once closed, this object is immediately disposed and may no longer be used.
    Specified by:
      `close` in interface `BufferFile`
    Throws:
      `IOException` - if an I/O error occurs

  - ### delete

    public boolean delete() throws IOException
    Description copied from interface: `BufferFile`
    Delete this buffer file if writable. Once deleted, this object is immediately disposed and may no longer be used.
    Specified by:
      `delete` in interface `BufferFile`
    Returns:
      true if deleted, false if the file is read-only
    Throws:
      `IOException` - if an I/O error occurs.

  - ### dispose

    public void dispose()
    Description copied from interface: `BufferFile`
    Dispose of this buffer file object. If file is not readOnly and has not been closed, an attempt will be made to delete the associated file(s). Once disposed, it may no longer be used.
    Specified by:
      `dispose` in interface `BufferFile`

  - ### get

    public DataBuffer get(DataBuffer buf, int index) throws IOException
    Description copied from interface: `BufferFile`
    Get the specified buffer. DataBuffer data and flags are read from the file at index and stored within the supplied DataBuffer object. If the read buffer is empty, the DataBuffer's data field will remain unchanged (which could be null).
    Specified by:
      `get` in interface `BufferFile`
    Parameters:
      `buf` - a buffer whose data array will be filled-in or replaced.
      `index` - index of buffer to be read. First user buffer is at index 0.
    Throws:
      `IOException` - if an I/O error occurs

  - ### put

    public void put(DataBuffer buf, int index) throws IOException
    Description copied from interface: `BufferFile`
    Store a data buffer at the specified block index.
    Specified by:
      `put` in interface `BufferFile`
    Parameters:
      `buf` - data buffer
      `index` - block index
    Throws:
      `IOException` - thrown if an IO error occurs

  - ### isRemote

    public boolean isRemote()
    Determine if this file is remotely accessed
    Returns:
      true if file is remote