magoffin.matt.meta.image
Class EXIFMetadataResourceFactory

java.lang.Object
  extended by magoffin.matt.meta.image.EXIFMetadataResourceFactory
All Implemented Interfaces:
MetadataResourceFactory

public class EXIFMetadataResourceFactory
extends java.lang.Object
implements MetadataResourceFactory

MetadataResourceFactory for EXIF metadata, eg. JPEG images.

This class manages finding camera-specific MetadataResource implementations for EXIF-based images based on a classpath Properties resource. This class will search in the following locations:

  1. smeta.properties
  2. META-INF/smeta.properties

The properties are searched until the first suitable key is found. The properties resource is loaded via the same ClassLoader that loaded this class, i.e. getClass().getClassLoader().getResource() is used. The properties file must have the format

smeta.camera.MAKE.MODEL = CLASS

where MAKE is an EXIF camera make (spaces removed), MODEL is an EXIF camera model (spaces removed), and CLASS is a fully-qualified class name that implements MetadataResource. The MetadataResource implementation must provide a constructor that takes a single Metadata object as a parameter, which will be invoked by this factory. The class will be loaded via the same ClassLoader that loaded this class, i.e. getClass().getClassLoader().loadClass() is used.

The MODEL may also be specified as a wildcard by using a * value. In this case, if a specific model match is not found, the wildcard value will be used.

An example of the property format looks like this:

smeta.camera.canon.canon20d=meta.image.camera.Canon20D
 smeta.camera.canon.canonpowershotg5=meta.image.camera.CanonG5
 smeta.camera.canon.*=meta.image.camera.Canon

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

Field Summary
static java.lang.String CAMERA_PROPERTY_KEY_PREFIX
          The prefix used for MetadataResource configuration properties.
static java.lang.String CUSTOM_CAMERA_PROPERTIES
          A custom class-path properties file.
static java.lang.String DEFAULT_CAMERA_PROPERTIES
          The default class-path properties file.
static java.lang.String MATCH_ANY_MODEL
          Special key for the makeModelMap to match any camera model.
 
Constructor Summary
EXIFMetadataResourceFactory()
          Default constructor.
 
Method Summary
protected  java.lang.String extractCameraMakeKey(com.drew.metadata.Metadata exif)
          Extract the camera make as a property key.
protected  java.lang.String extractCameraModelKey(com.drew.metadata.Metadata exif)
          Extract the cameral model as a property key.
protected  java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Class<? extends MetadataResource>>> getMakeModelMap()
           
 MetadataResource getMetadataResourceInstance(java.io.File file)
          Get a MetadataResource for a given file.
protected  void setMakeModelMap(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Class<? extends MetadataResource>>> makeModelMap)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CUSTOM_CAMERA_PROPERTIES

public static final java.lang.String CUSTOM_CAMERA_PROPERTIES
A custom class-path properties file.

See Also:
Constant Field Values

DEFAULT_CAMERA_PROPERTIES

public static final java.lang.String DEFAULT_CAMERA_PROPERTIES
The default class-path properties file.

See Also:
Constant Field Values

CAMERA_PROPERTY_KEY_PREFIX

public static final java.lang.String CAMERA_PROPERTY_KEY_PREFIX
The prefix used for MetadataResource configuration properties.

See Also:
Constant Field Values

MATCH_ANY_MODEL

public static final java.lang.String MATCH_ANY_MODEL
Special key for the makeModelMap to match any camera model.

See Also:
Constant Field Values
Constructor Detail

EXIFMetadataResourceFactory

public EXIFMetadataResourceFactory()
Default constructor.

Method Detail

getMetadataResourceInstance

public MetadataResource getMetadataResourceInstance(java.io.File file)
                                             throws java.io.IOException,
                                                    MetadataNotSupportedException
Description copied from interface: MetadataResourceFactory
Get a MetadataResource for a given file.

Specified by:
getMetadataResourceInstance in interface MetadataResourceFactory
Parameters:
file - the file
Returns:
the MetadataResource
Throws:
java.io.IOException - if an IO error occurs
MetadataNotSupportedException - if the file is not supported for any reason

extractCameraMakeKey

protected java.lang.String extractCameraMakeKey(com.drew.metadata.Metadata exif)
Extract the camera make as a property key.

Parameters:
exif - the Metadata to extract from
Returns:
camera make

extractCameraModelKey

protected java.lang.String extractCameraModelKey(com.drew.metadata.Metadata exif)
Extract the cameral model as a property key.

Parameters:
exif - the Metadata to extract from
Returns:
camera model

getMakeModelMap

protected java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Class<? extends MetadataResource>>> getMakeModelMap()
Returns:
the makeModelMap

setMakeModelMap

protected void setMakeModelMap(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Class<? extends MetadataResource>>> makeModelMap)
Parameters:
makeModelMap - the makeModelMap to set