T - A HttpMessage type.public abstract class AbstractMessageWrapper<T extends HttpMessage> extends Object implements HttpMessage
HttpMessage wrapper.| Constructor and Description |
|---|
AbstractMessageWrapper(T message) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(Header header)
Adds a header to this message.
|
void |
addHeader(String name,
Object value)
Adds a header to this message.
|
boolean |
containsHeader(String name)
Checks if a certain header is present in this message.
|
int |
countHeaders(String name)
Checks if a certain header is present in this message and how many times.
|
Header |
getFirstHeader(String name)
Returns the first header with a specified name of this message.
|
Header |
getHeader(String name)
Gets single first header with the given name.
|
Header[] |
getHeaders()
Returns all the headers of this message.
|
Header[] |
getHeaders(String name)
Returns all the headers with a specified name of this message.
|
Header |
getLastHeader(String name)
Returns the last header with a specified name of this message.
|
ProtocolVersion |
getVersion()
Returns protocol version or
null when not available. |
Iterator<Header> |
headerIterator()
Returns an iterator of all the headers.
|
Iterator<Header> |
headerIterator(String name)
Returns an iterator of the headers with a given name.
|
boolean |
removeHeader(Header header)
Removes a header from this message.
|
boolean |
removeHeaders(String name)
Removes all headers with a certain name from this message.
|
void |
setHeader(Header header)
Overwrites the first header with the same name.
|
void |
setHeader(String name,
Object value)
Overwrites the first header with the same name.
|
void |
setHeaders(Header... headers)
Overwrites all the headers in the message.
|
void |
setVersion(ProtocolVersion version)
Sets protocol version.
|
String |
toString() |
public AbstractMessageWrapper(T message)
public void setVersion(ProtocolVersion version)
HttpMessageFor incoming messages it represents protocol version this message was transmitted with. For outgoing messages it represents a hint what protocol version should be used to transmit the message.
setVersion in interface HttpMessageversion - The protocol version.public ProtocolVersion getVersion()
HttpMessagenull when not available.
For incoming messages it represents protocol version this message was transmitted with. For outgoing messages it represents a hint what protocol version should be used to transmit the message.
getVersion in interface HttpMessagepublic void addHeader(Header header)
HttpMessageaddHeader in interface HttpMessageheader - the header to append.public void addHeader(String name, Object value)
HttpMessageaddHeader in interface HttpMessagename - the name of the header.value - the value of the header, taken as the value's Object.toString().public void setHeader(Header header)
HttpMessagesetHeader in interface HttpMessageheader - the header to set.public void setHeader(String name, Object value)
HttpMessagesetHeader in interface HttpMessagename - the name of the header.value - the value of the header, taken as the value's Object.toString().public void setHeaders(Header... headers)
HttpMessagesetHeaders in interface HttpMessageheaders - the array of headers to set.public boolean removeHeader(Header header)
HttpMessageremoveHeader in interface HttpMessageheader - the header to remove.true if a header was removed as a result of this call.public boolean removeHeaders(String name)
HttpMessageremoveHeaders in interface HttpMessagename - The name of the headers to remove.true if any header was removed as a result of this call.public boolean containsHeader(String name)
MessageHeaderscontainsHeader in interface MessageHeadersname - the header name to check for.public int countHeaders(String name)
MessageHeaderscountHeaders in interface MessageHeadersname - the header name to check for.public Header[] getHeaders(String name)
MessageHeadersgetHeaders in interface MessageHeadersname - the name of the headers to return.name.public Header getHeader(String name) throws ProtocolException
MessageHeadersHeader name comparison is case insensitive.
getHeader in interface MessageHeadersname - the name of the header to getnullProtocolException - in case multiple headers with the given name are found.public Header getFirstHeader(String name)
MessageHeadersMessageHeaders.getHeaders(String) is returned.
If there is no matching header in the message null is
returned.getFirstHeader in interface MessageHeadersname - the name of the header to return.name
or null if no such header could be found.public Header getLastHeader(String name)
MessageHeadersMessageHeaders.getHeaders(String) is returned. If there is no
matching header in the message null is returned.getLastHeader in interface MessageHeadersname - the name of the header to return.name.
or null if no such header could be found.public Header[] getHeaders()
MessageHeadersgetHeaders in interface MessageHeaderspublic Iterator<Header> headerIterator()
MessageHeadersheaderIterator in interface MessageHeaderspublic Iterator<Header> headerIterator(String name)
MessageHeadersheaderIterator in interface MessageHeadersname - the name of the headers over which to iterate, or
null for all headersCopyright © 2005–2021 The Apache Software Foundation. All rights reserved.