Class DefaultHeaders<K,V,T extends Headers<K,V,T>>
- Type Parameters:
K
- the type of the header name.V
- the type of the header value.T
- the type to use for return values when the intention is to returnthis
object.
- Direct Known Subclasses:
CharSequenceMap
,CombinedHttpHeaders.CombinedHttpHeadersImpl
,DefaultHeadersImpl
,DefaultHttp2Headers
,DefaultSpdyHeaders
,DefaultStompHeaders
Headers
;-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
private final class
static interface
private final class
static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DefaultHeaders.HeaderEntry<K,
V>[] (package private) static final int
Constant used to seed the hash code generation.private final HashingStrategy
<K> private final byte
protected final DefaultHeaders.HeaderEntry
<K, V> private final DefaultHeaders.NameValidator
<K> (package private) int
private final ValueConverter
<V> private final DefaultHeaders.ValueValidator
<V> -
Constructor Summary
ConstructorsConstructorDescriptionDefaultHeaders
(ValueConverter<V> valueConverter) DefaultHeaders
(ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator) DefaultHeaders
(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter) DefaultHeaders
(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator) DefaultHeaders
(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator, int arraySizeHint) Create a new instance.DefaultHeaders
(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator, int arraySizeHint, DefaultHeaders.ValueValidator<V> valueValidator) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionAdds all header names and values ofheaders
to this object.Adds new headers with the specifiedname
andvalues
.Adds a new header with the specifiedname
andvalue
.Adds new headers with the specifiedname
andvalues
.private void
addBoolean
(K name, boolean value) Adds a new header.Adds a new header.Adds a new header.Adds a new header.Adds a new header.protected void
Adds a new header.Adds a new header.Adds a new header with the specified name and values.Adds a new header.Adds a new header with the specified name and values.Adds a new header.addTimeMillis
(K name, long value) Adds a new header.clear()
Removes all headers.boolean
Returnstrue
if a header with thename
exists,false
otherwise.boolean
Returnstrue
if a header with thename
andvalue
exists,false
otherwise.final boolean
contains
(K name, V value, HashingStrategy<? super V> valueHashingStrategy) boolean
containsBoolean
(K name, boolean value) Returnstrue
if a header with the name and value exists.boolean
containsByte
(K name, byte value) Returnstrue
if a header with the name and value exists.boolean
containsChar
(K name, char value) Returnstrue
if a header with the name and value exists.boolean
containsDouble
(K name, double value) Returnstrue
if a header with the name and value exists.boolean
containsFloat
(K name, float value) Returnstrue
if a header with the name and value exists.boolean
containsInt
(K name, int value) Returnstrue
if a header with the name and value exists.boolean
containsLong
(K name, long value) Returnstrue
if a header with the name and value exists.boolean
containsObject
(K name, Object value) Returnstrue
if a header with the name and value exists.boolean
containsShort
(K name, short value) Returnstrue
if a header with the name and value exists.boolean
containsTimeMillis
(K name, long value) Returnstrue
if a header with the name and value exists.copy()
Returns a deep copy of this instance.final boolean
Test this object for equality againsth2
.boolean
private V
fromBoolean
(K name, boolean value) private V
private V
private V
fromDouble
(K name, double value) private V
private V
private V
private V
fromObject
(K name, Object value) private V
private V
fromTimeMillis
(K name, long value) Returns the value of a header with the specified name.Returns the value of a header with the specified name.Returns all values for the header with the specified name.getAllAndRemove
(K name) Returns all values for the header with the specified name and removes them from this object.getAndRemove
(K name) Returns the value of a header with the specified name and removes it from this object.getAndRemove
(K name, V defaultValue) Returns the value of a header with the specified name and removes it from this object.getBoolean
(K name) Returns theboolean
value of a header with the specified name.boolean
getBoolean
(K name, boolean defaultValue) Returns theboolean
value of a header with the specified name.getBooleanAndRemove
(K name) Returns theboolean
value of a header with the specifiedname
and removes the header from this object.boolean
getBooleanAndRemove
(K name, boolean defaultValue) Returns theboolean
value of a header with the specifiedname
and removes the header from this object.Returns thebyte
value of a header with the specified name.byte
Returns thebyte
value of a header with the specified name.getByteAndRemove
(K name) Returns thebyte
value of a header with the specifiedname
and removes the header from this object.byte
getByteAndRemove
(K name, byte defaultValue) Returns thebyte
value of a header with the specifiedname
and removes the header from this object.Returns thechar
value of a header with the specified name.char
Returns thechar
value of a header with the specified name.getCharAndRemove
(K name) Returns thechar
value of a header with the specifiedname
and removes the header from this object.char
getCharAndRemove
(K name, char defaultValue) Returns thechar
value of a header with the specifiedname
and removes the header from this object.Returns thedouble
value of a header with the specified name.double
Returns thedouble
value of a header with the specified name.getDoubleAndRemove
(K name) Returns thedouble
value of a header with the specifiedname
and removes the header from this object.double
getDoubleAndRemove
(K name, double defaultValue) Returns thedouble
value of a header with the specifiedname
and removes the header from this object.Returns thefloat
value of a header with the specified name.float
Returns thefloat
value of a header with the specified name.getFloatAndRemove
(K name) Returns thefloat
value of a header with the specifiedname
and removes the header from this object.float
getFloatAndRemove
(K name, float defaultValue) Returns thefloat
value of a header with the specifiedname
and removes the header from this object.Returns theint
value of a header with the specified name.int
Returns theint
value of a header with the specified name.getIntAndRemove
(K name) Returns theint
value of a header with the specifiedname
and removes the header from this object.int
getIntAndRemove
(K name, int defaultValue) Returns theint
value of a header with the specifiedname
and removes the header from this object.Returns thelong
value of a header with the specified name.long
Returns thelong
value of a header with the specified name.getLongAndRemove
(K name) Returns thelong
value of a header with the specifiedname
and removes the header from this object.long
getLongAndRemove
(K name, long defaultValue) Returns thelong
value of a header with the specifiedname
and removes the header from this object.Returns theshort
value of a header with the specified name.short
Returns theshort
value of a header with the specified name.getShortAndRemove
(K name) Returns theshort
value of a header with the specifiedname
and removes the header from this object.short
getShortAndRemove
(K name, short defaultValue) Returns theshort
value of a header with the specifiedname
and removes the header from this object.getTimeMillis
(K name) Returns the value of a header with the specified name in milliseconds.long
getTimeMillis
(K name, long defaultValue) Returns the value of a header with the specified name in milliseconds.getTimeMillisAndRemove
(K name) Returns the value of a header with the specifiedname
in milliseconds and removes the header from this object.long
getTimeMillisAndRemove
(K name, long defaultValue) Returns the value of a header with the specifiedname
in milliseconds and removes the header from this object.int
hashCode()
final int
hashCode
(HashingStrategy<V> valueHashingStrategy) Generate a hash code for this object given aHashingStrategy
to generate hash codes for individual values.private int
index
(int hash) boolean
isEmpty()
iterator()
names()
Returns aSet
of all header names in this object.protected DefaultHeaders.NameValidator
<K> protected DefaultHeaders.HeaderEntry
<K, V> newHeaderEntry
(int h, K name, V value, DefaultHeaders.HeaderEntry<K, V> next) boolean
Removes all headers with the specifiedname
.private V
(package private) DefaultHeaders.HeaderEntry
<K, V> remove0
(DefaultHeaders.HeaderEntry<K, V> entry, DefaultHeaders.HeaderEntry<K, V> previous) Clears the current header entries and copies all header entries of the specifiedheaders
.Sets a new header with the specified name and values.Sets a header with the specified name and value.Sets a header with the specified name and values.Retains all current headers but callsHeaders.set(K, V)
for each entry inheaders
.setBoolean
(K name, boolean value) Set thename
tovalue
.Set thename
tovalue
.Set thename
tovalue
.Set thename
tovalue
.Set thename
tovalue
.Set thename
tovalue
.Set thename
tovalue
.Sets a header with the specified name and values.Sets a new header.Sets a header with the specified name and values.Set thename
tovalue
.setTimeMillis
(K name, long value) Set thename
tovalue
.int
size()
Returns the number of headers in this object.private T
thisT()
private boolean
private byte
private char
private double
private float
private int
private long
private short
toString()
private long
toTimeMillis
(K name, V value) protected void
validateName
(DefaultHeaders.NameValidator<K> validator, boolean forAdd, K name) Call out to the givenDefaultHeaders.NameValidator
to validate the given name.protected void
validateValue
(DefaultHeaders.ValueValidator<V> validator, K name, V value) protected ValueConverter
<V> valueIterator
(K name) Equivalent togetAll(Object)
but no intermediate list is generated.protected DefaultHeaders.ValueValidator
<V> Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
HASH_CODE_SEED
static final int HASH_CODE_SEEDConstant used to seed the hash code generation. Could be anything but this was borrowed from murmur3.- See Also:
-
entries
-
head
-
hashMask
private final byte hashMask -
valueConverter
-
nameValidator
-
valueValidator
-
hashingStrategy
-
size
int size
-
-
Constructor Details
-
DefaultHeaders
-
DefaultHeaders
public DefaultHeaders(ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator) -
DefaultHeaders
-
DefaultHeaders
public DefaultHeaders(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator) -
DefaultHeaders
public DefaultHeaders(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator, int arraySizeHint) Create a new instance.- Parameters:
nameHashingStrategy
- Used to hash and equality compare names.valueConverter
- Used to convert values to/from native types.nameValidator
- Used to validate name elements.arraySizeHint
- A hint as to how large the hash data structure should be. The next positive power of two will be used. An upper bound may be enforced.
-
DefaultHeaders
public DefaultHeaders(HashingStrategy<K> nameHashingStrategy, ValueConverter<V> valueConverter, DefaultHeaders.NameValidator<K> nameValidator, int arraySizeHint, DefaultHeaders.ValueValidator<V> valueValidator) Create a new instance.- Parameters:
nameHashingStrategy
- Used to hash and equality compare names.valueConverter
- Used to convert values to/from native types.nameValidator
- Used to validate name elements.arraySizeHint
- A hint as to how large the hash data structure should be. The next positive power of two will be used. An upper bound may be enforced.valueValidator
- The validation strategy for entry values.
-
-
Method Details
-
get
Description copied from interface:Headers
Returns the value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
get
Description copied from interface:Headers
Returns the value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getAndRemove
Description copied from interface:Headers
Returns the value of a header with the specified name and removes it from this object. If there is more than one value for the specified name, the first value in insertion order is returned. -
getAndRemove
Description copied from interface:Headers
Returns the value of a header with the specified name and removes it from this object. If there is more than one value for the specified name, the first value in insertion order is returned. -
getAll
Description copied from interface:Headers
Returns all values for the header with the specified name. The returnedList
can't be modified. -
valueIterator
Equivalent togetAll(Object)
but no intermediate list is generated.- Parameters:
name
- the name of the header to retrieve- Returns:
- an
Iterator
of header values corresponding toname
.
-
getAllAndRemove
Description copied from interface:Headers
Returns all values for the header with the specified name and removes them from this object. The returnedList
can't be modified. -
contains
Description copied from interface:Headers
Returnstrue
if a header with thename
exists,false
otherwise. -
containsObject
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists. -
containsBoolean
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists. -
containsByte
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists. -
containsChar
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists. -
containsShort
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists. -
containsInt
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists. -
containsLong
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists. -
containsFloat
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists. -
containsDouble
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists. -
containsTimeMillis
Description copied from interface:Headers
Returnstrue
if a header with the name and value exists. -
contains
Description copied from interface:Headers
Returnstrue
if a header with thename
andvalue
exists,false
otherwise.The
Object.equals(Object)
method is used to test for equality ofvalue
. -
contains
-
size
public int size()Description copied from interface:Headers
Returns the number of headers in this object. -
isEmpty
public boolean isEmpty()Description copied from interface:Headers
-
names
Description copied from interface:Headers
-
add
Description copied from interface:Headers
Adds a new header with the specifiedname
andvalue
. -
add
Description copied from interface:Headers
Adds new headers with the specifiedname
andvalues
. This method is semantically equivalent tofor (T value : values) { headers.add(name, value); }
-
add
Description copied from interface:Headers
Adds new headers with the specifiedname
andvalues
. This method is semantically equivalent tofor (T value : values) { headers.add(name, value); }
-
addObject
Description copied from interface:Headers
Adds a new header. Before thevalue
is added, it's converted to typeT
. -
addObject
Description copied from interface:Headers
Adds a new header with the specified name and values. This method is equivalent tofor (Object v : values) { headers.addObject(name, v); }
-
addObject
Description copied from interface:Headers
Adds a new header with the specified name and values. This method is equivalent tofor (Object v : values) { headers.addObject(name, v); }
-
addInt
Description copied from interface:Headers
Adds a new header. -
addLong
Description copied from interface:Headers
Adds a new header. -
addDouble
Description copied from interface:Headers
Adds a new header. -
addTimeMillis
Description copied from interface:Headers
Adds a new header. -
addChar
Description copied from interface:Headers
Adds a new header. -
addBoolean
Description copied from interface:Headers
Adds a new header. -
addFloat
Description copied from interface:Headers
Adds a new header. -
addByte
Description copied from interface:Headers
Adds a new header. -
addShort
Description copied from interface:Headers
Adds a new header. -
add
Description copied from interface:Headers
Adds all header names and values ofheaders
to this object. -
addImpl
-
set
Description copied from interface:Headers
Sets a header with the specified name and value. Any existing headers with the same name are overwritten. -
set
Description copied from interface:Headers
Sets a new header with the specified name and values. This method is equivalent tofor (T v : values) { headers.addObject(name, v); }
-
set
Description copied from interface:Headers
Sets a header with the specified name and values. Any existing headers with this name are removed. This method is equivalent to:headers.remove(name); for (T v : values) { headers.add(name, v); }
-
setObject
Description copied from interface:Headers
Sets a new header. Any existing headers with this name are removed. Before thevalue
is add, it's converted to typeT
. -
setObject
Description copied from interface:Headers
Sets a header with the specified name and values. Any existing headers with this name are removed. This method is equivalent to:headers.remove(name); for (Object v : values) { headers.addObject(name, v); }
-
setObject
Description copied from interface:Headers
Sets a header with the specified name and values. Any existing headers with this name are removed. This method is equivalent to:headers.remove(name); for (Object v : values) { headers.addObject(name, v); }
-
setInt
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
. -
setLong
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
. -
setDouble
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
. -
setTimeMillis
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
. -
setFloat
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
. -
setChar
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
. -
setBoolean
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
. -
setByte
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
. -
setShort
Description copied from interface:Headers
Set thename
tovalue
. This will remove all previous values associated withname
. -
set
Description copied from interface:Headers
Clears the current header entries and copies all header entries of the specifiedheaders
. -
setAll
Description copied from interface:Headers
Retains all current headers but callsHeaders.set(K, V)
for each entry inheaders
. -
remove
Description copied from interface:Headers
Removes all headers with the specifiedname
. -
clear
Description copied from interface:Headers
Removes all headers. After a call to this methodHeaders.size()
equals0
. -
iterator
-
getBoolean
Description copied from interface:Headers
Returns theboolean
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getBoolean
Description copied from interface:Headers
Returns theboolean
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.- Specified by:
getBoolean
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
boolean
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted toboolean
.
-
getByte
Description copied from interface:Headers
Returns thebyte
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getByte
Description copied from interface:Headers
Returns thebyte
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getChar
Description copied from interface:Headers
Returns thechar
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getChar
Description copied from interface:Headers
Returns thechar
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getShort
Description copied from interface:Headers
Returns theshort
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getShort
Description copied from interface:Headers
Returns theshort
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.- Specified by:
getShort
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
short
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted toshort
.
-
getInt
Description copied from interface:Headers
Returns theint
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getInt
Description copied from interface:Headers
Returns theint
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getLong
Description copied from interface:Headers
Returns thelong
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getLong
Description copied from interface:Headers
Returns thelong
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getFloat
Description copied from interface:Headers
Returns thefloat
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getFloat
Description copied from interface:Headers
Returns thefloat
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.- Specified by:
getFloat
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
float
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tofloat
.
-
getDouble
Description copied from interface:Headers
Returns thedouble
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned. -
getDouble
Description copied from interface:Headers
Returns thedouble
value of a header with the specified name. If there is more than one value for the specified name, the first value in insertion order is returned.- Specified by:
getDouble
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the
double
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted todouble
.
-
getTimeMillis
Description copied from interface:Headers
Returns the value of a header with the specified name in milliseconds. If there is more than one value for the specified name, the first value in insertion order is returned. -
getTimeMillis
Description copied from interface:Headers
Returns the value of a header with the specified name in milliseconds. If there is more than one value for the specified name, the first value in insertion order is returned.- Specified by:
getTimeMillis
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the milliseconds value of the first value in insertion order or
defaultValue
if there is no such value or it can't be converted to milliseconds.
-
getBooleanAndRemove
Description copied from interface:Headers
Returns theboolean
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed. -
getBooleanAndRemove
Description copied from interface:Headers
Returns theboolean
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getBooleanAndRemove
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
boolean
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted toboolean
.
-
getByteAndRemove
Description copied from interface:Headers
Returns thebyte
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed. -
getByteAndRemove
Description copied from interface:Headers
Returns thebyte
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getByteAndRemove
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
byte
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tobyte
.
-
getCharAndRemove
Description copied from interface:Headers
Returns thechar
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed. -
getCharAndRemove
Description copied from interface:Headers
Returns thechar
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getCharAndRemove
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
char
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tochar
.
-
getShortAndRemove
Description copied from interface:Headers
Returns theshort
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed. -
getShortAndRemove
Description copied from interface:Headers
Returns theshort
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getShortAndRemove
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
short
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted toshort
.
-
getIntAndRemove
Description copied from interface:Headers
Returns theint
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed. -
getIntAndRemove
Description copied from interface:Headers
Returns theint
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getIntAndRemove
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
int
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted toint
.
-
getLongAndRemove
Description copied from interface:Headers
Returns thelong
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed. -
getLongAndRemove
Description copied from interface:Headers
Returns thelong
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getLongAndRemove
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
long
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tolong
.
-
getFloatAndRemove
Description copied from interface:Headers
Returns thefloat
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed. -
getFloatAndRemove
Description copied from interface:Headers
Returns thefloat
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getFloatAndRemove
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
float
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted tofloat
.
-
getDoubleAndRemove
Description copied from interface:Headers
Returns thedouble
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed. -
getDoubleAndRemove
Description copied from interface:Headers
Returns thedouble
value of a header with the specifiedname
and removes the header from this object. If there is more than one value for the specified name, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getDoubleAndRemove
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to searchdefaultValue
- the default value- Returns:
- the
double
value of the first value in insertion order ordefaultValue
if there is no such value or it can't be converted todouble
.
-
getTimeMillisAndRemove
Description copied from interface:Headers
Returns the value of a header with the specifiedname
in milliseconds and removes the header from this object. If there is more than one value for the specifiedname
, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed. -
getTimeMillisAndRemove
Description copied from interface:Headers
Returns the value of a header with the specifiedname
in milliseconds and removes the header from this object. If there is more than one value for the specifiedname
, the first value in insertion order is returned. In any case all values forname
are removed.If an exception occurs during the translation from type
T
all entries withname
may still be removed.- Specified by:
getTimeMillisAndRemove
in interfaceHeaders<K,
V, T extends Headers<K, V, T>> - Parameters:
name
- the name of the header to retrievedefaultValue
- the default value- Returns:
- the milliseconds value of the first value in insertion order or
defaultValue
if there is no such value or it can't be converted to milliseconds.
-
equals
-
hashCode
public int hashCode() -
equals
Test this object for equality againsth2
.- Parameters:
h2
- The object to check equality for.valueHashingStrategy
- Defines how values will be compared for equality.- Returns:
true
if this object equalsh2
givenvalueHashingStrategy
.false
otherwise.
-
hashCode
Generate a hash code for this object given aHashingStrategy
to generate hash codes for individual values.- Parameters:
valueHashingStrategy
- Defines how values will be hashed.
-
toString
-
validateName
Call out to the givenDefaultHeaders.NameValidator
to validate the given name.- Parameters:
validator
- the validator to useforAdd
-true
if this validation is for adding to the headers, orfalse
if this is for setting (overwriting) the given header.name
- the name to validate.
-
validateValue
-
newHeaderEntry
protected DefaultHeaders.HeaderEntry<K,V> newHeaderEntry(int h, K name, V value, DefaultHeaders.HeaderEntry<K, V> next) -
valueConverter
-
nameValidator
-
valueValidator
-
index
private int index(int hash) -
add0
-
remove0
- Returns:
- the first value inserted whose hash code equals
h
and whose name is equal toname
.
-
remove0
DefaultHeaders.HeaderEntry<K,V> remove0(DefaultHeaders.HeaderEntry<K, V> entry, DefaultHeaders.HeaderEntry<K, V> previous) -
thisT
-
fromObject
-
fromBoolean
-
fromByte
-
fromChar
-
fromShort
-
fromInt
-
fromLong
-
fromFloat
-
fromDouble
-
fromTimeMillis
-
toBoolean
-
toByte
-
toChar
-
toShort
-
toInt
-
toLong
-
toFloat
-
toDouble
-
toTimeMillis
-
copy
Returns a deep copy of this instance.
-