|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcz.cuni.jagrlib.DefaultProperty
cz.cuni.jagrlib.Piece
cz.cuni.jagrlib.piece.BufferedBitStream
public class BufferedBitStream
Bit-stream object with random access and buffer-capability build on
top of RandomAccessFile class.
| Field Summary | |
|---|---|
protected byte[] |
buffer
Memory buffer. |
static java.lang.String |
BUFFER_SIZE
Buffer size in bytes. |
protected long |
bufferOrigin
Buffer position in the file (in bits). |
protected long |
bufferPtr
Actual position within the buffer. |
protected long |
bufferSize
Buffer size in bits. |
protected long |
bufferUsed
Used buffer bits. |
protected static java.lang.String |
CATEGORY
Object category. |
protected java.io.RandomAccessFile |
file
Current random access file. |
protected long |
changedMax
Position of the last changed bit in the buffer. |
protected long |
changedMin
Position of the first changed bit in the buffer. |
protected long |
position
Actual stream-position in bits. |
static RegPiece |
reg
Static registration instance for this class. |
protected java.lang.String |
streamName
Data stream name (file-name). |
protected static java.lang.String |
TEMPLATE_NAME
Object template identifier. |
protected boolean |
writeEnabled
File modification was enabled? |
| Fields inherited from class cz.cuni.jagrlib.Piece |
|---|
channels, info, pl, plugs, TEMPLATE_TYPE, userBreak |
| Fields inherited from interface cz.cuni.jagrlib.iface.BitStream |
|---|
DEFAULT_STREAM_NAME, STREAM_NAME |
| Fields inherited from interface cz.cuni.jagrlib.iface.Property |
|---|
LOGGING, STATISTICS, TEXT_DESCRIPTION |
| Constructor Summary | |
|---|---|
BufferedBitStream()
|
|
| Method Summary | |
|---|---|
long |
available()
How many bits are available to read (or skip). |
protected void |
bufferSeek(long bufferPos)
Does internal seek in the memory buffer. |
boolean |
canRead()
Stream is able to read data. |
void |
close()
Stream close. |
void |
flush()
Stream flush. |
protected void |
flushBuffer()
Flushes all unwritten data to disk file. |
java.lang.Object |
get(java.lang.String key)
Gets the given property. |
java.io.InputStream |
getInputStream()
Retrieves the associated input stream (non-mandatory). |
java.io.OutputStream |
getOutputStream()
Retrieves the associated output stream (non-mandatory). |
protected void |
changeBufferSize(long newSize)
|
void |
open(boolean output,
java.lang.String name,
java.lang.String detail)
Stream initialization. |
long |
position()
Actual stream position in bits. |
long |
read(int length)
Reads a bunch of bits from the stream. |
protected void |
readBuffer(long pos)
Reads buffer into memory. |
void |
readBytes(byte[] data,
int start,
int length)
Reads a bunch of bytes from the stream. |
void |
reOpen(boolean output,
java.lang.String detail)
Stream re-initialization. |
long |
seek(long pos)
Sets actual position of the stream in bits. |
void |
set(java.lang.String key,
java.lang.Object value)
Sets the given property. |
static int |
setTemplate(Template t,
int ord)
General-purpose registration routine. |
long |
skip(long length)
Skips the given number of bits. |
void |
write(long bits,
int length)
Writes a bunch of bits into the stream. |
void |
writeBytes(byte[] data,
int start,
int length)
Writes a bunch of bytes into the stream. |
| Methods inherited from class cz.cuni.jagrlib.Piece |
|---|
className, connect, findPlug, findPlug, getInfo, getInterface, getInterface, getPlug, getReg, init, isCompatible, isCompatible, isConnected, logError, logWarning, myInterface, newInputPlug, newOptOutputPlug, newOutputPlug, newPlug, noTemplates, propBegin, propBounds, propDefault, propEnd, propEnum, propManipulator, propManipulator, setProgressListener, setRegStrings, setTemplateDynamic, stop |
| Methods inherited from class cz.cuni.jagrlib.DefaultProperty |
|---|
booleanProperty, booleanProperty, colorDoubleProperty, colorProperty, commit, doubleProperty, doubleProperty, doubleProperty, enumProperty, floatProperty, floatProperty, floatProperty, intProperty, intProperty, intProperty, longProperty, longProperty, longProperty, set, stringProperty |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface cz.cuni.jagrlib.iface.Property |
|---|
commit |
| Field Detail |
|---|
protected java.lang.String streamName
protected java.io.RandomAccessFile file
protected boolean writeEnabled
protected long position
protected byte[] buffer
protected long bufferOrigin
protected long bufferSize
protected long bufferUsed
protected long changedMin
buffer. Relative to bufferOrigin.
protected long changedMax
buffer. Relative to bufferOrigin.
protected long bufferPtr
buffer. Relative to bufferOrigin.
public static final java.lang.String BUFFER_SIZE
protected static final java.lang.String TEMPLATE_NAME
protected static final java.lang.String CATEGORY
public static final RegPiece reg
| Constructor Detail |
|---|
public BufferedBitStream()
| Method Detail |
|---|
protected void flushBuffer()
throws java.io.IOException
java.io.IOExceptionprotected void bufferSeek(long bufferPos)
protected void readBuffer(long pos)
throws java.io.IOException
java.io.IOException
protected void changeBufferSize(long newSize)
throws java.io.IOException
java.io.IOExceptionpublic boolean canRead()
true, stream can be opened automatically in the init-phase.
canRead in interface BitStream
public void open(boolean output,
java.lang.String name,
java.lang.String detail)
throws java.io.IOException
open in interface BitStreamoutput - Open for output?name - Stream name (either stream identification e.g. file-name). null
for implicit bit-stream (reOpen(boolean, java.lang.String)).detail - Further implementation-specific information.
java.io.IOExceptionreOpen(boolean, java.lang.String)
public void reOpen(boolean output,
java.lang.String detail)
throws java.io.IOException
reOpen in interface BitStreamoutput - Open for output?detail - Further implementation-specific information.
java.io.IOExceptionopen(boolean, java.lang.String, java.lang.String)public java.io.OutputStream getOutputStream()
getOutputStream in interface BitStreamOutputStream instance or null if
not implemented.getInputStream()public java.io.InputStream getInputStream()
getInputStream in interface BitStreamInputStream instance or null if
not implemented.getOutputStream()
public void flush()
throws java.io.IOException
flush in interface BitStreamjava.io.IOExceptionopen(boolean, java.lang.String, java.lang.String),
close()
public void close()
throws java.io.IOException
close in interface BitStreamjava.io.IOExceptionopen(boolean, java.lang.String, java.lang.String),
reOpen(boolean, java.lang.String)
public long position()
throws java.io.IOException
position in interface BitStreamjava.io.IOExceptionavailable(),
seek(long)
public long available()
throws java.io.IOException
available in interface BitStreamjava.io.IOExceptionposition,
seek(long)
public long seek(long pos)
throws java.io.IOException
seek in interface BitStreampos - Required stream position in bits.
-1L if not implemented).
java.io.IOExceptionposition
public void write(long bits,
int length)
throws java.io.IOException
write in interface BitStreambits - Bits to be written (LSB first).length - Number of bits to write (negative lengths are ignored).
java.io.IOExceptionwriteBytes(byte[], int, int),
read(int)
public void writeBytes(byte[] data,
int start,
int length)
throws java.io.IOException
writeBytes in interface BitStreamdata - Bytes to be written (each byte is written in "LSB first" order).start - First index to write. Must be less than data.length.length - Number of bytes to write (start + length > data.length is ignored).
java.io.IOExceptionwrite(long, int),
readBytes(byte[], int, int)
public long read(int length)
throws java.io.IOException
read in interface BitStreamlength - Number of bits to read (negative lengths are ignored).
java.io.IOExceptionreadBytes(byte[], int, int),
write(long, int)
public void readBytes(byte[] data,
int start,
int length)
throws java.io.IOException
readBytes in interface BitStreamdata - Array holding the read bytes (each byte is read in "LSB first" order).start - First index to read. Must be less than data.length.length - Number of bytes to read (start + length > data.length is ignored).
java.io.IOExceptionread(int),
writeBytes(byte[], int, int)
public long skip(long length)
throws java.io.IOException
skip in interface BitStreamlength - Number of bits to skip (negative lengths are ignored).
java.io.IOExceptionseek(long)
public void set(java.lang.String key,
java.lang.Object value)
set in interface Propertyset in class DefaultPropertykey - Key string.value - The new value.Property.commit()public java.lang.Object get(java.lang.String key)
get in interface Propertyget in class DefaultPropertykey - Key string.
null.
public static int setTemplate(Template t,
int ord)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||