Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.harvard.hul.ois.jhove.module
Class Jpeg2000Module

    java.lang.Object
      edu.harvard.hul.ois.jhove.ModuleBase
          edu.harvard.hul.ois.jhove.module.Jpeg2000Module

All Implemented Interfaces:
  Module

    public class Jpeg2000Module

extends ModuleBase

Module for identification and validation of JPEG 2000 files. Code is included for JPX, but is almost entirely untested due to the lack of available sample files that use more than a tiny fraction of the features. The current version of the module is based on the typo-laden and inconsisent "JPEG 2000 Part II Final Committee Draft" (7 December 2000). The final standard (5 May 2004) has just reached our hands, and this code will be reviewed against it and revised accordingly in the near future. (All opinions expressed in this paragraph are those of the programmer.) JPEG 2000 format is not JPEG format, and isn't compatible with it. As with JPEG, JPEG 2000 is not in itself a file format. It can be encapsulated in JP2 or JPX format, which are recognized here.

Author:
  Gary McGath

Field Summary
`protected NisoImageMetadata` | `_defaultNiso`
`protected java.io.DataInputStream` | `_dstream`
`protected NisoImageMetadata` | `_niso` PRIVATE INSTANCE FIELDS.
`protected java.util.List<Property>` | `_propList`
`protected java.io.RandomAccessFile` | `_raf`
`protected RAFInputStream` | `_rafStream`
`protected java.util.List<Property>` | `associationProps`
`protected java.util.List<Property>` | `binaryFilterProps`
`protected java.util.List<Codestream>` | `codestreams`
`protected java.util.List<Property>` | `colorSpecs`
`protected boolean` | `colorSpecSeen`
`protected java.util.List<Property>` | `composLayers`
`protected Codestream` | `curCodestream`
`protected java.util.List<Property>` | `digitalSigProps`
`protected boolean` | `filterMode`
`protected boolean` | `imageHeaderSeen`
`protected boolean` | `jp2Compliant`
`protected boolean` | `jp2HdrSeen`
`protected boolean` | `jpxCompliant`
`protected int` | `nCodestreamHeaders`
`protected int` | `nCodestreams`
`protected boolean` | `rreqSeen`
`protected java.util.List<Property>` | `uuidInfos`
`protected java.util.List<Property>` | `uuids`
`protected java.util.List<java.lang.String>` | `xmlList`

Fields inherited from class edu.harvard.hul.ois.jhove.ModuleBase
`_app, _bigEndian, _checksumFinished, _countStream, _coverage, _crc32, _date, _defaultParams, _features, _format, _init, _isRandomAccess, _je, _logger, _md5, _mimeType, _name, _nByte, _note, _param, _release, _repInfoNote, _rights, _sha1, _signature, _specification, _validityNote, _vendor, _verbosity, _wellFormedNote`

Fields inherited from interface edu.harvard.hul.ois.jhove.Module
`MAXIMUM_VERBOSITY, MINIMUM_VERBOSITY`

Constructor Summary
`Jpeg2000Module()` Instantiate a `JpegModule` object.

