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).
-
MessageHeader()
-
-
MessageHeader(InputStream)
-
-
add(String, String)
- Adds a key value pair to the end of the
header.
-
canonicalID(String)
- Convert a message-id string to canonical form (strips off
leading and trailing <>s)
-
findNextValue(String, String)
- Find the next value that corresponds to this key.
-
findValue(String)
- Find the value that corresponds to this key.
-
getKey(int)
-
-
getValue(int)
-
-
parseHeader(InputStream)
- Parse a MIME header from an input stream.
-
prepend(String, String)
- Prepends a key value pair to the beginning of the
header.
-
print(PrintWriter)
- Prints the key-value pairs represented by this
header.
-
set(int, String, String)
- Overwrite the previous key/val pair at location 'i'
with the new k/v.
-
set(String, String)
- Sets the value of a key.
-
toString()
-
MessageHeader
public MessageHeader()
MessageHeader
public MessageHeader(InputStream is) throws IOException
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.
getKey
public String getKey(int n)
getValue
public String getValue(int n)
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)) {
...
}
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.
add
public void add(String k,
String v)
- Adds a key value pair to the end of the
header. Duplicates are allowed
prepend
public void prepend(String k,
String v)
- Prepends a key value pair to the beginning of the
header. Duplicates are allowed
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.
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.
canonicalID
public static String canonicalID(String id)
- Convert a message-id string to canonical form (strips off
leading and trailing <>s)
parseHeader
public void parseHeader(InputStream is) throws IOException
- Parse a MIME header from an input stream.
toString
public String toString()
- Overrides:
- toString in class Object
All Packages Class Hierarchy This Package Previous Next Index