|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.openexchange.mail.mime.HeaderCollection
public class HeaderCollection
HeaderCollection - Represents a collection of RFC822
headers.
| Field Summary | |
|---|---|
static HeaderCollection |
EMPTY_COLLECTION
Read-only constant for an empty header collection |
| Constructor Summary | |
|---|---|
HeaderCollection()
Initializes a new HeaderCollection with a default initial capacity of 40. |
|
HeaderCollection(HeaderCollection headers)
Copy constructor for HeaderCollection |
|
HeaderCollection(java.io.InputStream inputStream)
Initializes a new HeaderCollection from specified headers' RFC822 input stream |
|
HeaderCollection(int initialCapacity)
Initializes a new HeaderCollection |
|
HeaderCollection(java.lang.String headerSrc)
Initializes a new HeaderCollection from specified headers' RFC822 source |
|
| Method Summary | |
|---|---|
HeaderCollection |
addHeader(java.lang.String name,
java.lang.String value)
Adds a header with the specified name and value The current implementation knows about the preferred order of most well-known headers and will insert headers in that order. |
void |
addHeaders(HeaderCollection headers)
Adds the specified header collection to this header collection. |
void |
clear()
Clears this header collection. |
boolean |
containsHeader(java.lang.String name)
Checks if this header collection contains a header entry for specified header |
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one. |
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> |
getAllHeaders()
Gets an instance of Iterator to iterate all headers. |
java.lang.String[] |
getHeader(java.lang.String name)
Return all the values for the specified header. |
java.lang.String |
getHeader(java.lang.String name,
char delimiter)
Get all the headers for this header name, returned as a single String, with headers separated by the delimiter. |
java.lang.String |
getHeader(java.lang.String name,
java.lang.String delimiter)
Get all the headers for this header name, returned as a single String, with headers separated by the delimiter. |
java.util.Iterator<java.lang.String> |
getHeaderNames()
Gets an instance of Iterator to iterate all header names. |
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> |
getMatchingHeaders(java.lang.String[] matchingHeaders)
Gets the matching headers |
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> |
getNonMatchingHeaders(java.lang.String[] nonMatchingHeaders)
Gets the non-matching headers |
HeaderCollection |
getReadOnlyCollection()
Gets a read-only collection constructed from this collection's current content |
int |
hashCode()
|
boolean |
isEmpty()
Returns true if no headers are contained in this collection |
void |
load(java.io.InputStream inputStream)
Read and parse the given headers' RFC822 input stream till the blank line separating the header from the body. |
void |
load(java.lang.String headerSrc)
Read and parse the given headers' RFC822 source till the blank line separating the header from the body. |
HeaderCollection |
removeHeader(java.lang.String name)
Remove all header entries that match the given name |
HeaderCollection |
setHeader(java.lang.String name,
java.lang.String value)
Change the first header that matches name to have value, adding a new header if no existing header matches. |
int |
size()
Gets the number of headers contained in this collection. |
static void |
test()
Simple test method |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final HeaderCollection EMPTY_COLLECTION
| Constructor Detail |
|---|
public HeaderCollection()
HeaderCollection with a default initial capacity of 40.
public HeaderCollection(int initialCapacity)
HeaderCollection
initialCapacity - The collection's initial capacitypublic HeaderCollection(HeaderCollection headers)
HeaderCollection
headers - The source headerspublic HeaderCollection(java.lang.String headerSrc)
HeaderCollection from specified headers' RFC822 source
headerSrc - The headers' RFC822 source
public HeaderCollection(java.io.InputStream inputStream)
throws MailException
HeaderCollection from specified headers' RFC822 input stream
inputStream - The headers' RFC822 input stream
MailException - If parsing the header input stream fails| Method Detail |
|---|
public HeaderCollection getReadOnlyCollection()
collection constructed from this collection's current content
collection
public void load(java.io.InputStream inputStream)
throws MailException
Note that the header lines are added, so any existing headers in this object will not be affected. Headers are added to the end of the existing list of headers, in order.
Provided input stream is not going to be closed but is read until EOF or two subsequent CRLFs occur.
inputStream - The headers' RFC822 input stream
MailException - If reading from headers' RFC822 input
stream failspublic void load(java.lang.String headerSrc)
Note that the header lines are added, so any existing headers in this object will not be affected. Headers are added to the end of the existing list of headers, in order.
headerSrc - The headers' RFC822 sourcepublic void clear()
public boolean isEmpty()
true if no headers are contained in this collection
true if no headers are contained in this collectionpublic int size()
This method is a constant-time operation.
public void addHeaders(HeaderCollection headers)
Note that the header lines are added, so any existing headers in this object will not be affected. Headers are added to the end of the existing list of headers, in order.
headers - The header collection to add
public HeaderCollection addHeader(java.lang.String name,
java.lang.String value)
The current implementation knows about the preferred order of most well-known headers and will insert headers in that order. In
addition, it knows that Received headers should be inserted in reverse order (newest before oldest), and that they
should appear at the beginning of the headers, preceded only by a possible Return-Path header.
Note that RFC822 headers can only contain US-ASCII characters.
name - The header namevalue - The header value
java.lang.IllegalArgumentException - If name or value is invalid
public HeaderCollection setHeader(java.lang.String name,
java.lang.String value)
Note that RFC822 headers can only contain US-ASCII characters.
name - The header namevalue - The header value
java.lang.IllegalArgumentException - If name or value is invalidpublic boolean containsHeader(java.lang.String name)
name - The header name
true if this header collection contains a header entry for specified header; otherwise falsepublic java.lang.String[] getHeader(java.lang.String name)
null if no headers with the specified name exist.
name - The header name
null if none exists
java.lang.IllegalArgumentException - If name is invalid
public java.lang.String getHeader(java.lang.String name,
java.lang.String delimiter)
null, only the first header is returned. Returns null if no headers with the specified name exist.
name - The header namedelimiter - The delimiter
null if none
public java.lang.String getHeader(java.lang.String name,
char delimiter)
'\0', only the first header is returned. Returns null if no headers with the specified name exist.
name - The header namedelimiter - The delimiter character
null if nonepublic HeaderCollection removeHeader(java.lang.String name)
name - The header name
public java.util.Iterator<java.lang.String> getHeaderNames()
Iterator to iterate all header names.
Iterator to iterate all header namespublic java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> getAllHeaders()
Iterator to iterate all headers.
Iterator to iterate all headerspublic java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> getMatchingHeaders(java.lang.String[] matchingHeaders)
matchingHeaders - The matching headers
public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> getNonMatchingHeaders(java.lang.String[] nonMatchingHeaders)
nonMatchingHeaders - The non-matching headers
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equal method.
equals in class java.lang.Objectobj - The reference object with which to compare.
true if this object is the same as the object argument; false otherwise.public int hashCode()
hashCode in class java.lang.Objectpublic static final void test()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||