Method Summary
`void` | `addAssociationProp(Property p)` Adds an association property to the metadata.
`void` | `addBinaryFilterProp(Property p)` Adds a binary filter property to the metadata.
`void` | `addColorSpec(Property p)` Adds a color spec property to the metadata.
`void` | `addComposLayer(Property p)` Adds a Compositing Layer property to the list of Compositing Layer properties.
`void` | `addDigitalSignatureProp(Property p)` Adds a digital signature property to the metadata.
`void` | `addProperty(Property p)` Adds a property to the JPEG2000 metadata.
`void` | `addUUID(Property p)` Adds a UUID property to the list of UUID properties.
`void` | `addUUIDInfo(Property p)` Adds a UUIDInfo property to the list of UUIDInfo properties.
`void` | `addXML(java.lang.String s)` Adds an XML string to the list of XML properties.
`Codestream` | `getCodestream(int n)` Returns the nth `Codestream`, creating it if necessary, and make it the current one.
`NisoImageMetadata` | `getCurrentNiso()` Returns the current NisoImageMetadata object.
`NisoImageMetadata` | `getDefaultNiso()` Returns the default NisoImageMetadata object.
`long` | `getFilePos()` Return the current position in the module.
`int` | `getNCodestreamHeaders()` Returns the codestream header count.
`int` | `getNCodestreams()` Returns the codestream count.
`protected void` | `initParse()` Initializes the state of the module for parsing.
`boolean` | `isJP2HdrSeen()`
`void` | `parse(java.io.RandomAccessFile raf, RepInfo info)` Parse the content of a stream digital object and store the results in RepInfo.
`java.lang.String` | `read4Chars(java.io.DataInputStream stream)` Reads 4 bytes and concatenates them into a String.
`protected boolean` | `readBoxes(RepInfo info)`
`protected boolean` | `readFileTypeBox(RepInfo info)`
`long` | `readSignedLong(java.io.DataInputStream stream)` One-argument version of `readSignedLong`.
`long` | `readUnsignedInt(java.io.DataInputStream stream)` One-argument version of `readUnsignedInt`.
`int` | `readUnsignedShort(java.io.DataInputStream stream)` One-argument version of `readUnsignedShort`.
`void` | `seek(long pos)` Seek to a new file position.
`void` | `setColorSpecSeen(boolean b)` Set the flag indicating the color specification box has been seen.
`void` | `setImageHeaderSeen(boolean b)` Set the flag indicating the color specification box has been seen.
`void` | `setJP2Compliant(boolean b)` Sets a flag indicating JP2 compliance.
`void` | `setJP2HdrSeen(boolean b)` Set the flag indicating that a JP2 header has been seen.
`void` | `setJPXCompliant(boolean b)` Sets a flag indicating JPX compliance.
`void` | `setNCodestreamHeaders(int n)` Sets the codestream header count.
`void` | `setNCodestreams(int n)` Sets the codestream count.
`void` | `setRReqSeen(boolean b)` Set the flag indicating the reader requirements box has been seen.
`protected boolean` | `skipOverBox(BoxHeader hdr, RepInfo info, java.io.DataInputStream dstrm)`

Methods inherited from class edu.harvard.hul.ois.jhove.ModuleBase
`addIntegerProperty, addIntegerProperty, applyDefaultParams, calcRAChecksum, checkSignatures, checkSignatures, getApp, getBase, getBufferedDataStream, getCoverage, getCRC32, getDate, getDefaultParams, getFeatures, getFormat, getMimeType, getName, getNByte, getNote, getRelease, getRepInfoNote, getRights, getSignature, getSpecification, getValidityNote, getVendor, getWellFormedNote, hasFeature, init, initFeatures, isBigEndian, isRandomAccess, param, parse, readByteBuf, readDouble, readDouble, readDouble, readFloat, readFloat, readSignedByte, readSignedByte, readSignedByte, readSignedInt, readSignedInt, readSignedInt, readSignedLong, readSignedRational, readSignedRational, readSignedShort, readSignedShort, readSignedShort, readUnsignedByte, readUnsignedByte, readUnsignedByte, readUnsignedInt, readUnsignedInt, readUnsignedInt, readUnsignedRational, readUnsignedRational, readUnsignedRational, readUnsignedShort, readUnsignedShort, readUnsignedShort, resetParams, setApp, setBase, setChecksums, setCRC32, setDefaultParams, setMD5, setNByte, setSHA1, setValidityNote, setVerbosity, show, skipBytes, skipBytes, vectorToPropArray`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _niso

    protected NisoImageMetadata _niso

  PRIVATE INSTANCE FIELDS.

### _defaultNiso

    protected NisoImageMetadata _defaultNiso

### _dstream

    protected java.io.DataInputStream _dstream

