com.drew.metadata.iptc
Class IptcReader

java.lang.Object
  extended by com.drew.metadata.iptc.IptcReader
All Implemented Interfaces:
MetadataReader

public class IptcReader
extends Object
implements MetadataReader

Decodes IPTC binary data, populating a Metadata object with tag values in an IptcDirectory.

Author:
Drew Noakes http://drewnoakes.com

Field Summary
private  byte[] _data
          The Iptc data segment.
 
Constructor Summary
IptcReader(byte[] data)
          Creates an IptcReader for the given IPTC data segment.
IptcReader(File jpegFile)
          Deprecated. Not all files will be Jpegs! Use a constructor that provides the IPTC segment in isolation.
IptcReader(InputStream jpegInputStream)
          Deprecated. Not all files will be Jpegs! Use a constructor that provides the IPTC segment in isolation.
 
Method Summary
 Metadata extract()
          Performs the Exif data extraction, returning a new instance of Metadata.
 Metadata extract(Metadata metadata)
          Performs the Exif data extraction, adding found values to the specified instance of Metadata.
private  int get32Bits(int offset)
          Returns an int calculated from two bytes of data at the specified offset (MSB, LSB).
private  void processTag(Directory directory, int directoryType, int tagType, int offset, int tagByteCount)
          This method serves as marsheller of objects for dataset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_data

private final byte[] _data
The Iptc data segment.

Constructor Detail

IptcReader

public IptcReader(File jpegFile)
           throws JpegProcessingException
Deprecated. Not all files will be Jpegs! Use a constructor that provides the IPTC segment in isolation.

Creates a new IptcReader for the specified Jpeg jpegFile.

Throws:
JpegProcessingException

IptcReader

public IptcReader(InputStream jpegInputStream)
           throws JpegProcessingException
Deprecated. Not all files will be Jpegs! Use a constructor that provides the IPTC segment in isolation.

Creates an IptcReader for a JPEG stream.

Parameters:
jpegInputStream - JPEG stream. Stream will be closed.
Throws:
JpegProcessingException

IptcReader

public IptcReader(byte[] data)
Creates an IptcReader for the given IPTC data segment.

Method Detail

extract

public Metadata extract()
Performs the Exif data extraction, returning a new instance of Metadata.

Specified by:
extract in interface MetadataReader
Returns:
The populated Metadata object.

extract

public Metadata extract(Metadata metadata)
Performs the Exif data extraction, adding found values to the specified instance of Metadata.

Specified by:
extract in interface MetadataReader
Returns:
The updated Metadata object.

get32Bits

private int get32Bits(int offset)
               throws MetadataException
Returns an int calculated from two bytes of data at the specified offset (MSB, LSB).

Parameters:
offset - position within the data buffer to read first byte
Returns:
the 32 bit int value, between 0x0000 and 0xFFFF
Throws:
MetadataException

processTag

private void processTag(Directory directory,
                        int directoryType,
                        int tagType,
                        int offset,
                        int tagByteCount)
This method serves as marsheller of objects for dataset. It converts from IPTC octets to relevant java object.