com.xml_project.morganaxproc.filesystem
Class HttpBody

java.lang.Object
  extended by com.xml_project.morganaxproc.filesystem.HttpBody

public final class HttpBody
extends java.lang.Object

This class represents the http body of either an XProcHttpRequest or an XProcHttpResponse.


Constructor Summary
HttpBody(java.lang.String contentType, boolean fixContentType)
          Create a new HttpBody with the given content type.
 
Method Summary
 byte[] getContent()
          Return the content of this body as byte[].
 nu.xom.Document getDocument()
          Return document, that is content of this body.
 java.lang.String getHeader(java.lang.String name)
          Return the value of the header with the given name.
 HttpHeader[] getHeaders()
          Returns all headers found in this HttpBody.
 boolean isDocument()
          Checks whether this HttpBody has an XOM document as content.
 void setContent(byte[] content)
          Sets the content of this HttpBody.
 void setContent(nu.xom.Document doc)
          Sets the content of this HttpBody.
 void setHeader(java.lang.String name, java.lang.String value)
          Sets a header with the given name and the given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpBody

public HttpBody(java.lang.String contentType,
                boolean fixContentType)
Create a new HttpBody with the given content type.

Parameters:
contentType - the content type
fixContentType - flags whether the content type is fixed.
Method Detail

setContent

public void setContent(byte[] content)
Sets the content of this HttpBody.

Parameters:
content - the content

setContent

public void setContent(nu.xom.Document doc)
Sets the content of this HttpBody.

Parameters:
doc - a XOM document as content.

isDocument

public boolean isDocument()
Checks whether this HttpBody has an XOM document as content.

Returns:
true if the content is a document, false otherwise.

getContent

public byte[] getContent()
Return the content of this body as byte[]. If the content is a document, it is serialized.

Returns:
the content or null if no content is set.

getDocument

public nu.xom.Document getDocument()
Return document, that is content of this body.

Returns:
the document that is content of this body or null, if no document is found.

getHeader

public java.lang.String getHeader(java.lang.String name)
Return the value of the header with the given name.

Parameters:
name - the header's name.
Returns:
the value of the header with the given name or null, if no header with this name is found.

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Sets a header with the given name and the given value.

Parameters:
name - the header's name.
value - the header's value.

getHeaders

public HttpHeader[] getHeaders()
Returns all headers found in this HttpBody.

Returns:
the headers of this HttpBody.