EAF 7.6 Implementation

com.lutris.mime
Class MimeHeader

java.lang.Object
  extended by com.lutris.mime.MimeHeader
Direct Known Subclasses:
ContentHeader

public class MimeHeader
extends java.lang.Object

Represents a generic parsed Mime header. Specific header types, such as Content-Type are represented by classes derived from this header. The constructor for this class parses only parameters according to the rules specified in RFC2045 Section 5.1 Page 11. It is left to derived classes to parse type-specifiec information such as the Mime type ( Content-Type) or content disposition ( Content-Disposition).


Constructor Summary
MimeHeader(java.lang.String headerLine)
          Constructs a generic MimeHeader object and initializes its internal parameter list.
 
Method Summary
 java.lang.String getHeaderType()
          Returns the header type of this header.
 java.lang.String getParameter(java.lang.String name)
          Returns a single String value representing the last occurence of the parameter named by name.
 java.util.Enumeration getParameterNames()
          Returns an enumeration of all of the parameter names parsed from the current Mime header.
 java.lang.String[] getParameters(java.lang.String name)
          Returns an array of String containing all occurences of values named by name.
 java.lang.String getRawHeaderLine()
          Returns the string passed to the constructor without any parsing.
 java.lang.String getValue()
          Returns the "value" of this header.
protected  void parseParameters(java.lang.String headerLine)
          Parses the a given string into key=parameter pairs in accordance with RFC2045 Section 5.1 Page 11.
protected  void putParameter(java.lang.String name, java.lang.String value)
          Used by derived classes to put a parameter into the internal parameter value holder.
 
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 headerLine)
Constructs a generic MimeHeader object and initializes its internal parameter list.

Method Detail

putParameter

protected void putParameter(java.lang.String name,
                            java.lang.String value)
Used by derived classes to put a parameter into the internal parameter value holder.

Parameters:
name - The name of the parameter value to add.
value - The value to add.

getValue

public java.lang.String getValue()
Returns the "value" of this header. This is defined to be the trimmed substring between the first colon (':') character and the first semicolon (';') character. For example, observe the following header line:
 
 Content-Type: multipart/form-data; boundary="000572A9AD4"
 
 
The value of this header is multipart/form-data , the header type is Content-Type , and the first parameter is named boundary and has the value 00572A9AD4 .

Returns:
The value of this Mime header.

getHeaderType

public java.lang.String getHeaderType()
Returns the header type of this header. This is defined to be the substring from the first character up to first colon (':') character. For example, observe the following header line:
 
 Content-Type: multipart/form-data; boundary="000572A9AD4"
 
 
The value of this header is multipart/form-data , the header type is Content-Type , and the first parameter is named boundary and has the value 00572A9AD4 .

Returns:
The header type of this Mime header.

getRawHeaderLine

public java.lang.String getRawHeaderLine()
Returns the string passed to the constructor without any parsing.


getParameter

public java.lang.String getParameter(java.lang.String name)
Returns a single String value representing the last occurence of the parameter named by name. For example, observe the following header line:
 
 Content-Type: multipart/form-data; boundary="000572A9AD4"
 
 
The value of this header is multipart/form-data , the header type is Content-Type , and the first parameter is named boundary and has the value 00572A9AD4 .

Parameters:
name - The name of the parameter to return.
Returns:
The value of the last occurence of the named parameter or null if not found.

getParameters

public java.lang.String[] getParameters(java.lang.String name)
Returns an array of String containing all occurences of values named by name. For example, observe the following header line:
 
 Content-Type: multipart/form-data; boundary="000572A9AD4"
 
 
The value of this header is multipart/form-data , the header type is Content-Type , and the first parameter is named boundary and has the value 00572A9AD4 .

Parameters:
name - The name of the parameter to return.
Returns:
Array containing all values for the named parameter or null if not found.

getParameterNames

public java.util.Enumeration getParameterNames()
Returns an enumeration of all of the parameter names parsed from the current Mime header.

Returns:
An enumeration of the names of all parameters parsed from the Mime header.

parseParameters

protected void parseParameters(java.lang.String headerLine)
Parses the a given string into key=parameter pairs in accordance with RFC2045 Section 5.1 Page 11. Quoted strings are parsed in accordance with the RFC822 definition of the "quoted-string" grammatic construct. According to RFC822, quoted strings are strings, enclosed in double-quote marks, which contain any character except LF or double-quote. The backslash character is used to literally quote the following character. Octal or hex code backquoting is not supported.


EAF 7.6 Implementation