Base class for all Metadata directory types with supporting methods for setting and
getting tag values.
addError
public void addError(String message)
containsTag
public boolean containsTag(int tagType)
Indicates whether the specified tag type has been set.
tagType
- the tag type to check for
- true if a value exists for the specified tag type, false if not
getBoolean
public boolean getBoolean(int tagType)
throws MetadataException
Returns the specified tag's value as a boolean, if possible.
getByteArray
public byte[] getByteArray(int tagType)
throws MetadataException
Gets the specified tag's value as an byte array, if possible. Only supported
where the tag is set as String, int[], byte[] or Rational[].
tagType
- the tag identifier
- the tag's value as a byte array
MetadataException
- if the tag has not been set, or cannot be converted to
a byte array
getDate
public java.util.Date getDate(int tagType)
throws MetadataException
Returns the specified tag's value as a java.util.Date, if possible.
getDescription
public String getDescription(int tagType)
throws MetadataException
Provides a description of a tag's value using the descriptor set by
setDescriptor(Descriptor)
.
tagType
- the tag type identifier
- the tag value's description as a String
MetadataException
- if a descriptor hasn't been set, or if an error
occurs during calculation of the description within the Descriptor
getDouble
public double getDouble(int tagType)
throws MetadataException
Returns the specified tag's value as a double, if possible.
getErrorCount
public int getErrorCount()
getErrors
public Iterator getErrors()
getFloat
public float getFloat(int tagType)
throws MetadataException
Returns the specified tag's value as a float, if possible.
getInt
public int getInt(int tagType)
throws MetadataException
Returns the specified tag's value as an int, if possible.
getIntArray
public int[] getIntArray(int tagType)
throws MetadataException
Gets the specified tag's value as an int array, if possible. Only supported
where the tag is set as String, int[], byte[] or Rational[].
tagType
- the tag identifier
- the tag's value as an int array
MetadataException
- if the tag has not been set, or cannot be converted to
an int array
getLong
public long getLong(int tagType)
throws MetadataException
Returns the specified tag's value as a long, if possible.
getName
public abstract String getName()
Provides the name of the directory, for display purposes. E.g. Exif
- the name of the directory
getObject
public Object getObject(int tagType)
Returns the object hashed for the particular tag type specified, if available.
tagType
- the tag type identifier
- the tag's value as an Object if available, else null
getRational
public Rational getRational(int tagType)
throws MetadataException
Returns the specified tag's value as a Rational, if possible.
getString
public String getString(int tagType)
Returns the specified tag's value as a String. This value is the 'raw' value. A more presentable decoding
of this value may be obtained from the corresponding Descriptor.
- the String reprensentation of the tag's value, or
null
if the tag hasn't been defined.
getStringArray
public String[] getStringArray(int tagType)
throws MetadataException
Gets the specified tag's value as a String array, if possible. Only supported
where the tag is set as String[], String, int[], byte[] or Rational[].
tagType
- the tag identifier
- the tag's value as an array of Strings
MetadataException
- if the tag has not been set or cannot be represented
as a String[]
getTagCount
public int getTagCount()
Returns the number of tags set in this Directory.
- the number of tags set in this Directory
getTagIterator
public Iterator getTagIterator()
Returns an Iterator of Tag instances that have been set in this Directory.
- an Iterator of Tag instances
getTagName
public String getTagName(int tagType)
Returns the name of a specified tag as a String.
tagType
- the tag type identifier
- the tag's name as a String
getTagNameMap
protected abstract HashMap getTagNameMap()
Provides the map of tag names, hashed by tag type identifier.
hasErrors
public boolean hasErrors()
setBoolean
public void setBoolean(int tagType,
boolean value)
Sets an int value for the specified tag.
tagType
- the tag's value as an intvalue
- the value for the specified tag as a boolean
setByteArray
public void setByteArray(int tagType,
byte[] bytes)
Sets a byte array for the specified tag.
tagType
- the tag identifierbytes
- the byte array to store
setDate
public void setDate(int tagType,
java.util.Date value)
Sets a java.util.Date value for the specified tag.
tagType
- the tag's value as an intvalue
- the value for the specified tag as a java.util.Date
setDescriptor
public void setDescriptor(TagDescriptor descriptor)
Sets the descriptor used to interperet tag values.
descriptor
- the descriptor used to interperet tag values
setDouble
public void setDouble(int tagType,
double value)
Sets a double value for the specified tag.
tagType
- the tag's value as an intvalue
- the value for the specified tag as a double
setFloat
public void setFloat(int tagType,
float value)
Sets a float value for the specified tag.
tagType
- the tag's value as an intvalue
- the value for the specified tag as a float
setInt
public void setInt(int tagType,
int value)
Sets an int value for the specified tag.
tagType
- the tag's value as an intvalue
- the value for the specified tag as an int
setIntArray
public void setIntArray(int tagType,
int[] ints)
Sets an int array for the specified tag.
tagType
- the tag identifierints
- the int array to store
setLong
public void setLong(int tagType,
long value)
Sets a long value for the specified tag.
tagType
- the tag's value as an intvalue
- the value for the specified tag as a long
setObject
public void setObject(int tagType,
Object value)
Private helper method, containing common functionality for all 'add'
methods.
tagType
- the tag's value as an intvalue
- the value for the specified tag
setObjectArray
public void setObjectArray(int tagType,
Object array)
Private helper method, containing common functionality for all 'add...Array'
methods.
tagType
- the tag's value as an intarray
- the array of values for the specified tag
setRational
public void setRational(int tagType,
Rational rational)
Sets a Rational value for the specified tag.
tagType
- the tag's value as an intrational
- rational number
setRationalArray
public void setRationalArray(int tagType,
Rational[] rationals)
Sets a Rational array for the specified tag.
tagType
- the tag identifierrationals
- the Rational array to store
setString
public void setString(int tagType,
String value)
Sets an int value for the specified tag.
tagType
- the tag's value as an intvalue
- the value for the specified tag as a String
setStringArray
public void setStringArray(int tagType,
String[] strings)
Sets a String array for the specified tag.
tagType
- the tag identifierstrings
- the String array to store