### _raf

    protected java.io.RandomAccessFile _raf

### _rafStream

    protected RAFInputStream _rafStream

### _propList

    protected java.util.List<Property> _propList

### codestreams

    protected java.util.List<Codestream> codestreams

### binaryFilterProps

    protected java.util.List<Property> binaryFilterProps

### associationProps

    protected java.util.List<Property> associationProps

### digitalSigProps

    protected java.util.List<Property> digitalSigProps

### nCodestreams

    protected int nCodestreams

### nCodestreamHeaders

    protected int nCodestreamHeaders

### colorSpecs

    protected java.util.List<Property> colorSpecs

### uuids

    protected java.util.List<Property> uuids

### composLayers

    protected java.util.List<Property> composLayers

### uuidInfos

    protected java.util.List<Property> uuidInfos

### xmlList

    protected java.util.List<java.lang.String> xmlList

### jp2HdrSeen

    protected boolean jp2HdrSeen

### rreqSeen

    protected boolean rreqSeen

### colorSpecSeen

    protected boolean colorSpecSeen

### imageHeaderSeen

    protected boolean imageHeaderSeen

### jp2Compliant

    protected boolean jp2Compliant

### jpxCompliant

    protected boolean jpxCompliant

### curCodestream

    protected Codestream curCodestream

### filterMode

    protected boolean filterMode

Constructor Detail

### Jpeg2000Module

    public Jpeg2000Module()

  Instantiate a `JpegModule` object.

Method Detail

### parse

    public final void parse(java.io.RandomAccessFile raf,
                            RepInfo info)
                     throws java.io.IOException

  Parse the content of a stream digital object and store the results in RepInfo. This module is based on a RandomAccessFile because of the requirements of the (so far) rarely used fragmented codestream feature. Since just about everything else can be done with an InputStream, we use a RAFInputStream except on the occasions when random access is needed. We pass the module as the `counted` argment to all read calls, so that we can compute relative positions in the stream based on _nByte.

  Specified by:
    `parse` in interface `Module`
  Overrides:
    `parse` in class `ModuleBase`
  Parameters:
    `raf` - A RandomAccessFile to be parsed.
    `info` - A fresh (on the first call) RepInfo object which will be modified to reflect the results of the parsing If multiple calls to `parse` are made on the basis of a nonzero value being returned, the same RepInfo object should be passed with each call.
  Throws:
    `java.io.IOException`

### getFilePos

    public long getFilePos()

  Return the current position in the module. This is somewhat optimistically named; it should be trusted only for relative positions when no seek operations occur in between calls to getFilePos.

### seek

    public void seek(long pos)
              throws java.io.IOException

  Seek to a new file position.

  Throws:
    `java.io.IOException`

### getDefaultNiso

    public NisoImageMetadata getDefaultNiso()

  Returns the default NisoImageMetadata object.

### getCurrentNiso

    public NisoImageMetadata getCurrentNiso()

  Returns the current NisoImageMetadata object. If curCodestream is null, returns the default NisoImageMetadata, otherwise returns the NisoImageMetadata of curCodestream.

### getCodestream

    public Codestream getCodestream(int n)

  Returns the nth `Codestream`, creating it if necessary, and make it the current one. The value of `nCodestreams` or `nCodestreamHeaders` is not affected, even if a new `Codestream` is created.

### getNCodestreams

    public int getNCodestreams()

  Returns the codestream count. Because items may be added to the codestreams list when only the header is seen, this may be less than the size of the codestreams list. It will never be more.

### getNCodestreamHeaders

    public int getNCodestreamHeaders()

  Returns the codestream header count.

### isJP2HdrSeen

    public boolean isJP2HdrSeen()

### setNCodestreams

    public void setNCodestreams(int n)

  Sets the codestream count. This affects only the variable, not the size of the codestreams list. The codestream count should never be set to a value larger than the codestreams list; it signifies the number of elements of the list for which codestream boxes have actually been seen.

