Class HeaderWriter<V>

java.lang.Object
java.io.Writer
java.io.StringWriter
org.restlet.engine.header.HeaderWriter<V>
Type Parameters:
V - The value type.
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable
Direct Known Subclasses:
CacheDirectiveWriter, ChallengeWriter, CookieSettingWriter, CookieWriter, DimensionWriter, DispositionWriter, ExpectationWriter, MetadataWriter, MethodWriter, PreferenceWriter, RangeWriter, RecipientInfoWriter, StringWriter, TagWriter, WarningWriter

public abstract class HeaderWriter<V> extends StringWriter
HTTP-style header writer.
Author:
Jerome Louvel
  • Constructor Details

    • HeaderWriter

      public HeaderWriter()
  • Method Details

    • append

      public HeaderWriter<V> append(char c)
      Specified by:
      append in interface Appendable
      Overrides:
      append in class 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(CharSequence csq)
      Specified by:
      append in interface Appendable
      Overrides:
      append in class StringWriter
    • append

      public HeaderWriter<V> append(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(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(NamedValue<String> 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(String name, 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(String name, 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(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(String token)
      Appends a token.
      Parameters:
      token - The token to write.
      Returns:
      This writer.
    • appendUriEncoded

      public HeaderWriter<V> appendUriEncoded(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.