public abstract class AbstractMessageWrapper extends Object implements HttpMessage
HttpMessage
wrapper.Constructor and Description |
---|
AbstractMessageWrapper(HttpMessage 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(HttpMessage message)
public void setVersion(ProtocolVersion version)
HttpMessage
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.
setVersion
in interface HttpMessage
public ProtocolVersion getVersion()
HttpMessage
null
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 HttpMessage
public void addHeader(Header header)
HttpMessage
addHeader
in interface HttpMessage
header
- the header to append.public void addHeader(String name, Object value)
HttpMessage
addHeader
in interface HttpMessage
name
- the name of the header.value
- the value of the header, taken as the value's Object.toString()
.public void setHeader(Header header)
HttpMessage
setHeader
in interface HttpMessage
header
- the header to set.public void setHeader(String name, Object value)
HttpMessage
setHeader
in interface HttpMessage
name
- the name of the header.value
- the value of the header, taken as the value's Object.toString()
.public void setHeaders(Header... headers)
HttpMessage
setHeaders
in interface HttpMessage
headers
- the array of headers to set.public boolean removeHeader(Header header)
HttpMessage
removeHeader
in interface HttpMessage
header
- the header to remove.true
if a header was removed as a result of this call.public boolean removeHeaders(String name)
HttpMessage
removeHeaders
in interface HttpMessage
name
- The name of the headers to remove.true
if any header was removed as a result of this call.public boolean containsHeader(String name)
MessageHeaders
containsHeader
in interface MessageHeaders
name
- the header name to check for.public int countHeaders(String name)
MessageHeaders
countHeaders
in interface MessageHeaders
name
- the header name to check for.public Header[] getHeaders(String name)
MessageHeaders
getHeaders
in interface MessageHeaders
name
- the name of the headers to return.name
.public Header getHeader(String name) throws ProtocolException
MessageHeaders
Header name comparison is case insensitive.
getHeader
in interface MessageHeaders
name
- the name of the header to getnull
ProtocolException
- in case multiple headers with the given name are found.public Header getFirstHeader(String name)
MessageHeaders
MessageHeaders.getHeaders(String)
is returned.
If there is no matching header in the message null
is
returned.getFirstHeader
in interface MessageHeaders
name
- the name of the header to return.name
or null
if no such header could be found.public Header getLastHeader(String name)
MessageHeaders
MessageHeaders.getHeaders(String)
is returned. If there is no
matching header in the message null
is returned.getLastHeader
in interface MessageHeaders
name
- the name of the header to return.name
.
or null
if no such header could be found.public Header[] getHeaders()
MessageHeaders
getHeaders
in interface MessageHeaders
public Iterator<Header> headerIterator()
MessageHeaders
headerIterator
in interface MessageHeaders
public Iterator<Header> headerIterator(String name)
MessageHeaders
headerIterator
in interface MessageHeaders
name
- the name of the headers over which to iterate, or
null
for all headersCopyright © 2005–2021 The Apache Software Foundation. All rights reserved.