Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.jetty.http
Class HttpFields

    java.lang.Object
      org.eclipse.jetty.http.HttpFields

    public class HttpFields

extends java.lang.Object

HTTP Fields. A collection of HTTP header and or Trailer fields.

This class is not synchronized as it is expected that modifications will only be performed by a single thread.

Nested Class Summary
`static class` | `HttpFields.Field`

Field Summary
`static java.lang.String` | `__01Jan1970`
`static Buffer` | `__01Jan1970_BUFFER`
`static BufferDateCache` | `__dateCache`
`static java.util.TimeZone` | `__GMT`
`static java.lang.String` | `__separators`

Constructor Summary
`HttpFields()` Constructor.
`HttpFields(int maxCookieVersion)` Constructor.

Method Summary
`void` | `add(Buffer name, Buffer value)` Add to or set a field.
`void` | `add(HttpFields fields)` Add fields from another HttpFields instance.
`void` | `add(java.lang.String name, java.lang.String value)` Add to or set a field.
`void` | `addDateField(java.lang.String name, long date)` Sets the value of a date field.
`void` | `addLongField(Buffer name, long value)` Sets the value of an long field.
`void` | `addLongField(java.lang.String name, long value)` Sets the value of an long field.
`void` | `addSetCookie(HttpCookie cookie)` Format a set cookie value
`void` | `addSetCookie(java.lang.String name, java.lang.String value, java.lang.String domain, java.lang.String path, long maxAge, java.lang.String comment, boolean isSecure, boolean isHttpOnly, int version)` Format a set cookie value
`void` | `clear()` Clear the header.
`boolean` | `containsKey(Buffer name)`
`boolean` | `containsKey(java.lang.String name)`
`void` | `destroy()` Destroy the header.
`static java.lang.String` | `formatCookieDate(long date)` Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies
`static void` | `formatCookieDate(java.lang.StringBuilder buf, long date)` Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies
`static java.lang.String` | `formatDate(long date)` Format HTTP date "EEE, dd MMM yyyy HH:mm:ss 'GMT'" cookies
`Buffer` | `get(Buffer name)`
`long` | `getDateField(java.lang.String name)` Get a header as a date value.
`HttpFields.Field` | `getField(int i)` Get a Field by index.
`java.util.Enumeration<java.lang.String>` | `getFieldNames()` Get enumeration of header _names.
`java.util.Collection<java.lang.String>` | `getFieldNamesCollection()` Get Collection of header names.
`long` | `getLongField(Buffer name)` Get a header as an long value.
`long` | `getLongField(java.lang.String name)` Get a header as an long value.
`static java.lang.Float` | `getQuality(java.lang.String value)`
`java.lang.String` | `getStringField(Buffer name)`
`java.lang.String` | `getStringField(java.lang.String name)`
`java.util.Enumeration<java.lang.String>` | `getValues(Buffer name)` Get multi headers
`java.util.Enumeration<java.lang.String>` | `getValues(java.lang.String name)` Get multi headers
`java.util.Enumeration<java.lang.String>` | `getValues(java.lang.String name, java.lang.String separators)` Get multi field values with separator.
`java.util.Collection<java.lang.String>` | `getValuesCollection(java.lang.String name)` Get multi headers
`static long` | `parseDate(java.lang.String date)`
`void` | `put(Buffer buffer)`
`void` | `put(Buffer name, Buffer value)` Set a field.
`void` | `put(Buffer name, Buffer value, long numValue)` Set a field.
`void` | `put(Buffer name, java.lang.String value)` Set a field.
`void` | `put(java.lang.String name, java.util.List<?> list)` Set a field.
`void` | `put(java.lang.String name, java.lang.String value)` Set a field.
`void` | `putDateField(Buffer name, long date)` Sets the value of a date field.
`void` | `putDateField(java.lang.String name, long date)` Sets the value of a date field.
`void` | `putLongField(Buffer name, long value)` Sets the value of an long field.
`void` | `putLongField(java.lang.String name, long value)` Sets the value of an long field.
`static java.util.List` | `qualityList(java.util.Enumeration e)` List values in quality order.
`void` | `remove(Buffer name)` Remove a field.
`void` | `remove(java.lang.String name)` Remove a field.
`int` | `size()`
`java.lang.String` | `toString()`
`static java.lang.String` | `valueParameters(java.lang.String value, java.util.Map<java.lang.String,java.lang.String> parameters)` Get field value parameters.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### __GMT

    public static final java.util.TimeZone __GMT

### __dateCache

    public static final BufferDateCache __dateCache

### __separators

    public static final java.lang.String __separators

See Also:
  Constant Field Values