### setNCodestreamHeaders

    public void setNCodestreamHeaders(int n)

  Sets the codestream header count.

### setJP2HdrSeen

    public void setJP2HdrSeen(boolean b)

  Set the flag indicating that a JP2 header has been seen.

### setRReqSeen

    public void setRReqSeen(boolean b)

  Set the flag indicating the reader requirements box has been seen.

### setColorSpecSeen

    public void setColorSpecSeen(boolean b)

  Set the flag indicating the color specification box has been seen.

### setImageHeaderSeen

    public void setImageHeaderSeen(boolean b)

  Set the flag indicating the color specification box has been seen.

### setJP2Compliant

    public void setJP2Compliant(boolean b)

  Sets a flag indicating JP2 compliance. If the flag is set to `true`, and the JPX compliance flag is also true, set the MIME type to "image/jpx".

### setJPXCompliant

    public void setJPXCompliant(boolean b)

  Sets a flag indicating JPX compliance.

### addProperty

    public void addProperty(Property p)

  Adds a property to the JPEG2000 metadata.

### addColorSpec

    public void addColorSpec(Property p)

  Adds a color spec property to the metadata.

### addBinaryFilterProp

    public void addBinaryFilterProp(Property p)

  Adds a binary filter property to the metadata.

### addAssociationProp

    public void addAssociationProp(Property p)

  Adds an association property to the metadata.

### addDigitalSignatureProp

    public void addDigitalSignatureProp(Property p)

  Adds a digital signature property to the metadata.

### addUUID

    public void addUUID(Property p)

  Adds a UUID property to the list of UUID properties. Called from the UUIDBox.

### addUUIDInfo

    public void addUUIDInfo(Property p)

  Adds a UUIDInfo property to the list of UUIDInfo properties. Called from UUIDInfoBox.

### addComposLayer

    public void addComposLayer(Property p)

  Adds a Compositing Layer property to the list of Compositing Layer properties. Called from the ComposLayerHdrBox.

### addXML

    public void addXML(java.lang.String s)

  Adds an XML string to the list of XML properties. Called from XMLBox.

### read4Chars

    public java.lang.String read4Chars(java.io.DataInputStream stream)
                                throws java.io.IOException

  Reads 4 bytes and concatenates them into a String.

  Throws:
    `java.io.IOException`

### readUnsignedShort

    public int readUnsignedShort(java.io.DataInputStream stream)
                          throws java.io.IOException

  One-argument version of `readUnsignedShort`. JPEG2000 is always big-endian, so readUnsignedShort can unambiguously drop its endian argument.

  Throws:
    `java.io.IOException`

### readUnsignedInt

    public long readUnsignedInt(java.io.DataInputStream stream)
                         throws java.io.IOException

  One-argument version of `readUnsignedInt`. JPEG2000 is always big-endian, so readUnsignedInt can unambiguously drop its endian argument.

  Throws:
    `java.io.IOException`

### readSignedLong

    public long readSignedLong(java.io.DataInputStream stream)
                        throws java.io.IOException

  One-argument version of `readSignedLong`. JPEG2000 is always big-endian, so readSignedLong can unambiguously drop its endian argument.

  Throws:
    `java.io.IOException`

### initParse

    protected void initParse()

  Initializes the state of the module for parsing.

  Overrides:
    `initParse` in class `ModuleBase`

### readBoxes

    protected boolean readBoxes(RepInfo info)
                         throws java.io.IOException

  Throws:
    `java.io.IOException`

### readFileTypeBox

    protected boolean readFileTypeBox(RepInfo info)
                               throws java.io.IOException

  Throws:
    `java.io.IOException`

### skipOverBox

    protected boolean skipOverBox(BoxHeader hdr,
                                  RepInfo info,
                                  java.io.DataInputStream dstrm)
                           throws java.io.IOException

  Throws:
    `java.io.IOException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD