jdbm.recman
Class BlockIo

java.lang.Object
  extended byjdbm.recman.BlockIo
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public final class BlockIo
extends java.lang.Object
implements java.io.Externalizable

This class wraps a page-sized byte array and provides methods to read and write data to and from it. The readers and writers are just the ones that the rest of the toolkit needs, nothing else. Values written are compatible with java.io routines.

See Also:
DataInput, DataOutput, Serialized Form

Field Summary
static long serialVersionUID
           
 
Constructor Summary
  BlockIo()
          Default constructor for serialization
(package private) BlockIo(long blockId, byte[] data)
          Constructs a new BlockIo instance working on the indicated buffer.
 
Method Summary
(package private)  void decrementTransactionCount()
          Decrements transaction count for this block, to signal that this block has been written from the log to the data file.
(package private)  long getBlockId()
          Returns the block number.
(package private)  byte[] getData()
          Returns the underlying array
 BlockView getView()
          Returns the current view of the block.
(package private)  void incrementTransactionCount()
          Increments transaction count for this block, to signal that this block is in the log but not yet in the data file.
(package private)  boolean isDirty()
          Returns true if the dirty flag is set.
(package private)  boolean isInTransaction()
          Returns true if the block is still dirty with respect to the transaction log.
 byte readByte(int pos)
          Reads a byte from the indicated position
 void readExternal(java.io.ObjectInput in)
           
 int readInt(int pos)
          Reads an int from the indicated position
 long readLong(int pos)
          Reads a long from the indicated position
 short readShort(int pos)
          Reads a short from the indicated position
(package private)  void setBlockId(long id)
          Sets the block number.
(package private)  void setClean()
          Clears the dirty flag
(package private)  void setDirty()
          Sets the dirty flag
 void setView(BlockView view)
          Sets the current view of the block.
 java.lang.String toString()
           
 void writeByte(int pos, byte value)
          Writes a byte to the indicated position
 void writeExternal(java.io.ObjectOutput out)
           
 void writeInt(int pos, int value)
          Writes an int to the indicated position
 void writeLong(int pos, long value)
          Writes a long to the indicated position
 void writeShort(int pos, short value)
          Writes a short to the indicated position
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

BlockIo

public BlockIo()
Default constructor for serialization


BlockIo

BlockIo(long blockId,
        byte[] data)
Constructs a new BlockIo instance working on the indicated buffer.

Method Detail

getData

byte[] getData()
Returns the underlying array


setBlockId

void setBlockId(long id)
Sets the block number. Should only be called by RecordFile.


getBlockId

long getBlockId()
Returns the block number.


getView

public BlockView getView()
Returns the current view of the block.


setView

public void setView(BlockView view)
Sets the current view of the block.


setDirty

void setDirty()
Sets the dirty flag


setClean

void setClean()
Clears the dirty flag


isDirty

boolean isDirty()
Returns true if the dirty flag is set.


isInTransaction

boolean isInTransaction()
Returns true if the block is still dirty with respect to the transaction log.


incrementTransactionCount

void incrementTransactionCount()
Increments transaction count for this block, to signal that this block is in the log but not yet in the data file. The method also takes a snapshot so that the data may be modified in new transactions.


decrementTransactionCount

void decrementTransactionCount()
Decrements transaction count for this block, to signal that this block has been written from the log to the data file.


readByte

public byte readByte(int pos)
Reads a byte from the indicated position


writeByte

public void writeByte(int pos,
                      byte value)
Writes a byte to the indicated position


readShort

public short readShort(int pos)
Reads a short from the indicated position


writeShort

public void writeShort(int pos,
                       short value)
Writes a short to the indicated position


readInt

public int readInt(int pos)
Reads an int from the indicated position


writeInt

public void writeInt(int pos,
                     int value)
Writes an int to the indicated position


readLong

public long readLong(int pos)
Reads a long from the indicated position


writeLong

public void writeLong(int pos,
                      long value)
Writes a long to the indicated position


toString

public java.lang.String toString()

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException


Cees de Groot (C) 2000-2001. All rights reserved http://jdbm.sourceforge.net