### __01Jan1970

    public static final java.lang.String __01Jan1970

### __01Jan1970_BUFFER

    public static final Buffer __01Jan1970_BUFFER

Constructor Detail

### HttpFields

    public HttpFields()

  Constructor.

### HttpFields

    public HttpFields(int maxCookieVersion)

  Constructor.

Method Detail

### formatDate

    public static java.lang.String formatDate(long date)

  Format HTTP date "EEE, dd MMM yyyy HH:mm:ss 'GMT'" cookies

### formatCookieDate

    public static void formatCookieDate(java.lang.StringBuilder buf,
                                        long date)

  Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies

### formatCookieDate

    public static java.lang.String formatCookieDate(long date)

  Format "EEE, dd-MMM-yyyy HH:mm:ss 'GMT'" for cookies

### parseDate

    public static long parseDate(java.lang.String date)

### getFieldNamesCollection

    public java.util.Collection<java.lang.String> getFieldNamesCollection()

  Get Collection of header names.

### getFieldNames

    public java.util.Enumeration<java.lang.String> getFieldNames()

  Get enumeration of header _names. Returns an enumeration of strings representing the header _names for this request.

### size

    public int size()

### getField

    public HttpFields.Field getField(int i)

  Get a Field by index.

  Returns:
    A Field value or null if the Field value has not been set for this revision of the fields.

### containsKey

    public boolean containsKey(Buffer name)

### containsKey

    public boolean containsKey(java.lang.String name)

### getStringField

    public java.lang.String getStringField(java.lang.String name)

  Parameters:
    `name` - the case-insensitive field name
  Returns:
    the value of a field, or null if not found. For multiple fields of the same name, only the first is returned.

### getStringField

    public java.lang.String getStringField(Buffer name)

  Parameters:
    `name` - the case-insensitive field name
  Returns:
    the value of a field, or null if not found. For multiple fields of the same name, only the first is returned.

### get

    public Buffer get(Buffer name)

  Parameters:
    `name` - the case-insensitive field name
  Returns:
    the value of a field, or null if not found. For multiple fields of the same name, only the first is returned.

### getValuesCollection

    public java.util.Collection<java.lang.String> getValuesCollection(java.lang.String name)

  Get multi headers

  Parameters:
    `name` - the case-insensitive field name
  Returns:
    Enumeration of the values, or null if no such header.

### getValues

    public java.util.Enumeration<java.lang.String> getValues(java.lang.String name)

  Get multi headers

  Parameters:
    `name` - the case-insensitive field name
  Returns:
    Enumeration of the values, or null if no such header.

### getValues

    public java.util.Enumeration<java.lang.String> getValues(Buffer name)

  Get multi headers

  Parameters:
    `name` - the case-insensitive field name
  Returns:
    Enumeration of the value Strings, or null if no such header.

### getValues

    public java.util.Enumeration<java.lang.String> getValues(java.lang.String name,
                                                             java.lang.String separators)

  Get multi field values with separator. The multiple values can be represented as separate headers of the same name, or by a single header using the separator(s), or a combination of both. Separators may be quoted.

  Parameters:
    `name` - the case-insensitive field name
    `separators` - String of separators.
  Returns:
    Enumeration of the values, or null if no such header.

### put

    public void put(java.lang.String name,
                    java.lang.String value)

  Set a field.

  Parameters:
    `name` - the name of the field
    `value` - the value of the field. If null the field is cleared.

### put

    public void put(Buffer name,
                    java.lang.String value)

  Set a field.

  Parameters:
    `name` - the name of the field
    `value` - the value of the field. If null the field is cleared.

### put

    public void put(Buffer name,
                    Buffer value)

  Set a field.

  Parameters:
    `name` - the name of the field
    `value` - the value of the field. If null the field is cleared.

### put

    public void put(Buffer name,
                    Buffer value,
                    long numValue)

  Set a field.

  Parameters:
    `name` - the name of the field
    `value` - the value of the field. If null the field is cleared.
    `numValue` - the numeric value of the field (must match value) or -1

### put

    public void put(java.lang.String name,
                    java.util.List<?> list)

  Set a field.

  Parameters:
    `name` - the name of the field
    `list` - the List value of the field. If null the field is cleared.

### add

    public void add(java.lang.String name,
                    java.lang.String value)
             throws java.lang.IllegalArgumentException

  Add to or set a field. If the field is allowed to have multiple values, add will add multiple headers of the same name.

  Parameters:
    `name` - the name of the field
    `value` - the value of the field.
  Throws:
    `java.lang.IllegalArgumentException` - If the name is a single valued field and already has a value.

