org.neodatis.odb.impl.core.layers.layer3.buffer
Class MultiBufferedIO

java.lang.Object
  extended by org.neodatis.odb.impl.core.layers.layer3.buffer.MultiBufferedIO
All Implemented Interfaces:
IBufferedIO
Direct Known Subclasses:
MultiBufferedFileIO

public abstract class MultiBufferedIO
extends java.lang.Object
implements IBufferedIO

Abstract class allowing buffering for IO This class is used to give a transparent access to buffered io : File, socket The DefaultFileIO and DefaultSocketIO inherits from AbstractIO

Author:
olivier s

Field Summary
protected  long currentPositionWhenUsingBuffer
           
static java.lang.String LOG_ID
           
static int nbBufferNotOk
           
static int nbBufferOk
           
static int nbFlushForOverlap
           
static int nbSamePositionForRead
           
static int nbSamePositionForWrite
           
static long nbWrites
           
static long numberOfFlush
          Internal counter of flush
static long totalFlushSize
           
static long totalWriteSize
           
 
Constructor Summary
MultiBufferedIO(int nbBuffers, java.lang.String name, int bufferSize, boolean canWrite)
           
 
Method Summary
 boolean automaticDeleteIsEnabled()
           
 void clear()
           
 void close()
           
abstract  void closeIO()
           
 void enableAutomaticDelete(boolean yesOrNo)
           
 void flushAllBuffers()
           
 void flushBuffer(int bufferIndex)
           
 long getCurrentPosition()
           
 long getIoDeviceLength()
           
abstract  long getLength()
           
 long getNumberOfFlush()
           
abstract  void goToPosition(long position)
           
abstract  byte internalRead()
           
abstract  long internalRead(byte[] array, int size)
           
abstract  void internalWrite(byte b)
           
abstract  void internalWrite(byte[] bs, int size)
           
 boolean isForTransaction()
           
 boolean isUsingbuffer()
           
 int manageBufferForNewPosition(long newPosition, int readOrWrite, int size)
          Checks if the new position is in the buffer, if not, flushes the buffer and rebuilds it to the correct position
 byte readByte()
           
 byte[] readBytes(byte[] bytes, int startIndex, int endIndex)
           
 byte[] readBytes(int size)
           
 byte[] readBytesOld(int size)
           
 void setCurrentReadPosition(long currentPosition)
           
 void setCurrentWritePosition(long currentPosition)
           
 void setIoDeviceLength(long ioDeviceLength)
           
 void setUseBuffer(boolean useBuffer)
           
 java.lang.String toString()
           
 void writeByte(byte b)
           
 void writeBytes(byte[] bytes)
           
 void writeBytes(byte[] bytes, int startIndex, int endIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.neodatis.odb.core.layers.layer3.IBufferedIO
delete, flushIO
 

Field Detail

nbWrites

public static long nbWrites

totalWriteSize

public static long totalWriteSize

numberOfFlush

public static long numberOfFlush
Internal counter of flush


totalFlushSize

public static long totalFlushSize

nbFlushForOverlap

public static int nbFlushForOverlap

nbBufferOk

public static int nbBufferOk

nbBufferNotOk

public static int nbBufferNotOk

nbSamePositionForWrite

public static int nbSamePositionForWrite

nbSamePositionForRead

public static int nbSamePositionForRead

LOG_ID

public static final java.lang.String LOG_ID
See Also:
Constant Field Values

currentPositionWhenUsingBuffer

protected long currentPositionWhenUsingBuffer
Constructor Detail

MultiBufferedIO

public MultiBufferedIO(int nbBuffers,
                       java.lang.String name,
                       int bufferSize,
                       boolean canWrite)
Method Detail

goToPosition

public abstract void goToPosition(long position)
Specified by:
goToPosition in interface IBufferedIO

getLength

public abstract long getLength()
Specified by:
getLength in interface IBufferedIO

internalWrite

public abstract void internalWrite(byte b)

internalWrite

public abstract void internalWrite(byte[] bs,
                                   int size)

internalRead

public abstract byte internalRead()

internalRead

public abstract long internalRead(byte[] array,
                                  int size)

closeIO

public abstract void closeIO()

manageBufferForNewPosition

public int manageBufferForNewPosition(long newPosition,
                                      int readOrWrite,
                                      int size)
Description copied from interface: IBufferedIO
Checks if the new position is in the buffer, if not, flushes the buffer and rebuilds it to the correct position

Specified by:
manageBufferForNewPosition in interface IBufferedIO
size - Size if the data that must be stored
Returns:
The index of the buffer where that contains the position

isUsingbuffer

public boolean isUsingbuffer()
Specified by:
isUsingbuffer in interface IBufferedIO

setUseBuffer

public void setUseBuffer(boolean useBuffer)
Specified by:
setUseBuffer in interface IBufferedIO

getCurrentPosition

public long getCurrentPosition()
Specified by:
getCurrentPosition in interface IBufferedIO

setCurrentWritePosition

public void setCurrentWritePosition(long currentPosition)
Specified by:
setCurrentWritePosition in interface IBufferedIO

setCurrentReadPosition

public void setCurrentReadPosition(long currentPosition)
Specified by:
setCurrentReadPosition in interface IBufferedIO

writeByte

public void writeByte(byte b)
Specified by:
writeByte in interface IBufferedIO

readBytesOld

public byte[] readBytesOld(int size)
Specified by:
readBytesOld in interface IBufferedIO

readBytes

public byte[] readBytes(int size)
Specified by:
readBytes in interface IBufferedIO

readBytes

public byte[] readBytes(byte[] bytes,
                        int startIndex,
                        int endIndex)

readByte

public byte readByte()
Specified by:
readByte in interface IBufferedIO

writeBytes

public void writeBytes(byte[] bytes)
Specified by:
writeBytes in interface IBufferedIO

writeBytes

public void writeBytes(byte[] bytes,
                       int startIndex,
                       int endIndex)

flushAllBuffers

public void flushAllBuffers()
Specified by:
flushAllBuffers in interface IBufferedIO

flushBuffer

public void flushBuffer(int bufferIndex)
Specified by:
flushBuffer in interface IBufferedIO

getNumberOfFlush

public long getNumberOfFlush()
Returns:
Returns the numberOfFlush.

getIoDeviceLength

public long getIoDeviceLength()
Specified by:
getIoDeviceLength in interface IBufferedIO

setIoDeviceLength

public void setIoDeviceLength(long ioDeviceLength)
Specified by:
setIoDeviceLength in interface IBufferedIO

close

public void close()
Specified by:
close in interface IBufferedIO

clear

public void clear()
Specified by:
clear in interface IBufferedIO

isForTransaction

public boolean isForTransaction()
Specified by:
isForTransaction in interface IBufferedIO

enableAutomaticDelete

public void enableAutomaticDelete(boolean yesOrNo)
Specified by:
enableAutomaticDelete in interface IBufferedIO

automaticDeleteIsEnabled

public boolean automaticDeleteIsEnabled()
Specified by:
automaticDeleteIsEnabled in interface IBufferedIO

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object