org.restlet.service
Class MetadataService

java.lang.Object
  extended by org.restlet.service.Service
      extended by org.restlet.service.MetadataService

public class MetadataService
extends Service

Service providing access to metadata and their associated extension names.

Author:
Jerome Louvel

Constructor Summary
MetadataService()
          Constructor.
 
Method Summary
 void addCommonExtensions()
          Adds a common list of associations from extensions to metadata.
 void addExtension(java.lang.String extension, Metadata metadata)
          Maps an extension to some metadata (media type, language or character set) to an extension.
 void addExtension(java.lang.String extension, Metadata metadata, boolean preferred)
          Maps an extension to some metadata (media type, language or character set) to an extension.
 void clearExtensions()
          clears the mappings for all extensions.
 Encoding getDefaultEncoding()
          Returns the default encoding for local representations.
 Language getDefaultLanguage()
          Returns the default language for local representations.
 MediaType getDefaultMediaType()
          Returns the default media type for local representations.
 java.lang.String getExtension(Metadata metadata)
          Returns the first extension mapping to this metadata.
 java.util.Map<java.lang.String,Metadata> getMappings()
          Deprecated. .
 Metadata getMetadata(java.lang.String extension)
          Returns the metadata associated to this extension.
 void setDefaultEncoding(Encoding defaultEncoding)
          Sets the default encoding for local representations.
 void setDefaultLanguage(Language defaultLanguage)
          Sets the default language for local representations.
 void setDefaultMediaType(MediaType defaultMediaType)
          Sets the default media type for local representations.
 void setMappings(java.util.Map<java.lang.String,Metadata> mappings)
          Deprecated.  
 
Methods inherited from class org.restlet.service.Service
isEnabled, isStarted, isStopped, setEnabled, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetadataService

public MetadataService()
Constructor. Sets the default language to Language.ENGLISH_US, the default encoding to Encoding.IDENTITY (no encoding) and the default media type to MediaType.APPLICATION_OCTET_STREAM. It also calls the addCommonExtensions() method.

Method Detail

addCommonExtensions

public void addCommonExtensions()
Adds a common list of associations from extensions to metadata. The list of languages extensions:

The list of media type extensions:


addExtension

public void addExtension(java.lang.String extension,
                         Metadata metadata)
Maps an extension to some metadata (media type, language or character set) to an extension.

Parameters:
extension - The extension name.
metadata - The metadata to map.

addExtension

public void addExtension(java.lang.String extension,
                         Metadata metadata,
                         boolean preferred)
Maps an extension to some metadata (media type, language or character set) to an extension.

Parameters:
extension - The extension name.
metadata - The metadata to map.
preferred - indicates if this mapping is the preferred one.

clearExtensions

public void clearExtensions()
clears the mappings for all extensions.


getDefaultEncoding

public Encoding getDefaultEncoding()
Returns the default encoding for local representations.

Returns:
The default encoding for local representations.

getDefaultLanguage

public Language getDefaultLanguage()
Returns the default language for local representations.

Returns:
The default language for local representations.

getDefaultMediaType

public MediaType getDefaultMediaType()
Returns the default media type for local representations.

Returns:
The default media type for local representations.

getExtension

public java.lang.String getExtension(Metadata metadata)
Returns the first extension mapping to this metadata.

Parameters:
metadata - The metadata to find.
Returns:
The first extension mapping to this metadata.

getMappings

@Deprecated
public java.util.Map<java.lang.String,Metadata> getMappings()
Deprecated. .

Returns the mappings from extension names to metadata. Creates a new instance if no one has been set. Note that this map is only a snapshot of the list of mappings.

Returns:
The mappings from extension names to metadata.

getMetadata

public Metadata getMetadata(java.lang.String extension)
Returns the metadata associated to this extension. It returns null if the extension was not declared.

Parameters:
extension - The extension name without any delimiter.
Returns:
The metadata associated to this extension.

setDefaultEncoding

public void setDefaultEncoding(Encoding defaultEncoding)
Sets the default encoding for local representations.

Parameters:
defaultEncoding - The default encoding for local representations.

setDefaultLanguage

public void setDefaultLanguage(Language defaultLanguage)
Sets the default language for local representations.

Parameters:
defaultLanguage - The default language for local representations.

setDefaultMediaType

public void setDefaultMediaType(MediaType defaultMediaType)
Sets the default media type for local representations.

Parameters:
defaultMediaType - The default media type for local representations.

setMappings

@Deprecated
public void setMappings(java.util.Map<java.lang.String,Metadata> mappings)
Deprecated. 

Sets the mappings from extension names to metadata.

Parameters:
mappings - The mappings from extension names to metadata.


Copyright © 2005-2008 Noelios Technologies.