/** * Write the header and data portion to IoInterface implementor. Primarily for freechain create as * we used writeUsed otherwise * * @param fobj the IoInterface * @exception IOException error writing field */ public synchronized void write(IoInterface fobj) throws IOException { // synchronized(fobj) { fobj.Fwrite_long(getPrevblk()); fobj.Fwrite_long(getNextblk()); fobj.Fwrite_short(getBytesused()); fobj.Fwrite_short(getBytesinuse()); fobj.Fwrite_long(getPageLSN()); fobj.Fwrite(data); // } }
/** * read the header and data portion from IoInterface implementor * * @param fobj the IoInterface * @exception IOException error reading field */ public synchronized void read(IoInterface fobj) throws IOException { // synchronized(fobj) { setPrevblk(fobj.Fread_long()); setNextblk(fobj.Fread_long()); setBytesused(fobj.Fread_short()); setBytesinuse(fobj.Fread_short()); setPageLSN(fobj.Fread_long()); if (fobj.Fread(data, datasize) != datasize) { throw new IOException("Datablock read size invalid " + this.toString()); } // } }
/** * read the header and used data portion from IoInterface implementor * * @param fobj the IoInterface * @exception IOException error reading field */ public synchronized void readUsed(IoInterface fobj) throws IOException { // synchronized(fobj) { setPrevblk(fobj.Fread_long()); setNextblk(fobj.Fread_long()); setBytesused(fobj.Fread_short()); setBytesinuse(fobj.Fread_short()); setPageLSN(fobj.Fread_long()); if (getBytesused() > datasize) { throw new IOException("block inconsistency " + this.toString()); } if (getBytesused() == datasize) { if (fobj.Fread(data) != datasize) { throw new IOException("Datablock read size invalid " + this.toString()); } } else { if (fobj.Fread(data, getBytesused()) != getBytesused()) { throw new IOException( "Datablock read error bytesused=" + String.valueOf(getBytesused()) + " bytesinuse=" + String.valueOf(getBytesinuse())); } } // } }