info.aduna.lang.service
Class FileFormatServiceRegistry<FF extends FileFormat,S>

java.lang.Object
  extended by info.aduna.lang.service.ServiceRegistry<FF,S>
      extended by info.aduna.lang.service.FileFormatServiceRegistry<FF,S>

public abstract class FileFormatServiceRegistry<FF extends FileFormat,S>
extends ServiceRegistry<FF,S>

A special ServiceRegistry for FileFormat related services. This FileFormat-specific subclass offers some utility methods for matching MIME types and file extensions to the file formats of registered services.

Author:
Arjohn Kampman

Field Summary
 
Fields inherited from class info.aduna.lang.service.ServiceRegistry
logger, services
 
Constructor Summary
protected FileFormatServiceRegistry(Class<S> serviceClass)
           
 
Method Summary
 FF getFileFormatForFileName(String fileName)
          Tries to match the extension of a file name against the list of registred file formats.
 FF getFileFormatForFileName(String fileName, FF fallback)
          Tries to match the extension of a file name against the list of registred file formats.
 FF getFileFormatForMIMEType(String mimeType)
          Tries to match a MIME type against the list of registered file formats.
 FF getFileFormatForMIMEType(String mimeType, FF fallback)
          Tries to match a MIME type against the list of registred file formats.
 
Methods inherited from class info.aduna.lang.service.ServiceRegistry
add, get, getAll, getKey, getKeys, has, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileFormatServiceRegistry

protected FileFormatServiceRegistry(Class<S> serviceClass)
Method Detail

getFileFormatForMIMEType

public FF getFileFormatForMIMEType(String mimeType)
Tries to match a MIME type against the list of registered file formats.

Parameters:
mimeType - A MIME type, e.g. "text/plain".
Returns:
The matching Fileformat, or null if no match was found.
See Also:
getFileFormatForMIMEType(String, FileFormat)

getFileFormatForMIMEType

public FF getFileFormatForMIMEType(String mimeType,
                                   FF fallback)
Tries to match a MIME type against the list of registred file formats. This method calls FileFormat.matchMIMEType(String, Iterable, FileFormat) with the specified MIME type, the keys of this registry and the fallback format as parameters.

Parameters:
mimeType - A MIME type, e.g. "text/plain".
fallback - The format that will be returned if no match was found.
Returns:
The matching Fileformat, or fallback if no match was found.

getFileFormatForFileName

public FF getFileFormatForFileName(String fileName)
Tries to match the extension of a file name against the list of registred file formats.

Parameters:
fileName - A file name.
Returns:
The matching Fileformat, or null if no match was found.
See Also:
getFileFormatForFileName(String, FileFormat)

getFileFormatForFileName

public FF getFileFormatForFileName(String fileName,
                                   FF fallback)
Tries to match the extension of a file name against the list of registred file formats. This method calls FileFormat.matchFileName(String, Iterable, FileFormat) with the specified MIME type, the keys of this registry and the fallback format as parameters.

Parameters:
fileName - A file name.
fallback - The format that will be returned if no match was found.
Returns:
The matching Fileformat, or fallback if no match was found.


Copyright © 1997-2008 Aduna. All Rights Reserved.