public abstract class HttpMessage extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
HttpMessage.HeaderWriter |
Modifier and Type | Field and Description |
---|---|
static String |
__HTTP_0_9 |
static String |
__HTTP_1_0 |
static String |
__HTTP_1_1 |
static String |
__HTTP_1_X |
static int |
__MSG_BAD
Message States.
|
static int |
__MSG_EDITABLE
Message States.
|
static int |
__MSG_RECEIVED
Message States.
|
static int |
__MSG_SENDING
Message States.
|
static int |
__MSG_SENT
Message States.
|
static String |
__SCHEME |
static String |
__SSL_SCHEME |
static String[] |
__state |
protected Map |
_attributes |
protected String |
_characterEncoding |
protected HttpConnection |
_connection |
protected int |
_dotVersion |
protected HttpFields |
_header |
protected String |
_mimeType |
protected int |
_state |
protected String |
_version |
protected Object |
_wrapper |
Modifier | Constructor and Description |
---|---|
protected |
HttpMessage()
Constructor.
|
protected |
HttpMessage(HttpConnection connection)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addDateField(String name,
Date date)
Adds the value of a date field.
|
void |
addDateField(String name,
long date)
Add the value of a date field.
|
void |
addField(String name,
String value)
Add to a multi-value field value.
|
void |
addIntField(String name,
int value)
Adds the value of an integer field.
|
boolean |
containsField(String name)
Does the header or trailer contain a field?
|
void |
destroy()
Destroy the message.
|
Object |
getAttribute(String name)
Get a request attribute.
|
Enumeration |
getAttributeNames()
Get Attribute names.
|
String |
getCharacterEncoding()
Character Encoding.
|
int |
getContentLength() |
String |
getContentType() |
long |
getDateField(String name)
Get a header as a date value.
|
int |
getDotVersion()
Get the protocol version.
|
String |
getField(String name)
Get a message field.
|
Enumeration |
getFieldNames()
Get field names.
|
Enumeration |
getFieldValues(String name)
Get a multi valued message field.
|
Enumeration |
getFieldValues(String name,
String separators)
Get a multi valued message field.
|
HttpFields |
getHeader()
Get the HTTP header fields.
|
HttpConnection |
getHttpConnection() |
InputStream |
getInputStream() |
int |
getIntField(String name)
Get a field as an integer value.
|
String |
getMimeType()
Mime Type.
|
OutputStream |
getOutputStream() |
int |
getState()
Get the message state.
|
String |
getVersion()
Get the protocol version.
|
Object |
getWrapper()
Get an associated wrapper object.
|
boolean |
isCommitted() |
boolean |
isDirty() |
void |
removeAttribute(String name)
Remove a request attribute.
|
String |
removeField(String name)
Remove a field.
|
protected void |
reset() |
Object |
setAttribute(String name,
Object attribute)
Set a request attribute.
|
void |
setCharacterEncoding(String encoding,
boolean setField)
Set Character Encoding.
|
void |
setContentLength(int len) |
void |
setContentType(String contentType) |
void |
setDateField(String name,
Date date)
Sets the value of a date field.
|
void |
setDateField(String name,
long date)
Sets the value of a date field.
|
void |
setField(String name,
List value)
Set a multi-value field value.
|
String |
setField(String name,
String value)
Set a field value.
|
void |
setIntField(String name,
int value)
Sets the value of an integer field.
|
int |
setState(int state)
Set the message state.
|
void |
setVersion(String version)
Set the request version
|
void |
setWrapper(Object wrapper)
Set a wrapper object.
|
String |
toString()
Convert to String.
|
void |
updateMimeType() |
public static final String __SCHEME
public static final String __SSL_SCHEME
public static final String __HTTP_0_9
public static final String __HTTP_1_0
public static final String __HTTP_1_1
public static final String __HTTP_1_X
public static final int __MSG_EDITABLE
public static final int __MSG_BAD
public static final int __MSG_RECEIVED
public static final int __MSG_SENDING
public static final int __MSG_SENT
public static final String[] __state
protected int _state
protected String _version
protected int _dotVersion
protected HttpFields _header
protected HttpConnection _connection
protected String _characterEncoding
protected String _mimeType
protected Object _wrapper
protected Map _attributes
protected HttpMessage()
protected HttpMessage(HttpConnection connection)
public void setWrapper(Object wrapper)
public Object getWrapper()
protected void reset()
public HttpConnection getHttpConnection()
public InputStream getInputStream()
public OutputStream getOutputStream()
public int getState()
__MSG_EDITABLE = 0 - Created locally, all set methods enabled __MSG_BAD = 1 - Bad message or send failure. __MSG_RECEIVED = 2 - Received from connection. __MSG_SENDING = 3 - Headers sent. __MSG_SENT = 4 - Entity and trailers sent.
public int setState(int state)
state
- The new statepublic String getVersion()
public int getDotVersion()
public Enumeration getFieldNames()
public boolean containsField(String name)
name
- Name of the fieldpublic String getField(String name)
name
- The field namepublic Enumeration getFieldValues(String name)
name
- The field namepublic Enumeration getFieldValues(String name, String separators)
name
- The field nameseparators
- String of separators.public String setField(String name, String value)
name
- Name of fieldvalue
- New value of fieldpublic void setField(String name, List value)
name
- Name of fieldvalue
- New values of fieldpublic void addField(String name, String value) throws IllegalStateException
name
- Name of fieldvalue
- New value to add to the fieldIllegalStateException
- Not editable or sending 1.1
with trailerspublic int getIntField(String name)
name
- the case-insensitive field namepublic void setIntField(String name, int value)
name
- the field namevalue
- the field integer valuepublic void addIntField(String name, int value)
name
- the field namevalue
- the field integer valuepublic long getDateField(String name)
name
- the case-insensitive field namepublic void setDateField(String name, Date date)
name
- the field namedate
- the field date valuepublic void addDateField(String name, Date date)
name
- the field namedate
- the field date valuepublic void setDateField(String name, long date)
name
- the field namedate
- the field date valuepublic void addDateField(String name, long date)
name
- the field namedate
- the field date valueIllegalStateException
- Not editable or sending 1.1
with trailerspublic String removeField(String name) throws IllegalStateException
name
- Name of fieldIllegalStateException
public void setVersion(String version)
version
- the HTTP version string (eg HTTP/1.1)IllegalStateException
- message is not EDITABLEpublic HttpFields getHeader()
public int getContentLength()
public void setContentLength(int len)
public String getCharacterEncoding()
public void setCharacterEncoding(String encoding, boolean setField)
encoding
- An encoding that can override the encoding set
from the ContentType field.public String getContentType()
public void setContentType(String contentType)
public void updateMimeType()
public String getMimeType()
public void destroy()
public String toString()
public boolean isCommitted()
public boolean isDirty()
public Object getAttribute(String name)
name
- Attribute namepublic Object setAttribute(String name, Object attribute)
name
- Attribute nameattribute
- Attribute valuepublic Enumeration getAttributeNames()
public void removeAttribute(String name)
name
- Attribute nameCopyright © 2013. All Rights Reserved.