|
||||||||||
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 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 String |
CATEGORY
Object category. |
protected 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 String |
streamName
Data stream name (file-name). |
protected static 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 |
Fields inherited from interface cz.cuni.jagrlib.Template |
---|
ALL_PLUGS, C_1D, C_2D, C_3D, C_ALPHA, C_BINARY, C_BREP, C_CAMERA, C_CIRCLE, C_CLIP, C_COMPRESSION, C_CURVE, C_DATA, C_DRAW, C_EDITOR, C_ELLIPSE, C_FILL, C_FILTER, C_FLOAT, C_FUNCTION, C_IMAGE, C_INTEGER, C_IO, C_LIGHT, C_LINE, C_METRIC, C_POLYGON, C_PROJECTION, C_RADIOSITY, C_RASTER, C_RENDER, C_SAMPLE, C_SCENE, C_SET, C_SOLID, C_TEXT, C_TRANSFORM, C_VECTOR, C_VIEWER, C_WORKER, CAT_EMPTY, EMPTY, IFACE, JAGRLIB, JAGRLIB2, MANIPULATOR_COMBO, MANIPULATOR_CUSTOM, MANIPULATOR_DEFAULT, MANIPULATOR_MULTILINE, PL_ALPHAMASK, PL_BITMASK, PL_CODEC, PL_COLORMAP, PL_COMPARE, PL_DATA, PL_DIRECT, PL_EDITOR, PL_FILTER, PL_FUNCTION, PL_IMAGE, PL_IMPORT, PL_INPUT, PL_INTERSECTION, PL_LIGHTSOURCE, PL_ORDER, PL_OUTPUT, PL_PALETTE, PL_PROPERTY, PL_QUANTIZER, PL_RASTER, PL_RENDER, PL_STREAM, PL_TRANSFORM, PL_TRIGGER, PL_WINDOW, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_LONG, TYPE_OBJECT, TYPE_STRING |
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. |
Object |
get(String key)
Gets the given property. |
InputStream |
getInputStream()
Retrieves the associated input stream (non-mandatory). |
OutputStream |
getOutputStream()
Retrieves the associated output stream (non-mandatory). |
protected void |
changeBufferSize(long newSize)
|
void |
open(boolean output,
String name,
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,
String detail)
Stream re-initialization. |
long |
seek(long pos)
Sets actual position of the stream in bits. |
void |
set(String key,
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 String streamName
protected 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 String BUFFER_SIZE
protected static final String TEMPLATE_NAME
protected static final String CATEGORY
public static final RegPiece reg
Constructor Detail |
---|
public BufferedBitStream()
Method Detail |
---|
protected void flushBuffer() throws IOException
IOException
protected void bufferSeek(long bufferPos)
protected void readBuffer(long pos) throws IOException
IOException
protected void changeBufferSize(long newSize) throws IOException
IOException
public boolean canRead()
true
, stream can be opened automatically in the init-phase.
canRead
in interface BitStream
public void open(boolean output, String name, String detail) throws IOException
open
in interface BitStream
output
- 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.
IOException
reOpen(boolean, java.lang.String)
public void reOpen(boolean output, String detail) throws IOException
reOpen
in interface BitStream
output
- Open for output?detail
- Further implementation-specific information.
IOException
open(boolean, java.lang.String, java.lang.String)
public OutputStream getOutputStream()
getOutputStream
in interface BitStream
OutputStream
instance or null
if
not implemented.getInputStream()
public InputStream getInputStream()
getInputStream
in interface BitStream
InputStream
instance or null
if
not implemented.getOutputStream()
public void flush() throws IOException
flush
in interface BitStream
IOException
open(boolean, java.lang.String, java.lang.String)
,
close()
public void close() throws IOException
close
in interface BitStream
IOException
open(boolean, java.lang.String, java.lang.String)
,
reOpen(boolean, java.lang.String)
public long position() throws IOException
position
in interface BitStream
IOException
available()
,
seek(long)
public long available() throws IOException
available
in interface BitStream
IOException
position
,
seek(long)
public long seek(long pos) throws IOException
seek
in interface BitStream
pos
- Required stream position in bits.
-1L
if not implemented).
IOException
position
public void write(long bits, int length) throws IOException
write
in interface BitStream
bits
- Bits to be written (LSB first).length
- Number of bits to write (negative lengths are ignored).
IOException
writeBytes(byte[], int, int)
,
read(int)
public void writeBytes(byte[] data, int start, int length) throws IOException
writeBytes
in interface BitStream
data
- 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).
IOException
write(long, int)
,
readBytes(byte[], int, int)
public long read(int length) throws IOException
read
in interface BitStream
length
- Number of bits to read (negative lengths are ignored).
IOException
readBytes(byte[], int, int)
,
write(long, int)
public void readBytes(byte[] data, int start, int length) throws IOException
readBytes
in interface BitStream
data
- 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).
IOException
read(int)
,
writeBytes(byte[], int, int)
public long skip(long length) throws IOException
skip
in interface BitStream
length
- Number of bits to skip (negative lengths are ignored).
IOException
seek(long)
public void set(String key, Object value)
set
in interface Property
set
in class DefaultProperty
key
- Key string.value
- The new value.Property.commit()
public Object get(String key)
get
in interface Property
get
in class DefaultProperty
key
- 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 |