All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sun.beanbox.MessageHeader

java.lang.Object
   |
   +----sun.beanbox.MessageHeader

public class MessageHeader
extends Object
An RFC 844 or MIME message header. Includes methods for parsing headers from incoming streams, fetching values, setting values, and printing headers. Key values of null are legal: they indicate lines in the header that don't have a valid key, but do have a value (this isn't legal according to the standard, but lines like this are everywhere).


Constructor Index

 o MessageHeader()
 o MessageHeader(InputStream)

Method Index

 o add(String, String)
Adds a key value pair to the end of the header.
 o canonicalID(String)
Convert a message-id string to canonical form (strips off leading and trailing <>s)
 o findNextValue(String, String)
Find the next value that corresponds to this key.
 o findValue(String)
Find the value that corresponds to this key.
 o getKey(int)
 o getValue(int)
 o parseHeader(InputStream)
Parse a MIME header from an input stream.
 o prepend(String, String)
Prepends a key value pair to the beginning of the header.
 o print(PrintWriter)
Prints the key-value pairs represented by this header.
 o set(int, String, String)
Overwrite the previous key/val pair at location 'i' with the new k/v.
 o set(String, String)
Sets the value of a key.
 o toString()

Constructors

 o MessageHeader
 public MessageHeader()
 o MessageHeader
 public MessageHeader(InputStream is) throws IOException

Methods

 o findValue
 public String findValue(String k)
Find the value that corresponds to this key. It finds only the first occurrence of the key.

Parameters:
k - the key to find.
Returns:
null if not found.
 o getKey
 public String getKey(int n)
 o getValue
 public String getValue(int n)
 o findNextValue
 public String findNextValue(String k,
                             String v)
Find the next value that corresponds to this key. It finds the first value that follows v. To iterate over all the values of a key use:
		for(String v=h.findValue(k); v!=null; v=h.findNextValue(k, v)) {
		    ...
		}
	

 o print
 public void print(PrintWriter p)
Prints the key-value pairs represented by this header. Also prints the RFC required blank line at the end. Omits pairs with a null key.

 o add
 public void add(String k,
                 String v)
Adds a key value pair to the end of the header. Duplicates are allowed

 o prepend
 public void prepend(String k,
                     String v)
Prepends a key value pair to the beginning of the header. Duplicates are allowed

 o set
 public void set(int i,
                 String k,
                 String v)
Overwrite the previous key/val pair at location 'i' with the new k/v. If the index didn't exist before the key/val is simply tacked onto the end.

 o set
 public void set(String k,
                 String v)
Sets the value of a key. If the key already exists in the header, it's value will be changed. Otherwise a new key/value pair will be added to the end of the header.

 o canonicalID
 public static String canonicalID(String id)
Convert a message-id string to canonical form (strips off leading and trailing <>s)

 o parseHeader
 public void parseHeader(InputStream is) throws IOException
Parse a MIME header from an input stream.

 o toString
 public String toString()
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index