Package db.buffers
Class BufferFileAdapter
- java.lang.Object
-
- db.buffers.BufferFileAdapter
-
- All Implemented Interfaces:
BufferFile
- Direct Known Subclasses:
ManagedBufferFileAdapter
public class BufferFileAdapter extends java.lang.Object implements BufferFile
BufferFileAdapterprovides a BufferFile implementation which wraps a BufferFileHandle.
-
-
Constructor Summary
Constructors Constructor Description BufferFileAdapter(BufferFileHandle remoteBufferFile)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearParameters()Deletes all parametersvoidclose()Close the buffer file.booleandelete()Delete this buffer file if writable.voiddispose()Dispose of this buffer file object.DataBufferget(DataBuffer buf, int index)Get the specified buffer.intgetBufferSize()Return the actual size of a user data buffer.int[]getFreeIndexes()Returns the list of free indexes sorted by value.intgetIndexCount()Returns the number of allocated buffer indexes.intgetParameter(java.lang.String name)Get a the stored value for a named parameter.java.lang.String[]getParameterNames()Returns a list of all parameter names.booleanisReadOnly()Returns true if this file may not be modified via the buffer put method.booleanisRemote()Determine if this file is remotely accessedvoidput(DataBuffer buf, int index)Store a data buffer at the specified block index.voidsetFreeIndexes(int[] indexes)Sets the list of free buffer indexes.voidsetParameter(java.lang.String name, int value)Set the integer value for a named parameter.booleansetReadOnly()If file is open read-write, the modified contents are flushed and the file re-opened as read-only.
-
-
-
Constructor Detail
-
BufferFileAdapter
public BufferFileAdapter(BufferFileHandle remoteBufferFile)
Constructor.- Parameters:
remoteBufferFile- remote buffer file handle
-
-
Method Detail
-
getParameter
public int getParameter(java.lang.String name) throws java.util.NoSuchElementException, java.io.IOExceptionDescription copied from interface:BufferFileGet a the stored value for a named parameter.- Specified by:
getParameterin interfaceBufferFile- Parameters:
name- parameter name- Returns:
- integer value
- Throws:
java.util.NoSuchElementException- thrown if parameter not foundjava.io.IOException
-
setParameter
public void setParameter(java.lang.String name, int value) throws java.io.IOExceptionDescription copied from interface:BufferFileSet the integer value for a named parameter.- Specified by:
setParameterin interfaceBufferFile- Parameters:
name- parameter namevalue- parameter value- Throws:
java.io.IOException
-
clearParameters
public void clearParameters() throws java.io.IOExceptionDescription copied from interface:BufferFileDeletes all parameters- Specified by:
clearParametersin interfaceBufferFile- Throws:
java.io.IOException
-
getParameterNames
public java.lang.String[] getParameterNames() throws java.io.IOExceptionDescription copied from interface:BufferFileReturns a list of all parameter names.- Specified by:
getParameterNamesin interfaceBufferFile- Throws:
java.io.IOException
-
getBufferSize
public int getBufferSize() throws java.io.IOExceptionDescription copied from interface:BufferFileReturn the actual size of a user data buffer. This value should be used when constructing DataBuffer objects.- Specified by:
getBufferSizein interfaceBufferFile- Returns:
- DataBuffer data size as a number of bytes
- Throws:
java.io.IOException- if an I/O error occurs
-
getIndexCount
public int getIndexCount() throws java.io.IOExceptionDescription copied from interface:BufferFileReturns 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:
getIndexCountin interfaceBufferFile- Throws:
java.io.IOException
-
getFreeIndexes
public int[] getFreeIndexes() throws java.io.IOExceptionDescription copied from interface:BufferFileReturns the list of free indexes sorted by value. The management of the free-index-list is implementation specific.- Specified by:
getFreeIndexesin interfaceBufferFile- Throws:
java.io.IOException
-
setFreeIndexes
public void setFreeIndexes(int[] indexes) throws java.io.IOExceptionDescription copied from interface:BufferFileSets the list of free buffer indexes. The management of the free-index-list is implementation specific.- Specified by:
setFreeIndexesin interfaceBufferFile- Throws:
java.io.IOException
-
isReadOnly
public boolean isReadOnly() throws java.io.IOExceptionDescription copied from interface:BufferFileReturns 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:
isReadOnlyin interfaceBufferFile- Throws:
java.io.IOException- if an I/O error occurs
-
setReadOnly
public boolean setReadOnly() throws java.io.IOExceptionDescription copied from interface:BufferFileIf 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:
setReadOnlyin interfaceBufferFile- Throws:
java.io.IOException- if an I/O error occurs
-
close
public void close() throws java.io.IOExceptionDescription copied from interface:BufferFileClose 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:
closein interfaceBufferFile- Throws:
java.io.IOException- if an I/O error occurs
-
delete
public boolean delete() throws java.io.IOExceptionDescription copied from interface:BufferFileDelete this buffer file if writable. Once deleted, this object is immediately disposed and may no longer be used.- Specified by:
deletein interfaceBufferFile- Throws:
java.io.IOException- if an I/O error occurs.
-
dispose
public void dispose()
Description copied from interface:BufferFileDispose 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:
disposein interfaceBufferFile
-
get
public DataBuffer get(DataBuffer buf, int index) throws java.io.IOException
Description copied from interface:BufferFileGet 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:
getin interfaceBufferFile- 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:
java.io.EOFException- if the requested buffer index is greater than the number of available buffers of the end-of-file was encountered while reading the buffer.java.io.IOException- if an I/O error occurs
-
put
public void put(DataBuffer buf, int index) throws java.io.IOException
Description copied from interface:BufferFileStore a data buffer at the specified block index.- Specified by:
putin interfaceBufferFile- Parameters:
buf- data bufferindex- block index- Throws:
java.io.IOException- thrown if an IO error occurs
-
isRemote
public boolean isRemote()
Determine if this file is remotely accessed- Returns:
- true if file is remote
-
-