jj2000.j2k.fileformat.reader
Class FileFormatReader

java.lang.Object
  |
  +--jj2000.j2k.fileformat.reader.FileFormatReader
All Implemented Interfaces:
FileFormatBoxes

public class FileFormatReader
extends java.lang.Object
implements FileFormatBoxes

This class reads the file format wrapper that may or may not exist around a valid JPEG 2000 codestream. Since no information from the file format is used in the actual decoding, this class simply goes through the file and finds the first valid codestream.

See Also:
FileFormatWriter

Field Summary
private  java.util.Vector codeStreamLength
          The lengths of the codestreams in the fileformat
private  java.util.Vector codeStreamPos
          The positions of the codestreams in the fileformat
private  RandomAccessIO in
          The random access from which the file format boxes are read
 boolean JP2FFUsed
          Flag indicating whether or not the JP2 file format is used
 
Fields inherited from interface jj2000.j2k.fileformat.FileFormatBoxes
BITS_PER_COMPONENT_BOX, CAPTURE_RESOLUTION_BOX, CHANNEL_DEFINITION_BOX, COLOUR_SPECIFICATION_BOX, COMPONENT_MAPPING_BOX, CONTIGUOUS_CODESTREAM_BOX, CSB_APPROX, CSB_ENUM_GREY, CSB_ENUM_SRGB, CSB_METH, CSB_PREC, DEFAULT_DISPLAY_RESOLUTION_BOX, FILE_TYPE_BOX, FT_BR, IMAGE_HEADER_BOX, IMB_C, IMB_IPR, IMB_UnkC, IMB_VERS, INTELLECTUAL_PROPERTY_BOX, JP2_HEADER_BOX, JP2_SIGNATURE_BOX, PALETTE_BOX, RESOLUTION_BOX, URL_BOX, UUID_BOX, UUID_INFO_BOX, UUID_LIST_BOX, XML_BOX
 
Constructor Summary
FileFormatReader(RandomAccessIO in)
          The constructor of the FileFormatReader
 
Method Summary
 long[] getCodeStreamPos()
          This method creates and returns an array of positions to contiguous codestreams in the file
 int getFirstCodeStreamLength()
          This method returns the length of the first contiguous codestreams in the file
 int getFirstCodeStreamPos()
          This method returns the position of the first contiguous codestreams in the file
 boolean readContiguousCodeStreamBox(long pos, int length, long longLength)
          This method skips the Contiguous codestream box and adds position of contiguous codestream to a vector
 void readFileFormat()
          This method checks whether the given RandomAccessIO is a valid JP2 file and if so finds the first codestream in the file.
 boolean readFileTypeBox()
          This method reads the File Type box.
 void readIntPropertyBox(int length)
          This method reads the contents of the Intellectual property box
 boolean readJP2HeaderBox(long pos, int length, long longLength)
          This method reads the JP2Header box
 void readUUIDBox(int length)
          This method reads the contents of the Intellectual property box
 void readUUIDInfoBox(int length)
          This method reads the contents of the Intellectual property box
 void readXMLBox(int length)
          This method reads the contents of the XML box
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

private RandomAccessIO in
The random access from which the file format boxes are read


codeStreamPos

private java.util.Vector codeStreamPos
The positions of the codestreams in the fileformat


codeStreamLength

private java.util.Vector codeStreamLength
The lengths of the codestreams in the fileformat


JP2FFUsed

public boolean JP2FFUsed
Flag indicating whether or not the JP2 file format is used

Constructor Detail

FileFormatReader

public FileFormatReader(RandomAccessIO in)
The constructor of the FileFormatReader

Parameters:
in - The RandomAccessIO from which to read the file format
Method Detail

readFileFormat

public void readFileFormat()
                    throws java.io.IOException,
                           java.io.EOFException
This method checks whether the given RandomAccessIO is a valid JP2 file and if so finds the first codestream in the file. Currently, the information in the codestream is not used

Throws:
java.io.IOException - If an I/O error ocurred.
java.io.EOFException - If end of file is reached

readFileTypeBox

public boolean readFileTypeBox()
                        throws java.io.IOException,
                               java.io.EOFException
This method reads the File Type box.

Returns:
false if the File Type box was not found or invalid else true
Throws:
java.io.IOException - If an I/O error ocurred.
java.io.EOFException - If the end of file was reached

readJP2HeaderBox

public boolean readJP2HeaderBox(long pos,
                                int length,
                                long longLength)
                         throws java.io.IOException,
                                java.io.EOFException
This method reads the JP2Header box

Parameters:
pos - The position in the file
length - The length of the JP2Header box
Returns:
false if the JP2Header box was not found or invalid else true
Throws:
java.io.IOException - If an I/O error ocurred.
java.io.EOFException - If the end of file was reached

readContiguousCodeStreamBox

public boolean readContiguousCodeStreamBox(long pos,
                                           int length,
                                           long longLength)
                                    throws java.io.IOException,
                                           java.io.EOFException
This method skips the Contiguous codestream box and adds position of contiguous codestream to a vector

Parameters:
pos - The position in the file
length - The length of the JP2Header box
Returns:
false if the Contiguous codestream box was not found or invalid else true
Throws:
java.io.IOException - If an I/O error ocurred.
java.io.EOFException - If the end of file was reached

readIntPropertyBox

public void readIntPropertyBox(int length)
This method reads the contents of the Intellectual property box


readXMLBox

public void readXMLBox(int length)
This method reads the contents of the XML box


readUUIDBox

public void readUUIDBox(int length)
This method reads the contents of the Intellectual property box


readUUIDInfoBox

public void readUUIDInfoBox(int length)
This method reads the contents of the Intellectual property box


getCodeStreamPos

public long[] getCodeStreamPos()
This method creates and returns an array of positions to contiguous codestreams in the file

Returns:
The positions of the contiguous codestreams in the file

getFirstCodeStreamPos

public int getFirstCodeStreamPos()
This method returns the position of the first contiguous codestreams in the file

Returns:
The position of the first contiguous codestream in the file

getFirstCodeStreamLength

public int getFirstCodeStreamLength()
This method returns the length of the first contiguous codestreams in the file

Returns:
The length of the first contiguous codestream in the file