|
||||||||||
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.DefaultFileFormat
public abstract class DefaultFileFormat
File format default implementation.
Field Summary |
---|
Fields inherited from class cz.cuni.jagrlib.Piece |
---|
channels, info, pl, plugs, reg, TEMPLATE_TYPE, userBreak |
Fields inherited from interface cz.cuni.jagrlib.iface.DataFileFormat |
---|
DOUBLE_STREAM |
Fields inherited from interface cz.cuni.jagrlib.iface.Property |
---|
LOGGING, STATISTICS, TEXT_DESCRIPTION |
Constructor Summary | |
---|---|
DefaultFileFormat()
|
Method Summary | |
---|---|
void |
closeFile()
Closes the file (used in file-mapping mode). |
abstract java.lang.String[] |
fileNameMasks()
Returns file-name masks associated with the file-format type. |
abstract int |
headerLength()
Length of file-format header (number of bytes which is necessary for file-format matching). |
int |
init(int phase)
Module initialization - called before any Runnable.run() . |
abstract boolean |
loadFile(BitStream stream,
java.lang.Object support)
Retrieves data from the given BitStream . |
abstract boolean |
loadFile(java.lang.String fileName,
java.lang.String detail)
Retrieves data from the given file (stream). |
abstract double |
match(byte[] header,
java.lang.String fileName)
File-format match test. |
static float |
readFloat(java.io.InputStream is,
boolean littleEndian)
Read one binary float number. |
static java.lang.String |
readLine(java.io.InputStream is)
Read next nonempty line. |
static boolean |
readParameters(EntropyCodec codec,
java.lang.Object instance)
Reads and sets binary parameters to the given module instance. |
static java.lang.String |
readToken(java.io.InputStream is)
Read character token delimited by an white-space. |
static int |
readUnsigned16(BitStream s,
boolean littleEndian)
Reads 16-bit unsigned integer from the given bit-stream. |
static int |
readUnsigned16(EntropyCodec codec)
Reads 16-bit unsigned integer from the given codec stream (big endian). |
static long |
readUnsigned32(BitStream s,
boolean littleEndian)
Reads 32-bit unsigned integer from the given bit-stream. |
abstract boolean |
saveFile(BitStream stream,
java.lang.Object support)
Saves data to the given BitStream . |
abstract boolean |
saveFile(java.lang.String fileName,
java.lang.String detail)
Saves data to the given file (stream). |
static void |
writeFloat(java.io.OutputStream os,
float fl)
Writes binary float number in little endian format. |
static void |
writeLine(java.io.OutputStream os,
java.lang.String s)
Write the given string followed by system newline character. |
static void |
writeParameters(EntropyCodec codec,
java.lang.Object instance)
Writes binary parameters of the given module instance. |
static void |
writeUnsigned16(BitStream s,
int data,
boolean littleEndian)
Writes 16-bit unsigned integer to the given bit-stream. |
static void |
writeUnsigned16(EntropyCodec codec,
int data)
Stores the given 16-bit unsigned integer in big-endian order. |
static void |
writeUnsigned32(BitStream s,
long data,
boolean littleEndian)
Writes 32-bit unsigned integer to the given bit-stream. |
Methods inherited from class cz.cuni.jagrlib.Piece |
---|
className, connect, findPlug, findPlug, getInfo, getInterface, getInterface, getPlug, getReg, isCompatible, isCompatible, isConnected, logError, logWarning, myInterface, newInputPlug, newOptOutputPlug, newOutputPlug, newPlug, noTemplates, propBegin, propBounds, propDefault, propEnd, propEnum, propManipulator, propManipulator, setProgressListener, setRegStrings, setTemplate, setTemplateDynamic, stop |
Methods inherited from class cz.cuni.jagrlib.DefaultProperty |
---|
booleanProperty, booleanProperty, colorDoubleProperty, colorProperty, commit, doubleProperty, doubleProperty, doubleProperty, enumProperty, floatProperty, floatProperty, floatProperty, get, intProperty, intProperty, intProperty, longProperty, longProperty, longProperty, set, 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, get, set |
Methods inherited from interface cz.cuni.jagrlib.Breakable |
---|
setProgressListener, stop |
Constructor Detail |
---|
public DefaultFileFormat()
Method Detail |
---|
public static void writeLine(java.io.OutputStream os, java.lang.String s) throws java.io.IOException
java.io.IOException
public static java.lang.String readLine(java.io.InputStream is) throws java.io.IOException
null
if no line is available.
java.io.IOException
public static java.lang.String readToken(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public static float readFloat(java.io.InputStream is, boolean littleEndian) throws java.io.IOException
is
- Stream to read from.littleEndian
- true
for little endian.
java.io.IOException
public static void writeFloat(java.io.OutputStream os, float fl) throws java.io.IOException
java.io.IOException
public static final int readUnsigned16(BitStream s, boolean littleEndian) throws java.io.IOException
java.io.IOException
public static final void writeUnsigned16(BitStream s, int data, boolean littleEndian) throws java.io.IOException
java.io.IOException
public static final long readUnsigned32(BitStream s, boolean littleEndian) throws java.io.IOException
java.io.IOException
public static final void writeUnsigned32(BitStream s, long data, boolean littleEndian) throws java.io.IOException
java.io.IOException
public static final int readUnsigned16(EntropyCodec codec) throws java.io.IOException
java.io.IOException
public static final void writeUnsigned16(EntropyCodec codec, int data) throws java.io.IOException
java.io.IOException
public static final boolean readParameters(EntropyCodec codec, java.lang.Object instance) throws java.io.IOException
true
if object was successfully set up.
java.io.IOException
public static final void writeParameters(EntropyCodec codec, java.lang.Object instance) throws java.io.IOException
java.io.IOException
public abstract int headerLength()
headerLength
in interface DataFileFormat
match(byte[], java.lang.String)
public abstract double match(byte[] header, java.lang.String fileName)
match
in interface DataFileFormat
header
- Bytes from beginning of the file.fileName
- Optional file-name string.
0.0
.. no way,
0.5
.. maybe, 0.9
.. almost sure, 1.0
..
absolutely - no need to check another formats).headerLength()
,
fileNameMasks()
public abstract java.lang.String[] fileNameMasks()
fileNameMasks
in interface DataFileFormat
null
.match(byte[], java.lang.String)
public abstract boolean loadFile(java.lang.String fileName, java.lang.String detail) throws java.io.IOException
loadFile
in interface DataFileFormat
fileName
- File-name (stream-name) to read from (can be null
).detail
- Further implementation-specific information ("r" or "rw" for mapped mode).
true
if the operation was successful.
java.io.IOException
loadFile(BitStream,Object)
,
saveFile(String,String)
,
closeFile()
public abstract boolean loadFile(BitStream stream, java.lang.Object support) throws java.io.IOException
BitStream
. This metod is optional.
The stream should be opened before - only the reOpen(false,null)
call
can be used.
loadFile
in interface DataFileFormat
stream
- Input bit-stream (opened - call reOpen(false,null)
first).support
- Implementation-specific data (e.g. second BitStream
for
file-formats with DataFileFormat.DOUBLE_STREAM
property).
true
if the operation was successful.
java.io.IOException
loadFile(String,String)
,
DataFileFormat.DOUBLE_STREAM
public abstract boolean saveFile(java.lang.String fileName, java.lang.String detail) throws java.io.IOException
saveFile
in interface DataFileFormat
fileName
- File-name (stream-name) to write to (can be null
).detail
- Further implementation-specific information.
true
if the operation was successful.
java.io.IOException
saveFile(BitStream,Object)
,
loadFile(String,String)
public abstract boolean saveFile(BitStream stream, java.lang.Object support) throws java.io.IOException
BitStream
. This metod is optional.
The stream should be opened and empty - the reOpen(true,null)
call
is not required.
saveFile
in interface DataFileFormat
stream
- Output bit-stream (opened and empty).support
- Implementation-specific data (e.g. second BitStream
for
file-formats with DataFileFormat.DOUBLE_STREAM
property).
true
if the operation was successful.
java.io.IOException
saveFile(String,String)
,
DataFileFormat.DOUBLE_STREAM
public void closeFile() throws java.io.IOException
closeFile
in interface DataFileFormat
java.io.IOException
loadFile(String,String)
public int init(int phase)
Runnable.run()
.
Individual phases (starting at 0
) will be called until maximum
requested phase number is reached.
init
in class Piece
phase
- Current phase number.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |