com.drew.metadata
Class Metadata

java.lang.Object
  extended by com.drew.metadata.Metadata
All Implemented Interfaces:
Serializable

public final class Metadata
extends Object
implements Serializable

A top-level object to hold various types of metadata (such as Exif or IPTC) relating to one entity (such as a file or stream). Metadata objects may contain zero or more directories. Each directory may contain zero or more tags with corresponding values.

See Also:
Serialized Form

Field Summary
private  ArrayList directoryList
          List of Directory objects set against this object.
private  HashMap directoryMap
           
 
Constructor Summary
Metadata()
          Creates a new instance of Metadata.
 
Method Summary
 boolean containsDirectory(Class type)
          Indicates whether a given directory type has been created in this metadata repository.
 Directory getDirectory(Class type)
          Returns a Directory of specified type.
 int getDirectoryCount()
          Returns a count of unique directories in this metadata collection.
 Iterator getDirectoryIterator()
          Creates an Iterator over the tag types set against this image, preserving the order in which they were set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

directoryMap

private final HashMap directoryMap

directoryList

private final ArrayList directoryList
List of Directory objects set against this object. Keeping a list handy makes creation of an Iterator and counting tags simple.

Constructor Detail

Metadata

public Metadata()
Creates a new instance of Metadata. Package private.

Method Detail

getDirectoryIterator

public Iterator getDirectoryIterator()
Creates an Iterator over the tag types set against this image, preserving the order in which they were set. Should the same tag have been set more than once, it's first position is maintained, even though the final value is used.

Returns:
an Iterator of tag types set for this image

getDirectoryCount

public int getDirectoryCount()
Returns a count of unique directories in this metadata collection.

Returns:
the number of unique directory types set for this metadata collection

getDirectory

public Directory getDirectory(Class type)
Returns a Directory of specified type. If this Metadata object already contains such a directory, it is returned. Otherwise a new instance of this directory will be created and stored within this Metadata object.

Parameters:
type - the type of the Directory implementation required.
Returns:
a directory of the specified type.

containsDirectory

public boolean containsDirectory(Class type)
Indicates whether a given directory type has been created in this metadata repository. Directories are created by calling getDirectory(Class).

Parameters:
type - the Directory type
Returns:
true if the metadata directory has been created