ccs.mime
Class MimeHeader

java.lang.Object
  extended by ccs.mime.MimeHeader

public class MimeHeader
extends java.lang.Object

The basic MIME header syntax defines a name/value pair. However, there is also a mechanism for the value to be refined with an arbitray set of parameters. This extended syntax looks like this:

                name: value; paramname=paramvalue; paramname=paramvalue; [...]
        
The basic name/value syntax is handled by HeaderedEntity. This class allows the extended syntax to be manipulated. It also optionally stores the rest of the header information (name and index of the header in the parent HeaderedEntity) as a convenience. It tolerates RFC822-style comments, and removes then during parsing.

MT-UNSAFE.


Constructor Summary
MimeHeader(HeaderedEntity parent, int index, java.lang.String name, java.lang.String raw)
          A MimeHeader which decodes the value part of the header into a value and a set of parameters, and also stores other optional information about the header.
MimeHeader(java.lang.String raw)
          A MimeHeader which decodes the value part of the header into a value and a set of parameters.
 
Method Summary
 java.lang.String compile()
          Return the value and parameter set as a raw header value.
 void deleteParam(java.lang.String paramName)
          Delete the parameter with the specified name.
 int getIndex()
          Return the index of this header in the parent entity.
 java.lang.String getName()
          Return the name of this header.
 java.lang.String getParam(java.lang.String paramName)
          Return the value of the parameter with the specified name, or null if there is none such.
 java.lang.String[] getParamNames()
          Return the list of available param names.
 HeaderedEntity getParent()
          Return the HeaderedEntity this belongs to
 java.lang.String getValue()
          Return the processed value (no parameters).
 void setParam(java.lang.String paramName, java.lang.String paramValue)
          Add a new parameter or change the value of an existing one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeHeader

public MimeHeader(java.lang.String raw)
A MimeHeader which decodes the value part of the header into a value and a set of parameters.

Parameters:
raw - The raw value, with any parameters and / or comments

MimeHeader

public MimeHeader(HeaderedEntity parent,
                  int index,
                  java.lang.String name,
                  java.lang.String raw)
A MimeHeader which decodes the value part of the header into a value and a set of parameters, and also stores other optional information about the header. This extra information is stored verbatim; it's not checked and plays no further part in the operation of this class.

Parameters:
parent - The HeaderedEntity this header came in.
index - The index of this header in the entity's header list.
name - The header's name.
raw - The raw value, with any parameters and / or comments embedded.
Method Detail

getParent

public HeaderedEntity getParent()
Return the HeaderedEntity this belongs to


getIndex

public int getIndex()
Return the index of this header in the parent entity.


getName

public java.lang.String getName()
Return the name of this header.


getValue

public java.lang.String getValue()
Return the processed value (no parameters).


getParam

public java.lang.String getParam(java.lang.String paramName)
Return the value of the parameter with the specified name, or null if there is none such.

Parameters:
paramName - the name of the parameter. This must be in lowercase, or it won't get anything. (Parameter names are specified to be case-insensitive).

setParam

public void setParam(java.lang.String paramName,
                     java.lang.String paramValue)
Add a new parameter or change the value of an existing one.

Parameters:
paramName - The name of the parameter.
paramValue - The (new) value of the parameter.

deleteParam

public void deleteParam(java.lang.String paramName)
Delete the parameter with the specified name.

Parameters:
paramName - The name of the parameter to delete.

getParamNames

public java.lang.String[] getParamNames()
Return the list of available param names.


compile

public java.lang.String compile()
Return the value and parameter set as a raw header value. All parameter names are in lower case, all parameter values are quoted, any comments in the original will have gone, where there are multiple parameters their ordering is not preserved. Therefore a parse-compile round trip is not necessarily an identity transform.