cz.cuni.jagrlib.iface
Interface DataFileFormat

All Superinterfaces:
Breakable, Property
All Known Implementing Classes:
CompressedFormatBW, CompressedFormatGray, CompressedFormatOrder, CompressedFormatPal, CompressedFormatRGB, CompressedFormatTransform, DefaultBrepFileFormat, DefaultFileFormat, DefaultRasterFileFormat, FractalCompressionQtree, GIFFileFormat, HDRFileFormat, JFIFFileFormat, MeshCompressionRLE, OBJFileFormat, PFMFileFormat, PNGFileFormat, WAVFileFormatMapped

public interface DataFileFormat
extends Property, Breakable

Interface for data persistence algorithms (general load/save filter).

Since:
0.13
See Also:
DataFileFormat.java, BitStream

Field Summary
static java.lang.String DOUBLE_STREAM
          Double-stream property (Boolean): file-format uses more than one bit-stream - e.g. for header and raw data.
 
Fields inherited from interface cz.cuni.jagrlib.iface.Property
LOGGING, STATISTICS, TEXT_DESCRIPTION
 
Method Summary
 void closeFile()
          Closes the file (used in file-mapping mode).
 java.lang.String[] fileNameMasks()
          Returns file-name masks associated with the file-format type.
 int headerLength()
          Length of file-format header (number of bytes which is necessary for file-format matching).
 boolean loadFile(BitStream stream, java.lang.Object support)
          Retrieves data from the given BitStream.
 boolean loadFile(java.lang.String fileName, java.lang.String detail)
          Retrieves data from the given file (stream).
 double match(byte[] header, java.lang.String fileName)
          File-format match test.
 boolean saveFile(BitStream stream, java.lang.Object support)
          Saves data to the given BitStream.
 boolean saveFile(java.lang.String fileName, java.lang.String detail)
          Saves data to the given file (stream).
 
Methods inherited from interface cz.cuni.jagrlib.iface.Property
commit, get, set
 
Methods inherited from interface cz.cuni.jagrlib.Breakable
setProgressListener, stop
 

Field Detail

DOUBLE_STREAM

static final java.lang.String DOUBLE_STREAM
Double-stream property (Boolean): file-format uses more than one bit-stream - e.g. for header and raw data.

See Also:
loadFile(BitStream,Object), saveFile(BitStream,Object), Constant Field Values
Method Detail

headerLength

int headerLength()
Length of file-format header (number of bytes which is necessary for file-format matching).

Returns:
Number of bytes from beginning of a file which are enough for file-format match test.
See Also:
match(byte[], java.lang.String)

match

double match(byte[] header,
             java.lang.String fileName)
File-format match test. Guesses whether the binary file-header (and file-name) can belong to this file-format type.

Parameters:
header - Bytes from beginning of the file.
fileName - Optional file-name string.
Returns:
Probability of being my file-format type (0.0 .. no way, 0.5 .. maybe, 0.9 .. almost sure, 1.0 .. absolutely - no need to check another formats).
See Also:
headerLength(), fileNameMasks()

fileNameMasks

java.lang.String[] fileNameMasks()
Returns file-name masks associated with the file-format type. Needs not be implemented in systems where "file-name -> file-type" mapping is irrelevant.

Returns:
Array of wild-card file-name masks (e.g. ["*.jpg", "*.jpeg", "*.jfif"]) or null.
See Also:
match(byte[], java.lang.String)

loadFile

boolean loadFile(java.lang.String fileName,
                 java.lang.String detail)
                 throws java.io.IOException
Retrieves data from the given file (stream). Can be used for "file opening" in virtual-mapped mode.

Parameters:
fileName - File-name (stream-name) to read from (can be null).
detail - Further implementation-specific information ("r" or "rw" for mapped mode).
Returns:
true if the operation was successful.
Throws:
java.io.IOException
See Also:
loadFile(BitStream,Object), saveFile(String,String), closeFile()

loadFile

boolean loadFile(BitStream stream,
                 java.lang.Object support)
                 throws java.io.IOException
Retrieves data from the given BitStream. This metod is optional.

The stream should be opened before - only the BitStream.reOpen(boolean, java.lang.String) call can be used.

Parameters:
stream - Input bit-stream (opened - call BitStream.reOpen(boolean, java.lang.String) first).
support - Implementation-specific data (e.g. second BitStream for file-formats with DOUBLE_STREAM property).
Returns:
true if the operation was successful.
Throws:
java.io.IOException
See Also:
loadFile(String,String), DOUBLE_STREAM

saveFile

boolean saveFile(java.lang.String fileName,
                 java.lang.String detail)
                 throws java.io.IOException
Saves data to the given file (stream).

Parameters:
fileName - File-name (stream-name) to write to (can be null).
detail - Further implementation-specific information.
Returns:
true if the operation was successful.
Throws:
java.io.IOException
See Also:
saveFile(BitStream,Object), loadFile(String,String)

saveFile

boolean saveFile(BitStream stream,
                 java.lang.Object support)
                 throws java.io.IOException
Saves data to the given BitStream. This metod is optional.

The stream should be opened and empty - the reOpen(true,null) call is not required.

Parameters:
stream - Output bit-stream (opened and empty).
support - Implementation-specific data (e.g. second BitStream for file-formats with DOUBLE_STREAM property).
Returns:
true if the operation was successful.
Throws:
java.io.IOException
See Also:
saveFile(String,String), DOUBLE_STREAM

closeFile

void closeFile()
               throws java.io.IOException
Closes the file (used in file-mapping mode).

Throws:
java.io.IOException
See Also:
loadFile(String,String)