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 pos = headers.size();
for(int i = pos - 1 ; i >= 0; i--) {
MimeHeader hdr = (MimeHeader) headers.elementAt(i);
if (hdr.getName().equalsIgnoreCase(name)) {
headers.insertElementAt(new MimeHeader(name, value),
i+1);
return;
}
}
headers.addElement(new MimeHeader(name, value));
|
public java.util.Iterator | getAllHeaders()Returns all the MimeHeader s 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 values = new Vector();
for(int i = 0; i < headers.size(); i++) {
MimeHeader hdr = (MimeHeader) headers.elementAt(i);
if (hdr.getName().equalsIgnoreCase(name)
&& hdr.getValue() != null)
values.addElement(hdr.getValue());
}
if (values.size() == 0)
return null;
String r[] = new String[values.size()];
values.copyInto(r);
return r;
|
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
given name.
for(int i = 0; i < headers.size(); i++) {
MimeHeader hdr = (MimeHeader) headers.elementAt(i);
if (hdr.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 found = false;
if ((name == null) || name.equals(""))
throw new IllegalArgumentException("Illegal MimeHeader name");
for(int i = 0; i < headers.size(); i++) {
MimeHeader hdr = (MimeHeader) headers.elementAt(i);
if (hdr.getName().equalsIgnoreCase(name)) {
if (!found) {
headers.setElementAt(new MimeHeader(hdr.getName(),
value), i);
found = true;
}
else
headers.removeElementAt(i--);
}
}
if (!found)
addHeader(name, value);
|