@UnstableApi public final class ReadOnlyHttpHeaders extends HttpHeaders
HttpHeaders which only supports read-only methods.
Any array passed to this class may be used directly in the underlying data structures of this class. If these arrays may be modified it is the caller's responsibility to supply this class with a copy of the array.
This may be a good alternative to DefaultHttpHeaders if your have a fixed set of headers which will not
change.
HttpHeaders.Names, HttpHeaders.Values EMPTY_HEADERS | Constructor and Description |
|---|
ReadOnlyHttpHeaders (boolean validateHeaders,
CharSequence... nameValuePairs)
Create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
HttpHeaders |
add (String name,
Iterable<?> values) |
HttpHeaders |
add (String name,
Object value) |
HttpHeaders |
addInt (CharSequence name,
int value)
Add the
name to value. |
HttpHeaders |
addShort (CharSequence name,
short value)
Add the
name to value. |
HttpHeaders |
clear ()
Removes all headers from this
HttpMessage. |
boolean |
contains (String name) |
boolean |
contains (String name,
String value,
boolean ignoreCase) |
boolean |
containsValue (CharSequence name,
CharSequence value,
boolean ignoreCase)
Returns
true if a header with the name and value exists, false otherwise. |
List<Map.Entry<String,String>> |
entries ()
Returns a new
List that contains all headers in this object. |
String |
get (String name) |
List<String> |
getAll (String name) |
Integer |
getInt (CharSequence name)
Returns the integer value of a header with the specified name.
|
int |
getInt (CharSequence name,
int defaultValue)
Returns the integer value of a header with the specified name.
|
Short |
getShort (CharSequence name)
Returns the short value of a header with the specified name.
|
short |
getShort (CharSequence name,
short defaultValue)
Returns the short value of a header with the specified name.
|
Long |
getTimeMillis (CharSequence name)
Returns the date value of a header with the specified name.
|
long |
getTimeMillis (CharSequence name,
long defaultValue)
Returns the date value of a header with the specified name.
|
boolean |
isEmpty ()
Checks if no header exists.
|
Iterator<Map.Entry<String,String>> |
iterator () |
Iterator<Map.Entry<CharSequence,CharSequence>> |
iteratorCharSequence () |
Set<String> |
names ()
Returns a new
Set that contains the names of all headers in this object. |
HttpHeaders |
remove (String name) |
HttpHeaders |
set (String name,
Iterable<?> values) |
HttpHeaders |
set (String name,
Object value) |
HttpHeaders |
setInt (CharSequence name,
int value)
Set the
name to value. |
HttpHeaders |
setShort (CharSequence name,
short value)
Set the
name to value. |
int |
size ()
Returns the number of headers in this object.
|
Iterator<CharSequence> |
valueCharSequenceIterator (CharSequence name)
Equivalent to
HttpHeaders.getAll(String) but it is possible that no intermediate list is generated. |
Iterator<String> |
valueStringIterator (CharSequence name)
Equivalent to
HttpHeaders.getAll(String) but it is possible that no intermediate list is generated. |
add, add, add, addDateHeader, addDateHeader, addHeader, addHeader, addIntHeader, addIntHeader, clearHeaders, contains, contains, copy, encodeAscii, equalsIgnoreCase, get, get, getAll, getAllAsString, getAsString, getContentLength, getContentLength, getDate, getDate, getDateHeader, getDateHeader, getDateHeader, getDateHeader, getHeader, getHeader, getHeader, getHeader, getHost, getHost, getIntHeader, getIntHeader, getIntHeader, getIntHeader, is100ContinueExpected, isContentLengthSet, isKeepAlive, isTransferEncodingChunked, iteratorAsString, newEntity, remove, removeHeader, removeHeader, removeTransferEncodingChunked, set, set, set, set100ContinueExpected, set100ContinueExpected, setAll, setContentLength, setDate, setDateHeader, setDateHeader, setDateHeader, setDateHeader, setHeader, setHeader, setHeader, setHeader, setHost, setHost, setIntHeader, setIntHeader, setIntHeader, setIntHeader, setKeepAlive, setTransferEncodingChunked, toString clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait forEach, spliterator public ReadOnlyHttpHeaders(boolean validateHeaders, CharSequence... nameValuePairs)
validateHeaders - true to validate the contents of each header name.nameValuePairs - An array of the structure [<name,value>,<name,value>,...].
A copy will NOT be made of this array. If the contents of this array
may be modified externally you are responsible for passing in a copy.public String get(String name)
get in class HttpHeaders HttpHeaders.get(CharSequence) public Integer getInt(CharSequence name)
HttpHeaders getInt in class HttpHeaders name - the name of the header to searchnull if there's no
such header or its value is not an integer.public int getInt(CharSequence name, int defaultValue)
HttpHeaders getInt in class HttpHeaders name - the name of the header to searchdefaultValue - the default valuedefaultValue if
there's no such header or its value is not an integer.public Short getShort(CharSequence name)
HttpHeaders getShort in class HttpHeaders name - the name of the header to searchnull if there's no
such header or its value is not a short.public short getShort(CharSequence name, short defaultValue)
HttpHeaders getShort in class HttpHeaders name - the name of the header to searchdefaultValue - the default valuedefaultValue if
there's no such header or its value is not a short.public Long getTimeMillis(CharSequence name)
HttpHeaders getTimeMillis in class HttpHeaders name - the name of the header to searchnull if there's no
such header or its value is not a date.public long getTimeMillis(CharSequence name, long defaultValue)
HttpHeaders getTimeMillis in class HttpHeaders name - the name of the header to searchdefaultValue - the default valuedefaultValue if
there's no such header or its value is not a date.public List<String> getAll(String name)
getAll in class HttpHeaders HttpHeaders.getAll(CharSequence) public List<Map.Entry<String,String>> entries()
HttpHeaders List that contains all headers in this object. Note that modifying the
returned List will not affect the state of this object. If you intend to enumerate over the header
entries only, use HttpHeaders.iterator() instead, which has much less overhead.entries in class HttpHeaders HttpHeaders.iteratorCharSequence() public boolean contains(String name)
contains in class HttpHeaders HttpHeaders.contains(CharSequence) public boolean contains(String name, String value, boolean ignoreCase)
contains in class HttpHeaders HttpHeaders.contains(CharSequence, CharSequence, boolean) public boolean containsValue(CharSequence name, CharSequence value, boolean ignoreCase)
HttpHeaders true if a header with the name and value exists, false otherwise.
This also handles multiple values that are separated with a ,.
If ignoreCase is true then a case insensitive compare is done on the value.
containsValue in class HttpHeaders name - the name of the header to findvalue - the value of the header to findignoreCase - true then a case insensitive compare is run to compare values.
otherwise a case sensitive compare is run to compare values.public Iterator<String> valueStringIterator(CharSequence name)
HttpHeaders HttpHeaders.getAll(String) but it is possible that no intermediate list is generated.valueStringIterator in class HttpHeaders name - the name of the header to retrieveIterator of header values corresponding to name.public Iterator<CharSequence> valueCharSequenceIterator(CharSequence name)
HttpHeaders HttpHeaders.getAll(String) but it is possible that no intermediate list is generated.valueCharSequenceIterator in class HttpHeaders name - the name of the header to retrieveIterator of header values corresponding to name.public Iterator<Map.Entry<CharSequence,CharSequence>> iteratorCharSequence()
iteratorCharSequence in class HttpHeaders public boolean isEmpty()
HttpHeaders isEmpty in class HttpHeaders public int size()
HttpHeaders size in class HttpHeaders public Set<String> names()
HttpHeaders Set that contains the names of all headers in this object. Note that modifying the
returned Set will not affect the state of this object. If you intend to enumerate over the header
entries only, use HttpHeaders.iterator() instead, which has much less overhead.names in class HttpHeaders public HttpHeaders add(String name, Object value)
add in class HttpHeaders HttpHeaders.add(CharSequence, Object) public HttpHeaders add(String name, Iterable<?> values)
add in class HttpHeaders HttpHeaders.add(CharSequence, Iterable) public HttpHeaders addInt(CharSequence name, int value)
HttpHeaders name to value.addInt in class HttpHeaders name - The name to modifyvalue - The valuethispublic HttpHeaders addShort(CharSequence name, short value)
HttpHeaders name to value.addShort in class HttpHeaders name - The name to modifyvalue - The valuethispublic HttpHeaders set(String name, Object value)
set in class HttpHeaders HttpHeaders.set(CharSequence, Object) public HttpHeaders set(String name, Iterable<?> values)
set in class HttpHeaders HttpHeaders.set(CharSequence, Iterable) public HttpHeaders setInt(CharSequence name, int value)
HttpHeaders name to value. This will remove all previous values associated with name.setInt in class HttpHeaders name - The name to modifyvalue - The valuethispublic HttpHeaders setShort(CharSequence name, short value)
HttpHeaders name to value. This will remove all previous values associated with name.setShort in class HttpHeaders name - The name to modifyvalue - The valuethispublic HttpHeaders remove(String name)
remove in class HttpHeaders HttpHeaders.remove(CharSequence) public HttpHeaders clear()
HttpHeaders HttpMessage.clear in class HttpHeaders thisCopyright © 2008–2025 The Netty Project. All rights reserved.