|
||||||||||
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.JavaBitStream
public class JavaBitStream
Bit-stream object implemented with help of java.io streams (InputStream
,
OutputStream
).
Field Summary | |
---|---|
protected byte[] |
array
Temporary array for faster I/O operations. |
protected long |
buffer
Bit buffer. |
protected int |
bufferBits
Actual buffer length in bits. |
protected static java.lang.String |
CATEGORY
Object category. |
protected java.io.InputStream |
inputStream
Current input stream. |
protected boolean |
isOutput
Stream is intended for output. |
protected java.io.OutputStream |
outputStream
Current output stream. |
protected long |
position
Actual stream-position in bits. |
static RegPiece |
reg
Static registration instance for this class. |
static java.lang.String |
STREAM_OUTPUT
Stream-type property (boolean): intended for output. |
protected java.lang.String |
streamName
Data stream name (file-name etc.). |
protected static java.lang.String |
TEMPLATE_NAME
Object template identifier. |
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 | |
---|---|
JavaBitStream()
|
Method Summary | |
---|---|
long |
available()
How many bits are available to read (or skip). |
boolean |
canRead()
Stream is able to read data. |
void |
close()
Stream close. |
void |
flush()
Stream flush. |
protected void |
flushBuffer()
Flushes out the complete buffer . |
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). |
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()
Reads maximum amount of input bits into buffer . |
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. |
protected void |
writeBuffer()
Writes all complete bytes from buffer to the output 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 boolean isOutput
protected java.lang.String streamName
protected java.io.InputStream inputStream
protected java.io.OutputStream outputStream
protected long buffer
protected int bufferBits
protected long position
protected byte[] array
public static final java.lang.String STREAM_OUTPUT
protected static final java.lang.String TEMPLATE_NAME
protected static final java.lang.String CATEGORY
public static final RegPiece reg
Constructor Detail |
---|
public JavaBitStream()
Method Detail |
---|
protected final void writeBuffer() throws java.io.IOException
buffer
to the output stream.
java.io.IOException
flushBuffer()
,
buffer
protected void flushBuffer() throws java.io.IOException
buffer
. Incomplete byte is padded with zero bits.
java.io.IOException
writeBuffer()
,
buffer
protected final void readBuffer() throws java.io.IOException
buffer
.
Assumes bufferBits
== 0
.
java.io.IOException
writeBuffer()
,
buffer
public 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 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.
java.io.IOException
reOpen(boolean, java.lang.String)
public void reOpen(boolean output, java.lang.String detail) throws java.io.IOException
reOpen
in interface BitStream
output
- Open for output?detail
- Further implementation-specific information.
java.io.IOException
open(boolean, java.lang.String, java.lang.String)
public java.io.OutputStream getOutputStream()
getOutputStream
in interface BitStream
OutputStream
instance or null
if
not implemented.getInputStream()
public java.io.InputStream getInputStream()
getInputStream
in interface BitStream
InputStream
instance or null
if
not implemented.getOutputStream()
public void flush() throws java.io.IOException
flush
in interface BitStream
java.io.IOException
open(boolean, java.lang.String, java.lang.String)
,
close()
public void close() throws java.io.IOException
close
in interface BitStream
java.io.IOException
open(boolean, java.lang.String, java.lang.String)
,
reOpen(boolean, java.lang.String)
public long position() throws java.io.IOException
position
in interface BitStream
java.io.IOException
available()
,
seek(long)
public long available() throws java.io.IOException
available
in interface BitStream
java.io.IOException
position
,
seek(long)
public long seek(long pos)
seek
in interface BitStream
pos
- Required stream position in bits.
-1L
if not implemented).
java.io.IOException
position
public void write(long bits, int length) throws java.io.IOException
write
in interface BitStream
bits
- Bits to be written (LSB first).length
- Number of bits to write (negative lengths are ignored).
java.io.IOException
writeBytes(byte[], int, int)
,
read(int)
public void writeBytes(byte[] data, int start, int length) throws java.io.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).
java.io.IOException
write(long, int)
,
readBytes(byte[], int, int)
public long read(int length) throws java.io.IOException
read
in interface BitStream
length
- Number of bits to read (negative lengths are ignored).
java.io.IOException
readBytes(byte[], int, int)
,
write(long, int)
public void readBytes(byte[] data, int start, int length) throws java.io.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).
java.io.IOException
read(int)
,
writeBytes(byte[], int, int)
public long skip(long length) throws java.io.IOException
skip
in interface BitStream
length
- Number of bits to skip (negative lengths are ignored).
java.io.IOException
read(int)
public void set(java.lang.String key, java.lang.Object value)
set
in interface Property
set
in class DefaultProperty
key
- Key string.value
- The new value.Property.commit()
public java.lang.Object get(java.lang.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 |