org.tmatesoft.sqljet.core.internal.memory
Class SqlJetByteArrayBuffer

java.lang.Object
  extended by org.tmatesoft.sqljet.core.internal.memory.SqlJetByteArrayBuffer
All Implemented Interfaces:
ISqlJetMemoryBuffer

public class SqlJetByteArrayBuffer
extends java.lang.Object
implements ISqlJetMemoryBuffer


Constructor Summary
SqlJetByteArrayBuffer()
           
 
Method Summary
 void allocate(int size)
          Allocate chunk of memory.
 byte[] asArray()
           
 int compareTo(int pointer, ISqlJetMemoryBuffer buffer, int bufferPointer)
           
 void copyFrom(int dstPos, ISqlJetMemoryBuffer src, int srcPos, int count)
           
 void fill(int from, int count, byte value)
           
 void free()
          Fries chunk of memory.
 byte getByte(int pointer)
          Read byte at pointer.
 void getBytes(int pointer, byte[] bytes, int to, int count)
           
 int getByteUnsigned(int pointer)
          Read unsigned byte at pointer.
 int getInt(int pointer)
          Read int at pointer.
 long getIntUnsigned(int pointer)
          Read unsigned int at pointer.
 long getLong(int pointer)
          Read long at pointer.
 ISqlJetMemoryPointer getPointer(int pointer)
          Returns pointer in memory chunk at passed offset.
 short getShort(int pointer)
          Read short at pointer.
 int getShortUnsigned(int pointer)
          Read unsigned short at pointer.
 int getSize()
          Size of allocated memory chunk.
 boolean isAllocated()
          Returns true if memory is allocated.
 void putByte(int pointer, byte value)
          Write byte at pointer.
 void putBytes(int pointer, byte[] bytes, int from, int count)
           
 void putByteUnsigned(int pointer, int value)
          Write unsigned byte at pointer.
 void putInt(int pointer, int value)
          Write int at pointer.
 void putIntUnsigned(int pointer, long value)
          Write unsigned int at pointer.
 void putLong(int pointer, long value)
          Write long at pointer.
 void putShort(int pointer, short value)
          Write short at pointer.
 void putShortUnsigned(int pointer, int value)
          Write unsigned short at pointer.
 int readFromFile(int pointer, java.io.RandomAccessFile file, long position, int count)
          Read from file into memory chunk at pointer.
 int writeToFile(int pointer, java.io.RandomAccessFile file, long position, int count)
          Write from memory chunk at pointer to file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlJetByteArrayBuffer

public SqlJetByteArrayBuffer()
Method Detail

allocate

public void allocate(int size)
Description copied from interface: ISqlJetMemoryBuffer
Allocate chunk of memory. If memory already has allocated then fries current chunk and allocates new.

Specified by:
allocate in interface ISqlJetMemoryBuffer
Parameters:
size - size of chunk in bytes

free

public void free()
Description copied from interface: ISqlJetMemoryBuffer
Fries chunk of memory.

Specified by:
free in interface ISqlJetMemoryBuffer

isAllocated

public boolean isAllocated()
Description copied from interface: ISqlJetMemoryBuffer
Returns true if memory is allocated.

Specified by:
isAllocated in interface ISqlJetMemoryBuffer
Returns:

getSize

public int getSize()
Description copied from interface: ISqlJetMemoryBuffer
Size of allocated memory chunk.

Specified by:
getSize in interface ISqlJetMemoryBuffer
Returns:

getPointer

public ISqlJetMemoryPointer getPointer(int pointer)
Description copied from interface: ISqlJetMemoryBuffer
Returns pointer in memory chunk at passed offset.

Specified by:
getPointer in interface ISqlJetMemoryBuffer
Returns:

getByte

public byte getByte(int pointer)
Description copied from interface: ISqlJetMemoryBuffer
Read byte at pointer.

Specified by:
getByte in interface ISqlJetMemoryBuffer
Returns:

getInt

public int getInt(int pointer)
Description copied from interface: ISqlJetMemoryBuffer
Read int at pointer.

Specified by:
getInt in interface ISqlJetMemoryBuffer
Returns:

getLong

public long getLong(int pointer)
Description copied from interface: ISqlJetMemoryBuffer
Read long at pointer.

Specified by:
getLong in interface ISqlJetMemoryBuffer
Returns:

getShort

