org.restlet.engine.http.header

## Class HeaderWriter<V>

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

Type Parameters:
  `V` - The value type.

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

Direct Known Subclasses:
  CacheDirectiveWriter, ChallengeWriter, CookieSettingWriter, CookieWriter, DimensionWriter, DispositionWriter, ExpectationWriter, MetadataWriter, MethodWriter, PreferenceWriter, RangeWriter, RecipientInfoWriter, TagWriter, WarningWriter

    public abstract class HeaderWriter<V>
    extends java.io.StringWriter

HTTP-style header writer.

Author:
  Jerome Louvel

### Field Summary

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

`lock`

### Constructor Summary

Constructors
Constructor and Description
`HeaderWriter()`

### Method Summary

Methods
`HeaderWriter<V>` `append(char c)`
`HeaderWriter<V>` `append(char[] cs)` Appends an array of characters.
`HeaderWriter<V>` `append(java.lang.CharSequence csq)`
`HeaderWriter<V>` `append(java.util.Collection<V> values)` Appends a collection of values.
`HeaderWriter<V>` `append(int i)` Appends an integer.
`HeaderWriter<V>` `append(long l)` Appends a long.
`abstract HeaderWriter<V>` `append(V value)` Appends a value.
`HeaderWriter<V>` `appendComment(java.lang.String content)` Appends a string as an HTTP comment, surrounded by parenthesis and with quoted pairs if needed.
`HeaderWriter<V>` `appendExtension(Parameter extension)` Formats and appends a parameter as an extension.
`HeaderWriter<V>` `appendExtension(java.lang.String name, java.lang.String value)` Appends an extension.
`HeaderWriter<V>` `appendParameterSeparator()` Appends a semicolon as a parameter separator.
`HeaderWriter<V>` `appendProduct(java.lang.String name, java.lang.String version)` Appends a product description.
`HeaderWriter<V>` `appendQuotedPair(char character)` Appends a quoted character, prefixing it with a backslash.
`HeaderWriter<V>` `appendQuotedString(java.lang.String content)` Appends a quoted string.
`HeaderWriter<V>` `appendSpace()` Appends a space character.
`HeaderWriter<V>` `appendToken(java.lang.String token)` Appends a token.
`HeaderWriter<V>` `appendUriEncoded(java.lang.CharSequence source, CharacterSet characterSet)` Formats and appends a source string as an URI encoded string.
`HeaderWriter<V>` `appendValueSeparator()` Appends a comma as a value separator.
`protected boolean` `canWrite(V value)` Indicates if the value can be written to the header.

### 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

#### HeaderWriter

    public HeaderWriter()

### Method Detail

#### append

    public HeaderWriter<V> append(char c)

Specified by:
  `append` in interface `java.lang.Appendable`
Overrides:
  `append` in class `java.io.StringWriter`

#### append

    public HeaderWriter<V> append(char[] cs)

Appends an array of characters.

Parameters:
  `cs` - The array of characters.
Returns:
  This writer.

#### append

    public HeaderWriter<V> append(java.lang.CharSequence csq)

Specified by:
  `append` in interface `java.lang.Appendable`
Overrides:
  `append` in class `java.io.StringWriter`

#### append

    public HeaderWriter<V> append(java.util.Collection<V> values)

Appends a collection of values.

Parameters:
  `values` - The collection of values to append.
Returns:
  This writer.

#### append

    public HeaderWriter<V> append(int i)

Appends an integer.

Parameters:
  `i` - The value to append.
Returns:
  This writer.

#### append

    public HeaderWriter<V> append(long l)

Appends a long.

Parameters:
  `l` - The value to append.
Returns:
  This writer.

#### append

    public abstract HeaderWriter<V> append(V value)

Appends a value.

Parameters:
  `value` - The value.
Returns:
  This writer.

#### appendComment

    public HeaderWriter<V> appendComment(java.lang.String content)

Appends a string as an HTTP comment, surrounded by parenthesis and with quoted pairs if needed.

Parameters:
  `content` - The comment to write.
Returns:
  This writer.

#### appendExtension

    public HeaderWriter<V> appendExtension(Parameter extension)

Formats and appends a parameter as an extension. If the value is not a token, then it is quoted.

Parameters:
  `extension` - The parameter to format as an extension.
Returns:
  This writer.

#### appendExtension

    public HeaderWriter<V> appendExtension(java.lang.String name,
                                  java.lang.String value)

Appends an extension. If the value is not a token, then it is quoted.

Parameters:
  `name` - The extension name.
  `value` - The extension value.
Returns:
  This writer.

#### appendParameterSeparator

    public HeaderWriter<V> appendParameterSeparator()

Appends a semicolon as a parameter separator.

Returns:
  This writer.

#### appendProduct

    public HeaderWriter<V> appendProduct(java.lang.String name,
                                java.lang.String version)

Appends a product description.

Parameters:
  `name` - The product name token.
  `version` - The product version token.
Returns:
  This writer.

#### appendQuotedPair

    public HeaderWriter<V> appendQuotedPair(char character)

Appends a quoted character, prefixing it with a backslash.

Parameters:
  `character` - The character to quote.
Returns:
  This writer.

#### appendQuotedString

    public HeaderWriter<V> appendQuotedString(java.lang.String content)

Appends a quoted string.

Parameters:
  `content` - The string to quote and write.
Returns:
  This writer.

#### appendSpace

    public HeaderWriter<V> appendSpace()

Appends a space character.

Returns:
  This writer.

#### appendToken

    public HeaderWriter<V> appendToken(java.lang.String token)

Appends a token.

Parameters:
  `token` - The token to write.
Returns:
  This writer.

#### appendUriEncoded

    public HeaderWriter<V> appendUriEncoded(java.lang.CharSequence source,
                                   CharacterSet characterSet)

Formats and appends a source string as an URI encoded string.

Parameters:
  `source` - The source string to format.
  `characterSet` - The supported character encoding.
Returns:
  This writer.

#### appendValueSeparator

    public HeaderWriter<V> appendValueSeparator()

Appends a comma as a value separator.

Returns:
  This writer.

#### canWrite

    protected boolean canWrite(V value)

Indicates if the value can be written to the header. Useful to prevent the writing of `Encoding.IDENTITY` constants for example. By default it returns true for non null values.

Parameters:
  `value` - The value to add.
Returns:
  True if the value can be added.