Methods Summary |
---|
public void | addHeader(java.lang.String name, java.lang.String value)Adds a MimeHeader object with the specified
name and value to this MimeHeaders object's
list of headers.
Note that RFC822 headers can contain only US-ASCII
characters.
if ((name == null) || name.equals("")) {
throw new IllegalArgumentException(
"Illegal MimeHeader name");
}
int i = headers.size();
for (int j = i - 1; j >= 0; j--) {
MimeHeader mimeheader = (MimeHeader) headers.elementAt(j);
if (mimeheader.getName().equalsIgnoreCase(name)) {
headers.insertElementAt(new MimeHeader(name, value), j + 1);
return;
}
}
headers.addElement(new MimeHeader(name, value));
|
public java.util.Iterator | getAllHeaders()Returns all the headers in this MimeHeaders
object.
return headers.iterator();
|
public java.lang.String[] | getHeader(java.lang.String name)Returns all of the values for the specified header as an
array of String objects.
Vector vector = new Vector();
for (int i = 0; i < headers.size(); i++) {
MimeHeader mimeheader = (MimeHeader) headers.elementAt(i);
if (mimeheader.getName().equalsIgnoreCase(name)
&& (mimeheader.getValue() != null)) {
vector.addElement(mimeheader.getValue());
}
}
if (vector.size() == 0) {
return null;
} else {
String as[] = new String[vector.size()];
vector.copyInto(as);
return as;
}
|
public java.util.Iterator | getMatchingHeaders(java.lang.String[] names)Returns all the MimeHeader objects whose
name matches a name in the given array of names.
return new MatchingIterator(names, true);
|
public java.util.Iterator | getNonMatchingHeaders(java.lang.String[] names)Returns all of the MimeHeader objects whose
name does not match a name in the given array of names.
return new MatchingIterator(names, false);
|
public void | removeAllHeaders()Removes all the header entries from this
MimeHeaders object.
headers.removeAllElements();
|
public void | removeHeader(java.lang.String name)Remove all MimeHeader objects whose name
matches the the given name.
for (int i = 0; i < headers.size(); i++) {
MimeHeader mimeheader = (MimeHeader) headers.elementAt(i);
if (mimeheader.getName().equalsIgnoreCase(name)) {
headers.removeElementAt(i--);
}
}
|
public void | setHeader(java.lang.String name, java.lang.String value)Replaces the current value of the first header entry whose
name matches the given name with the given value, adding a
new header if no existing header name matches. This method
also removes all matching headers after the first one.
Note that RFC822 headers can contain only US-ASCII
characters.
boolean flag = false;
if ((name == null) || name.equals("")) {
throw new IllegalArgumentException(
"Illegal MimeHeader name");
}
for (int i = 0; i < headers.size(); i++) {
MimeHeader mimeheader = (MimeHeader) headers.elementAt(i);
if (mimeheader.getName().equalsIgnoreCase(name)) {
if (!flag) {
headers.setElementAt(new MimeHeader(mimeheader
.getName(), value), i);
flag = true;
} else {
headers.removeElementAt(i--);
}
}
}
if (!flag) {
addHeader(name, value);
}
|