Methods Summary |
---|
public void | addHeader(org.apache.http.Header header)Adds the given header to the group. The order in which this header was
added is preserved.
if (header == null) {
return;
}
headers.add(header);
|
public void | clear()Removes any contained headers.
headers.clear();
|
public java.lang.Object | clone()
HeaderGroup clone = (HeaderGroup) super.clone();
clone.headers = new ArrayList(this.headers);
return clone;
|
public boolean | containsHeader(java.lang.String name)Tests if headers with the given name are contained within this group.
Header name comparison is case insensitive.
for (int i = 0; i < headers.size(); i++) {
Header header = (Header) headers.get(i);
if (header.getName().equalsIgnoreCase(name)) {
return true;
}
}
return false;
|
public org.apache.http.message.HeaderGroup | copy()Returns a copy of this object
HeaderGroup clone = new HeaderGroup();
clone.headers.addAll(this.headers);
return clone;
|
public org.apache.http.Header[] | getAllHeaders()Gets all of the headers contained within this group.
return (Header[]) headers.toArray(new Header[headers.size()]);
|
public org.apache.http.Header | getCondensedHeader(java.lang.String name)Gets a header representing all of the header values with the given name.
If more that one header with the given name exists the values will be
combined with a "," as per RFC 2616.
Header name comparison is case insensitive.
Header[] headers = getHeaders(name);
if (headers.length == 0) {
return null;
} else if (headers.length == 1) {
return headers[0];
} else {
CharArrayBuffer valueBuffer = new CharArrayBuffer(128);
valueBuffer.append(headers[0].getValue());
for (int i = 1; i < headers.length; i++) {
valueBuffer.append(", ");
valueBuffer.append(headers[i].getValue());
}
return new BasicHeader(name.toLowerCase(Locale.ENGLISH), valueBuffer.toString());
}
|
public org.apache.http.Header | getFirstHeader(java.lang.String name)Gets the first header with the given name.
Header name comparison is case insensitive.
for (int i = 0; i < headers.size(); i++) {
Header header = (Header) headers.get(i);
if (header.getName().equalsIgnoreCase(name)) {
return header;
}
}
return null;
|
public org.apache.http.Header[] | getHeaders(java.lang.String name)Gets all of the headers with the given name. The returned array
maintains the relative order in which the headers were added.
Header name comparison is case insensitive.
ArrayList headersFound = new ArrayList();
for (int i = 0; i < headers.size(); i++) {
Header header = (Header) headers.get(i);
if (header.getName().equalsIgnoreCase(name)) {
headersFound.add(header);
}
}
return (Header[]) headersFound.toArray(new Header[headersFound.size()]);
|
public org.apache.http.Header | getLastHeader(java.lang.String name)Gets the last header with the given name.
Header name comparison is case insensitive.
// start at the end of the list and work backwards
for (int i = headers.size() - 1; i >= 0; i--) {
Header header = (Header) headers.get(i);
if (header.getName().equalsIgnoreCase(name)) {
return header;
}
}
return null;
|
public org.apache.http.HeaderIterator | iterator()Returns an iterator over this group of headers.
return new BasicListHeaderIterator(this.headers, null);
|
public org.apache.http.HeaderIterator | iterator(java.lang.String name)Returns an iterator over the headers with a given name in this group.
return new BasicListHeaderIterator(this.headers, name);
|
public void | removeHeader(org.apache.http.Header header)Removes the given header.
if (header == null) {
return;
}
headers.remove(header);
|
public void | setHeaders(org.apache.http.Header[] headers)Sets all of the headers contained within this group overriding any
existing headers. The headers are added in the order in which they appear
in the array.
clear();
if (headers == null) {
return;
}
for (int i = 0; i < headers.length; i++) {
this.headers.add(headers[i]);
}
|
public void | updateHeader(org.apache.http.Header header)Replaces the first occurence of the header with the same name. If no header with
the same name is found the given header is added to the end of the list.
if (header == null) {
return;
}
for (int i = 0; i < this.headers.size(); i++) {
Header current = (Header) this.headers.get(i);
if (current.getName().equalsIgnoreCase(header.getName())) {
this.headers.set(i, header);
return;
}
}
this.headers.add(header);
|