Class w3c.mime.MIMEHeaders
All Packages Class Hierarchy This Package Previous Next Index
Class w3c.mime.MIMEHeaders
java.lang.Object
|
+----w3c.mime.MIMEHeaders
- public class MIMEHeaders
- extends Object
This class is used as a container for MIME header fields.
It works in conjunction with the MIMEParser object. For efficiency reasons,
it keeps all headers value unparsed, until they are explicitly requested.
When such a thing happen, the header value gets parse to its native type
and svaed as such. All other calls for this header value will result in
the already parsed value.
- See Also:
- MIMEParser
-
blength
-
-
headers
-
-
rheaders
-
-
MIMEHeaders(Hashtable, Hashtable)
- Create a new MIMEHeader instance.
-
defineField(String, Object)
-
Define a new field, with the given value.
-
dump()
- Dump all headers.
-
getField(String)
-
Get the raw value of a field.
-
getFieldAccept(String)
- Get the value of the accept header.
-
getFieldDate(String)
- Get the value of a Date field.
-
getFieldHashtable(String)
- Get the value of a field as a list.
-
getFieldInt(String)
- Get the value of an integer field.
-
getFieldLanguage(String)
- Get the value of some field as an array of languages.
-
getFieldList(String)
- Get the value of a list field.
-
getFieldMIMEType(String)
- Get the value of a MIMEType header.
-
getFieldObject(String)
-
Get the parsed value of a field.
-
getFieldString(String)
- Get the value of an string field.
-
hasField(String)
- Check if the given field has been defined for this request.
-
invalidFieldAccess(String, String)
-
-
parseDate(String)
-
-
parseInteger(String)
-
-
parseList(String, char)
-
rheaders
protected Hashtable rheaders
headers
protected Hashtable headers
blength
protected int blength
MIMEHeaders
public MIMEHeaders(Hashtable headers,
Hashtable rheaders)
- Create a new MIMEHeader instance.
The instance gets its parsed fields and its raw (unparsed) fields from
the two hashtables.
- Parameters:
- headers - Parsed header values, indexed by header names.
- rheaders - Unparsed header values, indexed by header names.
invalidFieldAccess
protected void invalidFieldAccess(String name,
String type) throws MIMEException
dump
public void dump()
- Dump all headers. Available for debug only.
hasField
public boolean hasField(String name)
- Check if the given field has been defined for this request.
- Parameters:
- eter - name A field name.
- Returns:
- A boolean true if the field exists.
defineField
public void defineField(String name,
Object value)
- Define a new field, with the given value. If the field already exists
its old value is lost.
- Parameters:
- eter - name The field name.
- eter - value The field value.
getField
public String getField(String name)
- Get the raw value of a field. Before being parsed into their proper
types, field values are stored as a String.
- Parameters:
- eter - name The field name.
- Returns:
- The String handling the value or null if this
header isn't defined.
getFieldObject
public Object getFieldObject(String name)
- Get the parsed value of a field. If the field has not yet been parsed
triggers an exception.
- Parameters:
- eter - name The field name.
- Returns:
- The field value, as an Object, or null if the
header isn't defined.
parseDate
protected Long parseDate(String string) throws MIMEException
parseInteger
protected Integer parseInteger(String string) throws MIMEException
parseList
protected String[] parseList(String string,
char sep) throws MIMEException
getFieldDate
public long getFieldDate(String name) throws MIMEException
- Get the value of a Date field.
- Parameters:
- eter - name field name.
- Returns:
- A long, giving the UTC parsed date
- Throws: MIMEException
- If the requested header isn't define, or if
the date couldn't be parsed.
- See Also:
- Date
getFieldList
public String[] getFieldList(String name) throws MIMEException
- Get the value of a list field.
List values are represented as an array of strings.
- Parameters:
- eter - name field name.
- Returns:
- An array of String, one per item.
- Throws: MIMEException
- If the requested header isn't define, or if the
list couldn't be parsed.
getFieldInt
public int getFieldInt(String name) throws MIMEException
- Get the value of an integer field.
- Parameters:
- eter - name field name.
- Returns:
- An array of Accept objects.
- Throws: MIMEException
- If the requested header isn't define, or if
the integer couldn't be parsed.
getFieldString
public String getFieldString(String name) throws MIMEException
- Get the value of an string field.
- Parameters:
- eter - name field name.
- Returns:
- An array of Accept objects.
- Throws: MIMEException
- If the requested header isn't define.
- See Also:
- String
getFieldAccept
public Accept[] getFieldAccept(String name) throws MIMEException
- Get the value of the accept header. The accept header is parsed as an
array of Accept objects (see negociator.Accept).
- Parameters:
- name - The name of the field to get.
- Returns:
- An Accept object.
- Throws: MIMEException
- If the field wasn't defined, or if the
header couldn't be parsed.
- See Also:
- Accept
getFieldMIMEType
public MIMEType getFieldMIMEType(String name) throws MIMEException
- Get the value of a MIMEType header.
The given header is parsed and an appropriate MIMEType is returned.
- Parameters:
- name - The name of the requested header.
- Returns:
- A MIMEType object.
- Throws: MIMEEXception
- If the requested header wasn't defined, of if
the field couldn't be parsed.
- See Also:
- MIMEType
getFieldLanguage
public Language[] getFieldLanguage(String name) throws MIMEException
- Get the value of some field as an array of languages.
- Parameters:
- name - The field's name.
- Returns:
- An array of language objects.
- Throws: MIMEException
- If the requested field wasn't defined, or if
field couldn't be parsed properly.
- See Also:
- Language
getFieldHashtable
public Hashtable getFieldHashtable(String name) throws MIMEException
- Get the value of a field as a list.
The list of keyword and optional value should be separated by a
;.
- Parameters:
- name - The field's name.
- Returns:
- A Hashtable containing the associations.
- Throws: MIMEParserException
- if the field couldn't be parsed.
- See Also:
- Hashtable
All Packages Class Hierarchy This Package Previous Next Index