@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.ValuesEMPTY_HEADERS| 构造器和说明 |
|---|
ReadOnlyHttpHeaders(boolean validateHeaders,
java.lang.CharSequence... nameValuePairs)
Create a new instance.
|
| 限定符和类型 | 方法和说明 |
|---|---|
HttpHeaders |
add(java.lang.String name,
java.lang.Iterable<?> values) |
HttpHeaders |
add(java.lang.String name,
java.lang.Object value) |
HttpHeaders |
addInt(java.lang.CharSequence name,
int value)
Add the
name to value. |
HttpHeaders |
addShort(java.lang.CharSequence name,
short value)
Add the
name to value. |
HttpHeaders |
clear()
Removes all headers from this
HttpMessage. |
boolean |
contains(java.lang.String name) |
boolean |
contains(java.lang.String name,
java.lang.String value,
boolean ignoreCase) |
boolean |
containsValue(java.lang.CharSequence name,
java.lang.CharSequence value,
boolean ignoreCase)
Returns
true if a header with the name and value exists, false otherwise. |
java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> |
entries()
Returns a new
List that contains all headers in this object. |
java.lang.String |
get(java.lang.String name) |
java.util.List<java.lang.String> |
getAll(java.lang.String name) |
java.lang.Integer |
getInt(java.lang.CharSequence name)
Returns the integer value of a header with the specified name.
|
int |
getInt(java.lang.CharSequence name,
int defaultValue)
Returns the integer value of a header with the specified name.
|
java.lang.Short |
getShort(java.lang.CharSequence name)
Returns the short value of a header with the specified name.
|
short |
getShort(java.lang.CharSequence name,
short defaultValue)
Returns the short value of a header with the specified name.
|
java.lang.Long |
getTimeMillis(java.lang.CharSequence name)
Returns the date value of a header with the specified name.
|
long |
getTimeMillis(java.lang.CharSequence name,
long defaultValue)
Returns the date value of a header with the specified name.
|
boolean |
isEmpty()
Checks if no header exists.
|
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> |
iterator() |
java.util.Iterator<java.util.Map.Entry<java.lang.CharSequence,java.lang.CharSequence>> |
iteratorCharSequence() |
java.util.Set<java.lang.String> |
names()
Returns a new
Set that contains the names of all headers in this object. |
HttpHeaders |
remove(java.lang.String name) |
HttpHeaders |
set(java.lang.String name,
java.lang.Iterable<?> values) |
HttpHeaders |
set(java.lang.String name,
java.lang.Object value) |
HttpHeaders |
setInt(java.lang.CharSequence name,
int value)
Set the
name to value. |
HttpHeaders |
setShort(java.lang.CharSequence name,
short value)
Set the
name to value. |
int |
size()
Returns the number of headers in this object.
|
java.util.Iterator<java.lang.CharSequence> |
valueCharSequenceIterator(java.lang.CharSequence name)
Equivalent to
HttpHeaders.getAll(String) but it is possible that no intermediate list is generated. |
java.util.Iterator<java.lang.String> |
valueStringIterator(java.lang.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, toStringpublic ReadOnlyHttpHeaders(boolean validateHeaders,
java.lang.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 java.lang.String get(java.lang.String name)
get 在类中 HttpHeadersHttpHeaders.get(CharSequence)public java.lang.Integer getInt(java.lang.CharSequence name)
HttpHeadersgetInt 在类中 HttpHeadersname - the name of the header to searchnull if there's no
such header or its value is not an integer.public int getInt(java.lang.CharSequence name,
int defaultValue)
HttpHeadersgetInt 在类中 HttpHeadersname - the name of the header to searchdefaultValue - the default valuedefaultValue if
there's no such header or its value is not an integer.public java.lang.Short getShort(java.lang.CharSequence name)
HttpHeadersgetShort 在类中 HttpHeadersname - the name of the header to searchnull if there's no
such header or its value is not a short.public short getShort(java.lang.CharSequence name,
short defaultValue)
HttpHeadersgetShort 在类中 HttpHeadersname - the name of the header to searchdefaultValue - the default valuedefaultValue if
there's no such header or its value is not a short.public java.lang.Long getTimeMillis(java.lang.CharSequence name)
HttpHeadersgetTimeMillis 在类中 HttpHeadersname - the name of the header to searchnull if there's no
such header or its value is not a date.public long getTimeMillis(java.lang.CharSequence name,
long defaultValue)
HttpHeadersgetTimeMillis 在类中 HttpHeadersname - the name of the header to searchdefaultValue - the default valuedefaultValue if
there's no such header or its value is not a date.public java.util.List<java.lang.String> getAll(java.lang.String name)
getAll 在类中 HttpHeadersHttpHeaders.getAll(CharSequence)public java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> entries()
HttpHeadersList 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 在类中 HttpHeadersHttpHeaders.iteratorCharSequence()public boolean contains(java.lang.String name)
contains 在类中 HttpHeadersHttpHeaders.contains(CharSequence)public boolean contains(java.lang.String name,
java.lang.String value,
boolean ignoreCase)
public boolean containsValue(java.lang.CharSequence name,
java.lang.CharSequence value,
boolean ignoreCase)
HttpHeaderstrue 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 在类中 HttpHeadersname - 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 java.util.Iterator<java.lang.String> valueStringIterator(java.lang.CharSequence name)
HttpHeadersHttpHeaders.getAll(String) but it is possible that no intermediate list is generated.valueStringIterator 在类中 HttpHeadersname - the name of the header to retrieveIterator of header values corresponding to name.public java.util.Iterator<java.lang.CharSequence> valueCharSequenceIterator(java.lang.CharSequence name)
HttpHeadersHttpHeaders.getAll(String) but it is possible that no intermediate list is generated.valueCharSequenceIterator 在类中 HttpHeadersname - the name of the header to retrieveIterator of header values corresponding to name.public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> iterator()
iterator 在接口中 java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>>iterator 在类中 HttpHeaderspublic java.util.Iterator<java.util.Map.Entry<java.lang.CharSequence,java.lang.CharSequence>> iteratorCharSequence()
iteratorCharSequence 在类中 HttpHeaderspublic boolean isEmpty()
HttpHeadersisEmpty 在类中 HttpHeaderspublic int size()
HttpHeaderssize 在类中 HttpHeaderspublic java.util.Set<java.lang.String> names()
HttpHeadersSet 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 在类中 HttpHeaderspublic HttpHeaders add(java.lang.String name, java.lang.Object value)
add 在类中 HttpHeadersHttpHeaders.add(CharSequence, Object)public HttpHeaders add(java.lang.String name, java.lang.Iterable<?> values)
add 在类中 HttpHeadersHttpHeaders.add(CharSequence, Iterable)public HttpHeaders addInt(java.lang.CharSequence name, int value)
HttpHeadersname to value.addInt 在类中 HttpHeadersname - The name to modifyvalue - The valuethispublic HttpHeaders addShort(java.lang.CharSequence name, short value)
HttpHeadersname to value.addShort 在类中 HttpHeadersname - The name to modifyvalue - The valuethispublic HttpHeaders set(java.lang.String name, java.lang.Object value)
set 在类中 HttpHeadersHttpHeaders.set(CharSequence, Object)public HttpHeaders set(java.lang.String name, java.lang.Iterable<?> values)
set 在类中 HttpHeadersHttpHeaders.set(CharSequence, Iterable)public HttpHeaders setInt(java.lang.CharSequence name, int value)
HttpHeadersname to value. This will remove all previous values associated with name.setInt 在类中 HttpHeadersname - The name to modifyvalue - The valuethispublic HttpHeaders setShort(java.lang.CharSequence name, short value)
HttpHeadersname to value. This will remove all previous values associated with name.setShort 在类中 HttpHeadersname - The name to modifyvalue - The valuethispublic HttpHeaders remove(java.lang.String name)
remove 在类中 HttpHeadersHttpHeaders.remove(CharSequence)public HttpHeaders clear()
HttpHeadersHttpMessage.clear 在类中 HttpHeadersthis