Top Description Inners Fields Constructors Methods
org.mortbay.jetty

public Class HttpFields

extends Object
Class Inheritance
Imports
java.io.IOException, java.text.SimpleDateFormat, java.util.ArrayList, .Calendar, .Collections, .Date, .Enumeration, .GregorianCalendar, .HashMap, .Iterator, .List, .Locale, .Map, .NoSuchElementException, .StringTokenizer, .TimeZone, javax.servlet.http.Cookie, org.mortbay.io.Buffer, .BufferCache, .BufferDateCache, .BufferUtil, .ByteArrayBuffer, .View, .BufferCache.CachedBuffer, org.mortbay.util.LazyList, .QuotedStringTokenizer, .StringMap, .StringUtil, .URIUtil

HTTP Fields. A collection of HTTP header and or Trailer fields. This class is not synchronized and needs to be protected from concurrent access. This class is not synchronized as it is expected that modifications will only be performed by a single thread.
Author
Greg Wilkins (gregw)

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
public static final String
public static final Buffer
public static final BufferDateCache
private static SimpleDateFormat[]
private static final String[]
private static int
private static TimeZone
private static Float
private static StringMap
public static final String
private static Float
protected HashMap<K, V>
private Calendar
private StringBuffer
protected SimpleDateFormat[]
protected ArrayList<HttpFields.Field>
protected int
private static String[]
private static String[]

Constructor Summary

AccessConstructor and Description
public
HttpFields()

Constructor.

Method Summary

Modifier and TypeMethod and Description
public void
add(String
the name of the field
name
,
String
the value of the field.
value
)

Add to or set a field.

public void
add(Buffer
the name of the field
name
,
Buffer
the value of the field.
value
)

Add to or set a field.

private void
add(Buffer
the name of the field
name
,
Buffer
the value of the field.
value
,
long numValue)

Add to or set a field.

public void
add(HttpFields fields)

Add fields from another HttpFields instance.

public void
addDateField(String
the field name
name
,
long
the field date value
date
)

Sets the value of a date field.

public void
addLongField(String
the field name
name
,
long
the field long value
value
)

Sets the value of an long field.

public void
addLongField(Buffer
the field name
name
,
long
the field long value
value
)

Sets the value of an long field.

public void
addSetCookie(Cookie
The cookie.
cookie
)

Format a set cookie value

public void
clear()

Clear the header.

public boolean
public boolean
public void
destroy()

Destroy the header.

public static String
formatDate(long date, boolean cookie)

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

public static String
formatDate(Calendar calendar, boolean cookie)

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

public static String
formatDate(StringBuffer buf, long date, boolean cookie)

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

public static void
formatDate(StringBuffer buf, Calendar calendar, boolean cookie)

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

public Buffer

Returns:

the value of a field, or null if not found. For multiple fields of the same name, only the first is returned.
get
(Buffer
the case-insensitive field name
name
)

public long
getDateField(String
the case-insensitive field name
name
)

Get a header as a date value.

private HttpFields.Field
private HttpFields.Field
public Enumeration<E>
getFieldNames()

Get enumeration of header _names.

public Iterator<E>
getFields()

Get enumeration of Fields Returns an enumeration of Fields for this request.

public long
getLongField(String
the case-insensitive field name
name
)

Get a header as an long value.

public long
getLongField(Buffer
the case-insensitive field name
name
)

Get a header as an long value.

public static Float
public String

Returns:

the value of a field, or null if not found. For multiple fields of the same name, only the first is returned.
getStringField
(String
the case-insensitive field name
name
)

public String

Returns:

the value of a field, or null if not found. For multiple fields of the same name, only the first is returned.
getStringField
(Buffer
the case-insensitive field name
name
)

public Enumeration<E>

Returns:

Enumeration of the values, or null if no such header.
getValues
(String
the case-insensitive field name
name
)

Get multi headers

public Enumeration<E>

Returns:

Enumeration of the value Strings, or null if no such header.
getValues
(Buffer
the case-insensitive field name
name
)

Get multi headers

public Enumeration<E>

Returns:

Enumeration of the values, or null if no such header.
getValues
(String
the case-insensitive field name
name
,
final String
String of separators.
separators
)

Get multi field values with separator.

public void
put(String
the name of the field
name
,
String
the value of the field. If null the field is cleared.
value
)

Set a field.

public void
put(Buffer
the name of the field
name
,
String
the value of the field. If null the field is cleared.
value
)

Set a field.

public void
put(Buffer
the name of the field
name
,
Buffer
the value of the field. If null the field is cleared.
value
)

Set a field.

public void
put(Buffer
the name of the field
name
,
Buffer
the value of the field. If null the field is cleared.
value
,
long
the numeric value of the field (must match value) or -1
numValue
)

Set a field.

public void
put(String
the name of the field
name
,
List<E>
the List value of the field. If null the field is cleared.
list
)

Set a field.

public void
put(Buffer buffer)

public void
putDateField(Buffer
the field name
name
,
long
the field date value
date
)

