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

Variable Index

 o blength
 o headers
 o rheaders

Constructor Index

 o MIMEHeaders(Hashtable, Hashtable)
Create a new MIMEHeader instance.

Method Index

 o defineField(String, Object)
Define a new field, with the given value.
 o dump()
Dump all headers.
 o getField(String)
Get the raw value of a field.
 o getFieldAccept(String)
Get the value of the accept header.
 o getFieldDate(String)
Get the value of a Date field.
 o getFieldHashtable(String)
Get the value of a field as a list.
 o getFieldInt(String)
Get the value of an integer field.
 o getFieldLanguage(String)
Get the value of some field as an array of languages.
 o getFieldList(String)
Get the value of a list field.
 o getFieldMIMEType(String)
Get the value of a MIMEType header.
 o getFieldObject(String)
Get the parsed value of a field.
 o getFieldString(String)
Get the value of an string field.
 o hasField(String)
Check if the given field has been defined for this request.
 o invalidFieldAccess(String, String)
 o parseDate(String)
 o parseInteger(String)
 o parseList(String, char)

Variables

 o rheaders
  protected Hashtable rheaders
 o headers
  protected Hashtable headers
 o blength
  protected int blength

Constructors

 o 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.

Methods

 o invalidFieldAccess
  protected void invalidFieldAccess(String name,
                                    String type) throws MIMEException
 o dump
  public void dump()
Dump all headers. Available for debug only.
 o 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.
 o 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.
 o 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.
 o 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.
 o parseDate
  protected Long parseDate(String string) throws MIMEException
 o parseInteger
  protected Integer parseInteger(String string) throws MIMEException
 o parseList
  protected String[] parseList(String string,
                               char sep) throws MIMEException
 o 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
 o 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.
 o 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.
 o 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
 o 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
 o 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
 o 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
 o 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