waba.io
Class ResizeStream

java.lang.Object
  |
  +--waba.io.Stream
        |
        +--waba.io.ResizeStream

public class ResizeStream
extends Stream

this class is used to create an resizable record. you can use it with DataStream. example:

Catalog cat = new Catalog(type+"."+creator+"."+type,Catalog.READ_WRITE);
ResizeStream rs = new ResizeStream(cat,512);
DataStream ds = new DataStream(rs);
rs.startRecord();
ds.writeStringArray(aStringArray);
rs.endRecord();
ds.close();

ps: if you dont call startRecord, writeBytes will simply call catalog.writeBytes and will not resize the record.
created by guich (guich@email.com)


Constructor Summary
ResizeStream(Catalog cat, int initialSize)
          constructs the resize stream.
 
Method Summary
 boolean close()
          closes the catalog
 void endRecord()
          must be called after the record is finished so it can be resized
 int readBytes(byte[] buf, int start, int count)
          simply read the bytes from the associated catalog
 void startRecord()
          add a new record to the catalog
 void startRecord(int pos)
          inserts the record at the specified index in the catalog.
 int writeBytes(byte[] buf, int start, int count)
          writes to the buffer, growing the record if necessary.
 
Methods inherited from class java.lang.Object
hashCode, toString
 

Constructor Detail

ResizeStream

public ResizeStream(Catalog cat,
                    int initialSize)
constructs the resize stream.
Parameters:
cat - the catalog associated
initialSize - the initial size of the record
Method Detail

startRecord

public void startRecord(int pos)
inserts the record at the specified index in the catalog.
Since:
SuperWaba 1.21.

startRecord

public void startRecord()
add a new record to the catalog

endRecord

public void endRecord()
must be called after the record is finished so it can be resized

readBytes

public int readBytes(byte[] buf,
                     int start,
                     int count)
simply read the bytes from the associated catalog
Overrides:
readBytes in class Stream
Tags copied from class: Stream
Parameters:
buf - the byte array to read data into
start - the start position in the array
count - the number of bytes to read

writeBytes

public int writeBytes(byte[] buf,
                      int start,
                      int count)
writes to the buffer, growing the record if necessary.
Overrides:
writeBytes in class Stream
Tags copied from class: Stream
Parameters:
buf - the byte array to write data from
start - the start position in the byte array
count - the number of bytes to write

close

public boolean close()
closes the catalog
Overrides:
close in class Stream