## com.bbn.openmap.tools.beanbox
Class MessageHeader

    java.lang.Object
      com.bbn.openmap.tools.beanbox.MessageHeader

public class MessageHeader
extends java.lang.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 Summary
`MessageHeader()`
`MessageHeader(java.io.InputStream is)`

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

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### MessageHeader

    public MessageHeader()

### MessageHeader

    public MessageHeader(java.io.InputStream is)
                  throws java.io.IOException

Method Detail

### findValue

    public java.lang.String findValue(java.lang.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.

### getKey

    public java.lang.String getKey(int n)

### getValue

    public java.lang.String getValue(int n)

### findNextValue

    public java.lang.String findNextValue(java.lang.String k,
                                          java.lang.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)) {
                     ...
                 }

### print

    public void print(java.io.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.

### add

    public void add(java.lang.String k,
                    java.lang.String v)

  Adds a key value pair to the end of the header. Duplicates are allowed.

### prepend

    public void prepend(java.lang.String k,
                        java.lang.String v)

  Prepends a key value pair to the beginning of the header. Duplicates are allowed.

### set

    public void set(int i,
                    java.lang.String k,
                    java.lang.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.

### set

    public void set(java.lang.String k,
                    java.lang.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.

### canonicalID

    public static java.lang.String canonicalID(java.lang.String id)

  Convert a message-id string to canonical form (strips off leading and trailing <>s)

### parseHeader

    public void parseHeader(java.io.InputStream is)
                     throws java.io.IOException

  Parse a MIME header from an input stream.

  Throws:
    `java.io.IOException`

### toString

    public java.lang.String toString()

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details