Methods Summary |
---|
public void | add(java.lang.String key, java.lang.String value)Add a field with the specified value.
if (key == null) {
throw new NullPointerException();
}
// BEGIN android-changed
key = key.toLowerCase();
LinkedList<String> list = keyTable.get(key);
if (list == null) {
list = new LinkedList<String>();
keyTable.put(key, list);
}
// END android-changed
list.add(value);
props.add(key);
props.add(value);
|
public java.lang.Object | clone()
try {
Header clone = (Header) super.clone();
clone.props = (ArrayList<String>) props.clone();
clone.keyTable = new HashMap<String, LinkedList<String>>(20);
for (Map.Entry<String, LinkedList<String>> next : this.keyTable
.entrySet()) {
LinkedList<String> v = (LinkedList<String>) next.getValue()
.clone();
clone.keyTable.put(next.getKey(), v);
}
return clone;
} catch (CloneNotSupportedException e) {
return null;
}
|
public java.lang.String | get(int pos)Returns the element at pos , null if no such element
exist.
if (pos >= 0 && pos < props.size() / 2) {
return props.get(pos * 2 + 1);
}
return null;
|
public java.lang.String | get(java.lang.String key)Returns the value corresponding to the specified key, null if no such key
exists.
LinkedList<String> result = keyTable.get(key.toLowerCase());
if (result == null) {
return null;
}
return result.getLast();
|
public java.util.Map | getFieldMap()Provides an unmodifiable map with all String header names mapped to their
String values. The map keys are Strings and the values are unmodifiable
Lists of Strings.
Map<String, List<String>> result = new HashMap<String, List<String>>(
keyTable.size());
for (Map.Entry<String, LinkedList<String>> next : keyTable.entrySet()) {
List<String> v = next.getValue();
result.put(next.getKey(), Collections.unmodifiableList(v));
}
return Collections.unmodifiableMap(result);
|
public java.lang.String | getKey(int pos)Returns the key of this header at pos , null if there are
fewer keys in the header
if (pos >= 0 && pos < props.size() / 2) {
return props.get(pos * 2);
}
return null;
|
public java.lang.String | getStatusLine()Gets the status line in the header request example: GET / HTTP/1.1
response example: HTTP/1.1 200 OK
return statusLine;
|
public int | length()Returns the number of keys stored in this header
return props.size() / 2;
|
public void | set(java.lang.String key, java.lang.String value)Set a field with the specified value. If the field is not found, it is
added. If the field is found, the existing value(s) are overwritten.
if (key == null) {
throw new NullPointerException();
}
// BEGIN android-added
key = key.toLowerCase();
// END android-added
LinkedList<String> list = keyTable.get(key);
if (list == null) {
add(key, value);
} else {
list.clear();
list.add(value);
for (int i = 0; i < props.size(); i += 2) {
String propKey = props.get(i);
if (propKey != null && key.equals(propKey)) {
props.set(i + 1, value);
}
}
}
|
public void | setStatusLine(java.lang.String statusLine)Sets the status line in the header request example: GET / HTTP/1.1
response example: HTTP/1.1 200 OK
this.statusLine = statusLine;
/*
* we add the status line to the list of headers so that it is
* accessible from java.net.HttpURLConnection.getResponseCode() which
* calls
* org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHeaderField(0)
* to get it
*/
props.add(0, null);
props.add(1, statusLine);
|