Header header = Header.full('Content-Type:text/plain')
assert header.key == 'Content-Type'
assert header.value == 'text/plain'
public abstract static class FromServer.Header<T>
extends java.lang.Object
implements java.util.Map.Entry<java.lang.String,java.lang.String>
Defines the interface to the HTTP headers contained in the response. (see also List of HTTP Header Fields)
Modifier and Type | Class and Description |
---|---|
static class |
FromServer.Header.CombinedMap
Type representing headers that have values which are parseable as key/value pairs,
provided the header hey is included in the key/value map.
|
static class |
FromServer.Header.CsvList
Type representing headers that have values which are comma separated lists.
|
static class |
FromServer.Header.HttpCookies |
static class |
FromServer.Header.HttpDate
Type representing headers that have values which are zoned date time values.
|
static class |
FromServer.Header.MapPairs
Type representing headers that have values which are parseable as key/value pairs.
|
static class |
FromServer.Header.SingleLong
Type representing headers that have values which are parseable as longs.
|
static class |
FromServer.Header.ValueOnly
Type representing headers that are simple key/values, with no parseable structure in the value.
|
Modifier | Constructor and Description |
---|---|
protected |
Header(java.lang.String key,
java.lang.String value) |
Modifier and Type | Method and Description |
---|---|
protected static java.lang.String |
cleanQuotes(java.lang.String str) |
boolean |
equals(java.lang.Object o) |
static FromServer.Header<?> |
find(java.util.Collection<FromServer.Header<?>> headers,
java.lang.String key)
Used to find a specific
Header by key from a Collection of `Header`s. |
static FromServer.Header<?> |
full(java.lang.String raw)
Creates a
Header from a full header string. |
java.lang.String |
getKey()
Retrieves the header
key . |
T |
getParsed()
Retrieves the parsed representation of the 'value`.
|
abstract java.lang.Class<?> |
getParsedType()
Retrieves the type of the parsed representation of the 'value`.
|
java.lang.String |
getValue()
Retrieves the header
value . |
int |
hashCode() |
protected static java.lang.String |
key(java.lang.String raw) |
static FromServer.Header<?> |
keyValue(java.lang.String key,
java.lang.String value)
Creates a
Header from a given key and value . |
protected abstract T |
parse()
Performs the parse of the
value |
java.lang.String |
setValue(java.lang.String val)
Unsupported, headers are read-only.
|
java.lang.String |
toString() |
protected static java.lang.String |
value(java.lang.String raw) |
protected static java.lang.String key(java.lang.String raw)
protected static java.lang.String cleanQuotes(java.lang.String str)
protected static java.lang.String value(java.lang.String raw)
public java.lang.String getKey()
Retrieves the header key
.
getKey
in interface java.util.Map.Entry<java.lang.String,java.lang.String>
public java.lang.String getValue()
Retrieves the header value
.
getValue
in interface java.util.Map.Entry<java.lang.String,java.lang.String>
public java.lang.String setValue(java.lang.String val)
Unsupported, headers are read-only.
setValue
in interface java.util.Map.Entry<java.lang.String,java.lang.String>
java.lang.UnsupportedOperationException
- alwayspublic boolean equals(java.lang.Object o)
equals
in interface java.util.Map.Entry<java.lang.String,java.lang.String>
equals
in class java.lang.Object
public int hashCode()
hashCode
in interface java.util.Map.Entry<java.lang.String,java.lang.String>
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public T getParsed()
Retrieves the parsed representation of the 'value`. The type of
the returned Object
depends on the header and will be given
by the getParsedType()
property.
public abstract java.lang.Class<?> getParsedType()
Retrieves the type of the parsed representation of the 'value`.
protected abstract T parse()
Performs the parse of the value
public static FromServer.Header<?> full(java.lang.String raw)
Creates a Header
from a full header string. The string format is colon-delimited as KEY:VALUE
.
Header header = Header.full('Content-Type:text/plain')
assert header.key == 'Content-Type'
assert header.value == 'text/plain'
raw
- the full header stringHeader
representing the given header stringpublic static FromServer.Header<?> keyValue(java.lang.String key, java.lang.String value)
Creates a Header
from a given key
and value
.
key
- the header keyvalue
- the header valueHeader
public static FromServer.Header<?> find(java.util.Collection<FromServer.Header<?>> headers, java.lang.String key)
Used to find a specific Header
by key from a Collection
of `Header`s.
headers
- the Collection
of `Header`s to be searchedkey
- the key of the desired Header
Header
with the matching key (or null
)