org.restlet.engine.http.header

## Class PreferenceWriter

- java.lang.Object
- - java.io.Writer
  - - java.io.StringWriter
    - - org.restlet.engine.http.header.HeaderWriter<Preference<?>>
      - - org.restlet.engine.http.header.PreferenceWriter

All Implemented Interfaces:
  java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable

    public class PreferenceWriter
    extends HeaderWriter<Preference<?>>

Preference header writer.

Author:
  Jerome Louvel

### Field Summary

### Fields inherited from class java.io.Writer

`lock`

### Constructor Summary

Constructors
Constructor and Description
`PreferenceWriter()`

### Method Summary

Methods
`PreferenceWriter` `append(Preference<?> pref)` Appends a value.
`PreferenceWriter` `appendQuality(float quality)` Formats a quality value. If the quality is invalid, an IllegalArgumentException is thrown.
`static boolean` `isValidQuality(float quality)` Indicates if the quality value is valid.
`static java.lang.String` `write(java.util.List prefs)` Writes a list of preferences with a comma separator.

### Methods inherited from class org.restlet.engine.http.header.HeaderWriter

`append, append, append, append, append, append, appendComment, appendExtension, appendExtension, appendParameterSeparator, appendProduct, appendQuotedPair, appendQuotedString, appendSpace, appendToken, appendUriEncoded, appendValueSeparator, canWrite`

### Methods inherited from class java.io.StringWriter

`append, close, flush, getBuffer, toString, write, write, write, write`

### Methods inherited from class java.io.Writer

`write`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### PreferenceWriter

    public PreferenceWriter()

### Method Detail

#### isValidQuality

    public static boolean isValidQuality(float quality)

Indicates if the quality value is valid.

Parameters:
  `quality` - The quality value.
Returns:
  True if the quality value is valid.

#### write

    public static java.lang.String write(java.util.List prefs)

Writes a list of preferences with a comma separator.

Parameters:
  `prefs` - The list of preferences.
Returns:
  The formatted list of preferences.
Throws:
  `java.io.IOException`

#### append

    public PreferenceWriter append(Preference<?> pref)

Description copied from class: `HeaderWriter`
Appends a value.

Specified by:
  `append` in class `HeaderWriter<Preference<?>>`
Parameters:
  `pref` - The value.
Returns:
  This writer.

#### appendQuality

    public PreferenceWriter appendQuality(float quality)

Formats a quality value.
If the quality is invalid, an IllegalArgumentException is thrown.

Parameters:
  `quality` - The quality value as a float.
Returns:
  This writer.