Sets the value of a date field.

public void
putDateField(String
the field name
name
,
long
the field date value
date
)

Sets the value of a date field.

public void
putLongField(Buffer
the field name
name
,
long
the field long value
value
)

Sets the value of an long field.

public void
putLongField(String
the field name
name
,
long
the field long value
value
)

Sets the value of an long field.

public static List<E>

Returns:

values in quality order.
qualityList
(Enumeration<E>
Enumeration of values with quality parameters
e
)

List values in quality order.

public void
remove(String name)

Remove a field.

public void
remove(Buffer name)

Remove a field.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public static String

Returns:

The value.
valueParameters
(String
The Field value, possibly with parameteres.
value
,
Map<K, V>
A map to populate with the parameters, or null
parameters
)

Get field value parameters.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

__01Jan1970back to summary
public static final String __01Jan1970
__01Jan1970_BUFFERback to summary
public static final Buffer __01Jan1970_BUFFER
__dateCacheback to summary
public static final BufferDateCache __dateCache
__dateReceiveback to summary
private static SimpleDateFormat[] __dateReceive
__dateReceiveFmtback to summary
private static final String[] __dateReceiveFmt
__dateReceiveInitback to summary
private static int __dateReceiveInit
__GMTback to summary
private static TimeZone __GMT
__oneback to summary
private static Float __one
__qualitiesback to summary
private static StringMap __qualities
__separatorsback to summary
public static final String __separators
__zeroback to summary
private static Float __zero
_bufferMapback to summary
protected HashMap<K, V> _bufferMap
_calendarback to summary
private Calendar _calendar
_dateBufferback to summary
private StringBuffer _dateBuffer
_dateReceiveback to summary
protected SimpleDateFormat[] _dateReceive
_fieldsback to summary
protected ArrayList<HttpFields.Field> _fields
_revisionback to summary
protected int _revision
DAYSback to summary
private static String[] DAYS
MONTHSback to summary
private static String[] MONTHS

Constructor Detail

HttpFieldsback to summary
public HttpFields()

Constructor.

Method Detail

addback to summary
public void add(String name, String value) throws 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:String

the name of the field

value:String

the value of the field.

Exceptions
IllegalArgumentException:
If the name is a single valued field and already has a value.
addback to summary
public void add(Buffer name, Buffer value) throws 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:Buffer

the name of the field

value:Buffer

the value of the field.

Exceptions
IllegalArgumentException:
If the name is a single valued field and already has a value.
addback to summary
private void add(Buffer name, Buffer value, long numValue) throws 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:Buffer

the name of the field

value:Buffer

the value of the field.

Exceptions
IllegalArgumentException:
If the name is a single valued field and already has a value.
addback to summary
public void add(HttpFields fields)

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

addDateFieldback to summary
public void addDateField(String name, long date)

Sets the value of a date field.

Parameters
name:String

the field name

date:long

the field date value

addLongFieldback to summary
public void addLongField(String name, long value)

Sets the value of an long field.

Parameters
name:String

the field name

value:long

the field long value

addLongFieldback to summary
public void addLongField(Buffer name, long value)

Sets the value of an long field.

Parameters
name:Buffer

the field name

value:long

the field long value

addSetCookieback to summary
public void addSetCookie(Cookie cookie)

Format a set cookie value

Parameters
cookie:Cookie

The cookie.

clearback to summary
public void clear()

Clear the header.

containsKeyback to summary
public boolean containsKey(Buffer name)
containsKeyback to summary
public boolean containsKey(String name)
destroyback to summary
public void destroy()

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

formatDateback to summary
public static String formatDate(long date, boolean cookie)

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

formatDateback to summary
public static String formatDate(Calendar calendar, boolean cookie)

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

formatDateback to summary
public static String formatDate(StringBuffer buf, long date, boolean cookie)

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

formatDateback to summary
public static void formatDate(StringBuffer buf, Calendar calendar, boolean cookie)

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

getback to summary
public Buffer get(Buffer name)
Parameters
name:Buffer

the case-insensitive field name

Returns:Buffer

the value of a field, or null if not found. For multiple fields of the same name, only the first is returned.

