|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Message
An abstract base class for HTTP messages (i.e. Request and Response) with support for header and entity management.
| Method Summary | |
|---|---|
java.lang.String |
getContentCharset()
Returns the currently set content charset value, if any. |
java.lang.String |
getContentType()
Returns the IANA media type, minus charset information, for the current entity, if any. |
java.lang.String |
getEntity()
Returns the current entity in String form, if available, converting the underlying
entity stream to a string using the currently set content charset, or defaulting to the HTTP
standard of "ISO-8859-1" if no content charset has been specified. |
java.io.InputStream |
getEntityStream()
Returns the current entity as an input stream, or null if not set. |
java.lang.String |
getHeader(java.lang.String name)
Returns the specified header by name. |
java.util.Map<java.lang.String,java.lang.String> |
getHeaders()
Returns a map of all headers that have been set on this object. |
boolean |
hasEntity()
Returns whether or not an entity has been set on this object. |
boolean |
hasReadEntity()
Returns whether or not the current entity property, if any, has been read from this object. |
boolean |
isFrozen()
Returns whether or not this object has been made immutable. |
Message |
setContentCharset(java.lang.String contentCharset)
Sets the charset for this object's entity, if any. |
Message |
setContentType(java.lang.String contentType)
Sets the IANA media type, for the current entity, if any. |
Message |
setEntity(java.lang.String entity)
Sets this object's entity stream from a string. |
Message |
setEntityStream(java.io.InputStream entityStream)
Sets this object's entity as an input stream. |
Message |
setEntityStream(java.io.InputStream entityStream,
java.lang.String charset)
Sets this object's entity as an input stream, encoded with the specified charset. |
Message |
setHeader(java.lang.String name,
java.lang.String value)
Sets an HTTP header on this object. |
Message |
setHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
Copies the specified map of HTTP headers into this object. |
| Method Detail |
|---|
java.lang.String getContentType()
getContentCharset(). To get the full
Content-Type header value including charset if specified, use getHeader("Content-Type").
Message setContentType(java.lang.String contentType)
contentType argument
also contains charset information, this method will have the side effect of parsing the charset
out and storing the component parts independently. The method getContentCharset() can
be used to retrieve extracted content charset, if present, and getHeader("Content-Type")
can be used to retrieve the entire Content-Type header, complete with charset information, if set.
The content type property is required when an entity is present.
contentType - An IANA media type with optional charset information
java.lang.String getContentCharset()
Message setContentCharset(java.lang.String contentCharset)
contentCharset - The entity's charset value, or null
java.io.InputStream getEntityStream()
throws java.lang.IllegalStateException
hasEntity()
to check if this message has an entity value.
java.lang.IllegalStateException - If the non-null entity has already been accessed once, through
any accessor for this objectMessage setEntityStream(java.io.InputStream entityStream)
hasReadEntity() state to false. It is recommended to also set this
object's content charset property when setting an entity stream for a textual media type (or
using the overloaded form that takes both the entity stream and charset in the same call).
Clients of this object should assume the HTTP standard of ISO-8859-1 (latin-1)
for the content charset property if a textual media type is set but no explcit charset was
provided for this message. A charset should NOT be provided for entity streams targetting
binary media types.
entityStream - An entity input stream ready to be read
Message setEntityStream(java.io.InputStream entityStream,
java.lang.String charset)
hasReadEntity() state to false. This
method should only be called for entity streams targetting textual media types -- that is, it's
nonsensical to set the charset of an entity stream for binary media types (e.g. image/*, etc).
entityStream - An entity input stream ready to be readcharset - The charset in which the entity stream is encoded
java.lang.String getEntity()
throws java.lang.IllegalStateException,
java.lang.IllegalArgumentException
String form, if available, converting the underlying
entity stream to a string using the currently set content charset, or defaulting to the HTTP
standard of "ISO-8859-1" if no content charset has been specified.
java.lang.IllegalStateException - If the non-null entity has already been accessed once, through
any accessor for this object. Also thrown if underlying body cannot be converted into a String
java.lang.IllegalArgumentException - If the entity exceeds the maximum sizeMessage setEntity(java.lang.String entity)
entity - An entity string
boolean hasEntity()
hasReadEntity() state.
boolean hasReadEntity()
IllegalStateException being thrown.
java.util.Map<java.lang.String,java.lang.String> getHeaders()
Message setHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
headers - A map of HTTP headers
java.lang.String getHeader(java.lang.String name)
name - The name of the header to fetch
Message setHeader(java.lang.String name,
java.lang.String value)
name - The name of the header to be setvalue - The value of the header to be set
boolean isFrozen()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||