com.noelios.restlet.http
Class PreferenceReader<T extends Metadata>

java.lang.Object
  extended by com.noelios.restlet.http.HeaderReader
      extended by com.noelios.restlet.http.PreferenceReader<T>

public class PreferenceReader<T extends Metadata>
extends HeaderReader

Preference header reader. Works for character sets, encodings, languages or media types.

Author:
Jerome Louvel

Field Summary
static int TYPE_CHARACTER_SET
           
static int TYPE_ENCODING
           
static int TYPE_LANGUAGE
           
static int TYPE_MEDIA_TYPE
           
 
Constructor Summary
PreferenceReader(int type, java.lang.String header)
          Constructor.
 
Method Summary
protected  Preference<T> createPreference(java.lang.CharSequence metadata, Series<Parameter> parameters)
          Creates a new preference.
protected  Series<Parameter> extractMediaParams(Series<Parameter> parameters)
          Extract the media parameters.
protected  float extractQuality(Series<Parameter> parameters)
          Extract the quality value.
 Preference<T> readPreference()
          Read the next preference.
 
Methods inherited from class com.noelios.restlet.http.HeaderReader
appendQuotedString, isLinearWhiteSpace, isValueSeparator, read, readQuotedString, readValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_CHARACTER_SET

public static final int TYPE_CHARACTER_SET
See Also:
Constant Field Values

TYPE_ENCODING

public static final int TYPE_ENCODING
See Also:
Constant Field Values

TYPE_LANGUAGE

public static final int TYPE_LANGUAGE
See Also:
Constant Field Values

TYPE_MEDIA_TYPE

public static final int TYPE_MEDIA_TYPE
See Also:
Constant Field Values
Constructor Detail

PreferenceReader

public PreferenceReader(int type,
                        java.lang.String header)
Constructor.

Parameters:
type - The type of metadata read.
header - The header to read.
Method Detail

createPreference

protected Preference<T> createPreference(java.lang.CharSequence metadata,
                                         Series<Parameter> parameters)
Creates a new preference.

Parameters:
metadata - The metadata name.
parameters - The parameters list.
Returns:
The new preference.

extractMediaParams

protected Series<Parameter> extractMediaParams(Series<Parameter> parameters)
Extract the media parameters. Only leave as the quality parameter if found. Modifies the parameters list.

Parameters:
parameters - All the preference parameters.
Returns:
The media parameters.

extractQuality

protected float extractQuality(Series<Parameter> parameters)
Extract the quality value. If the value is not found, 1 is returned.

Parameters:
parameters - The preference parameters.
Returns:
The quality value.

readPreference

public Preference<T> readPreference()
                                              throws java.io.IOException
Read the next preference.

Returns:
The next preference.
Throws:
java.io.IOException


Copyright © 2005-2008 Noelios Technologies.