getDateFieldback to summary
public long getDateField(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:String

the case-insensitive field name

getFieldback to summary
private HttpFields.Field getField(String name)
getFieldback to summary
private HttpFields.Field getField(Buffer name)
getFieldNamesback to summary
public Enumeration<E> getFieldNames()

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

getFieldsback to summary
public Iterator<E> getFields()

Get enumeration of Fields Returns an enumeration of Fields for this request.

getLongFieldback to summary
public long getLongField(String name) throws 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:String

the case-insensitive field name

Exceptions
NumberFormatException:
If bad long found
getLongFieldback to summary
public long getLongField(Buffer name) throws 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:Buffer

the case-insensitive field name

Exceptions
NumberFormatException:
If bad long found
getQualityback to summary
public static Float getQuality(String value)
getStringFieldback to summary
public String getStringField(String name)
Parameters
name:String

the case-insensitive field name

Returns:String

the value of a field, or null if not found. For multiple fields of the same name, only the first is returned.

getStringFieldback to summary
public String getStringField(Buffer name)
Parameters
name:Buffer

the case-insensitive field name

Returns:String

the value of a field, or null if not found. For multiple fields of the same name, only the first is returned.

getValuesback to summary
public Enumeration<E> getValues(String name)

Get multi headers

Parameters
name:String

the case-insensitive field name

Returns:Enumeration<E>

Enumeration of the values, or null if no such header.

getValuesback to summary
public Enumeration<E> getValues(Buffer name)

Get multi headers

Parameters
name:Buffer

the case-insensitive field name

Returns:Enumeration<E>

Enumeration of the value Strings, or null if no such header.

getValuesback to summary
public Enumeration<E> getValues(String name, final 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:String

the case-insensitive field name

separators:String

String of separators.

Returns:Enumeration<E>

Enumeration of the values, or null if no such header.

putback to summary
public void put(String name, String value)

Set a field.

Parameters
name:String

the name of the field

value:String

the value of the field. If null the field is cleared.

putback to summary
public void put(Buffer name, String value)

Set a field.

Parameters
name:Buffer

the name of the field

value:String

the value of the field. If null the field is cleared.

putback to summary
public void put(Buffer name, Buffer value)

Set a field.

Parameters
name:Buffer

the name of the field

value:Buffer

the value of the field. If null the field is cleared.

putback to summary
public void put(Buffer name, Buffer value, long numValue)

Set a field.

Parameters
name:Buffer

the name of the field

value:Buffer

the value of the field. If null the field is cleared.

numValue:long

the numeric value of the field (must match value) or -1

putback to summary
public void put(String name, List<E> list)

Set a field.

Parameters
name:String

the name of the field

list:List<E>

the List value of the field. If null the field is cleared.

putback to summary
public void put(Buffer buffer) throws IOException
putDateFieldback to summary
public void putDateField(Buffer name, long date)

Sets the value of a date field.

Parameters
name:Buffer

the field name

date:long

the field date value

putDateFieldback to summary
public void putDateField(String name, long date)

Sets the value of a date field.

Parameters
name:String

the field name

date:long

the field date value

putLongFieldback to summary
public void putLongField(Buffer name, long value)

Sets the value of an long field.

Parameters
name:Buffer

the field name

value:long

the field long value

putLongFieldback to summary
public void putLongField(String name, long value)

Sets the value of an long field.

Parameters
name:String

the field name

value:long

the field long value

qualityListback to summary
public static List<E> qualityList(Enumeration<E> e)

List values in quality order.

Parameters
e:Enumeration<E>

Enumeration of values with quality parameters

Returns:List<E>

values in quality order.

removeback to summary
public void remove(String name)

Remove a field.

removeback to summary
public void remove(Buffer name)

Remove a field.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

valueParametersback to summary
public static String valueParameters(String value, Map<K, V> 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 paramters. For example:


FieldName : Value ; param1=val1 ; param2=val2

Parameters
value:String

The Field value, possibly with parameteres.

parameters:Map<K, V>

A map to populate with the parameters, or null

Returns:String

The value.

org.mortbay.jetty back to summary

public final Class HttpFields.Field

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private Buffer
private HttpFields.Field
private long
private HttpFields.Field
private int
private String
private Buffer

Constructor Summary

AccessConstructor and Description
private
Field(Buffer name, Buffer value, long numValue, int revision)

Method Summary

Modifier and TypeMethod and Description
private void
private void
public int
public long
public String
pack-priv Buffer
public int
public String
public Buffer
public int
public void
put(Buffer buffer)

private void
reset(Buffer value, long numValue, int revision)

Reassign a value to this field.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_nameback to summary
private Buffer _name
_nextback to summary
private HttpFields.Field _next
_numValueback to summary
private long _numValue
_prevback to summary
private HttpFields.Field _prev
_revisionback to summary
private int _revision
_stringValueback to summary
private String _stringValue
_valueback to summary
private Buffer _value

Constructor Detail

Fieldback to summary
private Field(Buffer name, Buffer value, long numValue, int revision)

Method Detail

clearback to summary
private void clear()
destroyback to summary
private void destroy()
getIntValueback to summary
public int getIntValue()
getLongValueback to summary
public long getLongValue()
getNameback to summary
public String getName()
getNameBufferback to summary
pack-priv Buffer getNameBuffer()
getNameOrdinalback to summary
public int getNameOrdinal()
getValueback to summary
public String getValue()
getValueBufferback to summary
public Buffer getValueBuffer()
getValueOrdinalback to summary
public int getValueOrdinal()
putback to summary
public void put(Buffer buffer) throws IOException
resetback to summary
private void reset(Buffer value, long numValue, int revision)

Reassign a value to this field. Checks if the string value is the same as that in the char array, if so then just reuse existing value.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.