org.restlet.engine.application
Class StrictConneg

java.lang.Object
  extended by org.restlet.engine.application.Conneg
      extended by org.restlet.engine.application.StrictConneg
Direct Known Subclasses:
FlexibleConneg

public class StrictConneg
extends Conneg

Content negotiation algorithm that strictly interprets the content negotiation preferences.

Author:
Jerome Louvel

Constructor Summary
StrictConneg(Request request, MetadataService metadataService)
          Constructor.
 
Method Summary
protected  List<Preference<CharacterSet>> getCharacterSetPrefs()
          Returns the enriched list of character set preferences.
protected  List<Preference<Encoding>> getEncodingPrefs()
          Returns the enriched list of encoding preferences.
protected  List<Preference<Language>> getLanguagePrefs()
          Returns the enriched list of language preferences.
protected  List<Preference<MediaType>> getMediaTypePrefs()
          Returns the enriched list of media type preferences.
protected  float scoreAnnotation(AnnotationInfo annotation)
          Scores the annotation descriptor.
 float scoreCharacterSet(CharacterSet characterSet)
          Scores a character set relatively to enriched client preferences.
 float scoreEncodings(List<Encoding> encodings)
          Scores encodings relatively to enriched client preferences.
 float scoreLanguages(List<Language> languages)
          Scores languages relatively to enriched client preferences.
 float scoreMediaType(MediaType mediaType)
          Scores a media type relatively to enriched client preferences.
protected
<T extends Metadata>
float
scoreMetadata(List<T> metadataList, List<Preference<T>> prefs)
          Scores a list of metadata relatively to enriched client preferences.
protected
<T extends Metadata>
float
scoreMetadata(T metadata, List<Preference<T>> prefs)
          Scores a metadata relatively to enriched client preferences.
 float scoreVariant(Variant variant)
          Scores a variant relatively to enriched client preferences.
 
Methods inherited from class org.restlet.engine.application.Conneg
getPreferredVariant, getRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StrictConneg

public StrictConneg(Request request,
                    MetadataService metadataService)
Constructor.

Parameters:
request - The request including client preferences.
metadataService - The metadata service used to get default metadata values.
Method Detail

getCharacterSetPrefs

protected List<Preference<CharacterSet>> getCharacterSetPrefs()
Returns the enriched list of character set preferences.

Returns:
The enriched list of character set preferences.

getEncodingPrefs

protected List<Preference<Encoding>> getEncodingPrefs()
Returns the enriched list of encoding preferences.

Returns:
The enriched list of encoding preferences.

getLanguagePrefs

protected List<Preference<Language>> getLanguagePrefs()
Returns the enriched list of language preferences.

Returns:
The enriched list of language preferences.

getMediaTypePrefs

protected List<Preference<MediaType>> getMediaTypePrefs()
Returns the enriched list of media type preferences.

Returns:
The enriched list of media type preferences.

scoreAnnotation

protected float scoreAnnotation(AnnotationInfo annotation)
Scores the annotation descriptor. By default, it assess the quality of the query parameters with the URI query constraint defined in the annotation value if any.

Parameters:
annotation - The annotation descriptor to score.
Returns:
The annotation descriptor score.

scoreCharacterSet

public float scoreCharacterSet(CharacterSet characterSet)
Scores a character set relatively to enriched client preferences.

Parameters:
characterSet - The character set to score.
Returns:
The score.

scoreEncodings

public float scoreEncodings(List<Encoding> encodings)
Scores encodings relatively to enriched client preferences.

Parameters:
encodings - The encodings to score.
Returns:
The score.

scoreLanguages

public float scoreLanguages(List<Language> languages)
Scores languages relatively to enriched client preferences.

Parameters:
languages - The languages to score.
Returns:
The score.

scoreMediaType

public float scoreMediaType(MediaType mediaType)
Scores a media type relatively to enriched client preferences.

Parameters:
mediaType - The media type to score.
Returns:
The score.

scoreMetadata

protected <T extends Metadata> float scoreMetadata(List<T> metadataList,
                                                   List<Preference<T>> prefs)
Scores a list of metadata relatively to enriched client preferences.

Parameters:
metadataList - The list of metadata to score.
Returns:
The score.

scoreMetadata

protected <T extends Metadata> float scoreMetadata(T metadata,
                                                   List<Preference<T>> prefs)
Scores a metadata relatively to enriched client preferences.

Parameters:
metadata - The metadata to score.
Returns:
The score.

scoreVariant

public float scoreVariant(Variant variant)
Scores a variant relatively to enriched client preferences. The language has a weight of 4, the media type 3, the character set 2 and the encoding 1.

Specified by:
scoreVariant in class Conneg
Parameters:
variant - The variant to score.
Returns:
The enriched client preferences.


Copyright © 2005-2013 Restlet.