### add

    public void add(Buffer name,
                    Buffer value)
             throws java.lang.IllegalArgumentException

  Add to or set a field. If the field is allowed to have multiple values, add will add multiple headers of the same name.

  Parameters:
    `name` - the name of the field
    `value` - the value of the field.
  Throws:
    `java.lang.IllegalArgumentException` - If the name is a single valued field and already has a value.

### remove

    public void remove(java.lang.String name)

  Remove a field.

  Parameters:
    `name` -

### remove

    public void remove(Buffer name)

  Remove a field.

  Parameters:
    `name` -

### getLongField

    public long getLongField(java.lang.String name)
                      throws java.lang.NumberFormatException

  Get a header as an long value. Returns the value of an integer field or -1 if not found. The case of the field name is ignored.

  Parameters:
    `name` - the case-insensitive field name
  Throws:
    `java.lang.NumberFormatException` - If bad long found

### getLongField

    public long getLongField(Buffer name)
                      throws java.lang.NumberFormatException

  Get a header as an long value. Returns the value of an integer field or -1 if not found. The case of the field name is ignored.

  Parameters:
    `name` - the case-insensitive field name
  Throws:
    `java.lang.NumberFormatException` - If bad long found

### getDateField

    public long getDateField(java.lang.String name)

  Get a header as a date value. Returns the value of a date field, or -1 if not found. The case of the field name is ignored.

  Parameters:
    `name` - the case-insensitive field name

### putLongField

    public void putLongField(Buffer name,
                             long value)

  Sets the value of an long field.

  Parameters:
    `name` - the field name
    `value` - the field long value

### putLongField

    public void putLongField(java.lang.String name,
                             long value)

  Sets the value of an long field.

  Parameters:
    `name` - the field name
    `value` - the field long value

### addLongField

    public void addLongField(java.lang.String name,
                             long value)

  Sets the value of an long field.

  Parameters:
    `name` - the field name
    `value` - the field long value

### addLongField

    public void addLongField(Buffer name,
                             long value)

  Sets the value of an long field.

  Parameters:
    `name` - the field name
    `value` - the field long value

### putDateField

    public void putDateField(Buffer name,
                             long date)

  Sets the value of a date field.

  Parameters:
    `name` - the field name
    `date` - the field date value

### putDateField

    public void putDateField(java.lang.String name,
                             long date)

  Sets the value of a date field.

  Parameters:
    `name` - the field name
    `date` - the field date value

### addDateField

    public void addDateField(java.lang.String name,
                             long date)

  Sets the value of a date field.

  Parameters:
    `name` - the field name
    `date` - the field date value

### addSetCookie

    public void addSetCookie(HttpCookie cookie)

  Format a set cookie value

  Parameters:
    `cookie` - The cookie.

### addSetCookie

    public void addSetCookie(java.lang.String name,
                             java.lang.String value,
                             java.lang.String domain,
                             java.lang.String path,
                             long maxAge,
                             java.lang.String comment,
                             boolean isSecure,
                             boolean isHttpOnly,
                             int version)

  Format a set cookie value

  Parameters:
    `name` - the name
    `value` - the value
    `domain` - the domain
    `path` - the path
    `maxAge` - the maximum age
    `comment` - the comment (only present on versions > 0)
    `isSecure` - true if secure cookie
    `isHttpOnly` - true if for http only
    `version` - version of cookie logic to use (0 == default behavior)

### put

    public void put(Buffer buffer)
             throws java.io.IOException

  Throws:
    `java.io.IOException`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

### clear

    public void clear()

  Clear the header.

### destroy

    public void destroy()

  Destroy the header. Help the garbage collector by null everything that we can.

### add

    public void add(HttpFields fields)

  Add fields from another HttpFields instance. Single valued fields are replaced, while all others are added.

  Parameters:
    `fields` -

### valueParameters

    public static java.lang.String valueParameters(java.lang.String value,
                                                   java.util.Map<java.lang.String,java.lang.String> parameters)

  Get field value parameters. Some field values can have parameters. This method separates the value from the parameters and optionally populates a map with the parameters. For example:

       FieldName : Value ; param1=val1 ; param2=val2

  Parameters:
    `value` - The Field value, possibly with parameteres.
    `parameters` - A map to populate with the parameters, or null
  Returns:
    The value.

### getQuality

    public static java.lang.Float getQuality(java.lang.String value)

### qualityList

    public static java.util.List qualityList(java.util.Enumeration e)

  List values in quality order.

  Parameters:
    `e` - Enumeration of values with quality parameters
  Returns:
    values in quality order.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1995-2010 Mort Bay Consulting. All Rights Reserved.