![]() |
|
Contents |
It is essentially constructed by hashtable with key indexed in a vector for position lookup.
Public Member Functions | |
| Header () | |
| A generic header structure. | |
| Header (Map< String, List< String >> map) | |
| The alternative constructor which sets the input map as its initial keyTable. | |
| Object | clone () |
| void | add (String key, String value) |
| Add a field with the specified value. | |
| void | set (String key, String value) |
| Set a field with the specified value. | |
| Map< String, List< String > > | getFieldMap () |
| Provides an unmodifiable map with all String header names mapped to their String values. | |
| String | get (int pos) |
Answers the element at pos, null if no such element exist. | |
| String | getKey (int pos) |
Answers the key of this header at pos, null if there are fewer keys in the header. | |
| String | get (String key) |
| Answers the value corresponding to the specified key. | |
| int | length () |
| Answers the number of keys stored in this header. | |
| void | setStatusLine (String statusLine) |
| Sets the status line in the header request example: GET / HTTP/1.1 response example: HTTP/1.1 200 OK. | |
| String | getStatusLine () |
| Gets the status line in the header request example: GET / HTTP/1.1 response example: HTTP/1.1 200 OK. | |
Private Attributes | |
| ArrayList< String > | props |
| HashMap< String, LinkedList < String > > | keyTable |
| String | statusLine |
| Header | ( | ) |
A generic header structure.
Used mostly for request / response header. The key/value pair of the header may be inserted for later use. The key is stored in an array for indexed slot access.
| Header | ( | Map< String, List< String >> | map | ) |
The alternative constructor which sets the input map as its initial keyTable.
| map | the initial keyTable as a map |
| Object clone | ( | ) |
| void add | ( | String | key, | |
| String | value | |||
| ) |
Add a field with the specified value.
| key | ||
| value |
| void set | ( | String | key, | |
| 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.
| key | ||
| value |
| Map<String, List<String> > 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.
| String get | ( | int | pos | ) |
Answers the element at pos, null if no such element exist.
| pos | int the position to look for |
| String getKey | ( | int | pos | ) |
Answers the key of this header at pos, null if there are fewer keys in the header.
| pos | the position to look for |
| String get | ( | String | key | ) |
Answers the value corresponding to the specified key.
| key | the key to look up. |
null if no such key exists. | int length | ( | ) |
Answers the number of keys stored in this header.
| void setStatusLine | ( | String | statusLine | ) |
Sets the status line in the header request example: GET / HTTP/1.1 response example: HTTP/1.1 200 OK.
| statusLine |
| String getStatusLine | ( | ) |
Gets the status line in the header request example: GET / HTTP/1.1 response example: HTTP/1.1 200 OK.
ArrayList<String> props [private] |
HashMap<String, LinkedList<String> > keyTable [private] |
String statusLine [private] |