public short getShort(int pointer)
Description copied from interface: ISqlJetMemoryBuffer
Read short at pointer.

Specified by:
getShort in interface ISqlJetMemoryBuffer
Returns:

getByteUnsigned

public int getByteUnsigned(int pointer)
Description copied from interface: ISqlJetMemoryBuffer
Read unsigned byte at pointer.

Specified by:
getByteUnsigned in interface ISqlJetMemoryBuffer
Returns:

getIntUnsigned

public long getIntUnsigned(int pointer)
Description copied from interface: ISqlJetMemoryBuffer
Read unsigned int at pointer.

Specified by:
getIntUnsigned in interface ISqlJetMemoryBuffer
Returns:

getShortUnsigned

public int getShortUnsigned(int pointer)
Description copied from interface: ISqlJetMemoryBuffer
Read unsigned short at pointer.

Specified by:
getShortUnsigned in interface ISqlJetMemoryBuffer
Returns:

putByte

public void putByte(int pointer,
                    byte value)
Description copied from interface: ISqlJetMemoryBuffer
Write byte at pointer.

Specified by:
putByte in interface ISqlJetMemoryBuffer

putInt

public void putInt(int pointer,
                   int value)
Description copied from interface: ISqlJetMemoryBuffer
Write int at pointer.

Specified by:
putInt in interface ISqlJetMemoryBuffer

putLong

public void putLong(int pointer,
                    long value)
Description copied from interface: ISqlJetMemoryBuffer
Write long at pointer.

Specified by:
putLong in interface ISqlJetMemoryBuffer

putShort

public void putShort(int pointer,
                     short value)
Description copied from interface: ISqlJetMemoryBuffer
Write short at pointer.

Specified by:
putShort in interface ISqlJetMemoryBuffer

putByteUnsigned

public void putByteUnsigned(int pointer,
                            int value)
Description copied from interface: ISqlJetMemoryBuffer
Write unsigned byte at pointer.

Specified by:
putByteUnsigned in interface ISqlJetMemoryBuffer

putIntUnsigned

public void putIntUnsigned(int pointer,
                           long value)
Description copied from interface: ISqlJetMemoryBuffer
Write unsigned int at pointer.

Specified by:
putIntUnsigned in interface ISqlJetMemoryBuffer

putShortUnsigned

public void putShortUnsigned(int pointer,
                             int value)
Description copied from interface: ISqlJetMemoryBuffer
Write unsigned short at pointer.

Specified by:
putShortUnsigned in interface ISqlJetMemoryBuffer

readFromFile

public int readFromFile(int pointer,
                        java.io.RandomAccessFile file,
                        long position,
                        int count)
                 throws java.io.IOException
Description copied from interface: ISqlJetMemoryBuffer
Read from file into memory chunk at pointer. Method isn't synchronized on file.

Specified by:
readFromFile in interface ISqlJetMemoryBuffer
Returns:
Throws:
java.io.IOException

writeToFile

public int writeToFile(int pointer,
                       java.io.RandomAccessFile file,
                       long position,
                       int count)
                throws java.io.IOException
Description copied from interface: ISqlJetMemoryBuffer
Write from memory chunk at pointer to file. Method isn't synchronized on file.

Specified by:
writeToFile in interface ISqlJetMemoryBuffer
Returns:
Throws:
java.io.IOException

asArray

public byte[] asArray()
Specified by:
asArray in interface ISqlJetMemoryBuffer
Returns:

copyFrom

public void copyFrom(int dstPos,
                     ISqlJetMemoryBuffer src,
                     int srcPos,
                     int count)
Specified by:
copyFrom in interface ISqlJetMemoryBuffer

fill

public void fill(int from,
                 int count,
                 byte value)
Specified by:
fill in interface ISqlJetMemoryBuffer

getBytes

public void getBytes(int pointer,
                     byte[] bytes,
                     int to,
                     int count)
Specified by:
getBytes in interface ISqlJetMemoryBuffer

putBytes

public void putBytes(int pointer,
                     byte[] bytes,
                     int from,
                     int count)
Specified by:
putBytes in interface ISqlJetMemoryBuffer

compareTo

public int compareTo(int pointer,
                     ISqlJetMemoryBuffer buffer,
                     int bufferPointer)
Specified by:
compareTo in interface ISqlJetMemoryBuffer
Returns: