magoffin.matt.meta.support
Class AbstractEnumMetadataResource<T extends java.lang.Enum<T>>

java.lang.Object
  extended by magoffin.matt.meta.support.AbstractMetadataResource
      extended by magoffin.matt.meta.support.AbstractEnumMetadataResource<T>
Type Parameters:
T - the enum type
All Implemented Interfaces:
MetadataResource
Direct Known Subclasses:
AbstractVideoMetadataResource, EXIFJpegMetadataResource, ID3v1MetadataResource, ID3v2_2MetadataResource, PNGMetadataResource

public abstract class AbstractEnumMetadataResource<T extends java.lang.Enum<T>>
extends AbstractMetadataResource

Abstract base MetadataResource implementation with special support for an enumeration type.

Version:
$Revision: 3 $ $Date: 2008-12-27 08:09:28 +1300 (Sat, 27 Dec 2008) $
Author:
Matt Magoffin (spamsqr@msqr.us)

Field Summary
 
Fields inherited from class magoffin.matt.meta.support.AbstractMetadataResource
log
 
Constructor Summary
AbstractEnumMetadataResource()
           
 
Method Summary
protected  void addError(T type, java.lang.String msg)
          Set an error message for a particular type.
protected  void addValue(T type, java.lang.Object value)
          Add a value for a type constant.
 java.lang.Object getValue(T type, java.util.Locale locale)
          Get a single metadata value based on a type constant.
 java.lang.Iterable<?> getValues(T type, java.util.Locale locale)
          Get all available metadata values based on a type constant.
protected  void setValue(T type, java.lang.Object value)
          Set a value for a type constant.
protected  void setValues(T type, java.util.Collection<?> values)
          Set a value for a type constant.
 
Methods inherited from class magoffin.matt.meta.support.AbstractMetadataResource
addError, addValue, clearValues, getParsedKeys, getParseErrors, getValue, getValueList, getValues, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractEnumMetadataResource

public AbstractEnumMetadataResource()
Method Detail

getValue

public java.lang.Object getValue(T type,
                                 java.util.Locale locale)
Get a single metadata value based on a type constant.

Enum.name() will be used to call AbstractMetadataResource.getValue(String, Locale). If more than one metadata of the specified type is available, this will return the first available one.

Parameters:
type - the type
locale - a Locale
Returns:
the value, or null if not available

getValues

public java.lang.Iterable<?> getValues(T type,
                                       java.util.Locale locale)
Get all available metadata values based on a type constant.

Enum.name() will be used to call AbstractMetadataResource.getValues(String, Locale). If more than one metadata of the specified type is available, this will return the first available one.

Parameters:
type - the type
locale - a Locale
Returns:
iterable for all values, never null

setValue

protected final void setValue(T type,
                              java.lang.Object value)
Set a value for a type constant.

This replaces any values currently associated with the key. Enum.name() will be used to call AbstractMetadataResource.setValue(String, Object).

Parameters:
type - the type to use
value - the value to set

setValues

protected final void setValues(T type,
                               java.util.Collection<?> values)
Set a value for a type constant.

This replaces any values currently associated with the key. Enum.name() will be used to call AbstractMetadataResource.setValues(String, Collection).

Parameters:
type - the type to use
values - the values to set

addValue

protected final void addValue(T type,
                              java.lang.Object value)
Add a value for a type constant.

This replaces any values currently associated with the key. Enum.name() will be used to call AbstractMetadataResource.addValue(String, Object).

Parameters:
type - the type to use
value - the value to add

addError

protected final void addError(T type,
                              java.lang.String msg)
Set an error message for a particular type.

Enum.name() will be used to call AbstractMetadataResource.addError(String, String).

Parameters:
type - the type to set the error message for
msg - the error message