org.abstracthorizon.danube.tapestry
Class DanubeResponse

java.lang.Object
  extended by org.abstracthorizon.danube.tapestry.DanubeResponse
All Implemented Interfaces:
WebResponse

public class DanubeResponse
extends Object
implements WebResponse

WebResponse interface implementation.

Author:
Daniel Sendula

Field Summary
protected  HTTPConnection connection
          Reference to connection
protected  boolean needReset
          If true getPrintWriter(ContentType) will reset connection.
 
Constructor Summary
DanubeResponse(HTTPConnection connection)
          Constructor
 
Method Summary
 String encodeURL(String url)
          Encodes url.
 String getNamespace()
          Returns namespace
 OutputStream getOutputStream(ContentType contentType)
          Returns output stream and sets content type
 PrintWriter getPrintWriter(ContentType contentType)
          Returns print writer.
 void reset()
          Resets connection.
 void sendError(int code, String msg)
          Sends error to the client
 void setContentLength(int len)
          Sets content length.
 void setDateHeader(String name, long date)
          Sets date header
 void setHeader(String name, String value)
          Sets header
 void setIntHeader(String name, int i)
          Sets integer header
 void setStatus(int code)
          Sets HTTP status
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection

protected HTTPConnection connection
Reference to connection


needReset

protected boolean needReset
If true getPrintWriter(ContentType) will reset connection.

Constructor Detail

DanubeResponse

public DanubeResponse(HTTPConnection connection)
Constructor

Parameters:
connection - connection
Method Detail

getOutputStream

public OutputStream getOutputStream(ContentType contentType)
                             throws IOException
Returns output stream and sets content type

Specified by:
getOutputStream in interface WebResponse
Parameters:
contentType -
Returns:
output stream
Throws:
IOException

getPrintWriter

public PrintWriter getPrintWriter(ContentType contentType)
                           throws IOException
Returns print writer. It will reset connection (HTTPConnection.reset()) if this method is called second time.

Specified by:
getPrintWriter in interface WebResponse
Throws:
IOException

encodeURL

public String encodeURL(String url)
Encodes url.

Specified by:
encodeURL in interface WebResponse
Parameters:
url - to be encoded
Returns:
encoded url

reset

public void reset()
Resets connection. It calls HTTPConnection.reset().

Specified by:
reset in interface WebResponse

setContentLength

public void setContentLength(int len)
Sets content length. It sets appropriate header.

Specified by:
setContentLength in interface WebResponse
Parameters:
len - content length

getNamespace

public String getNamespace()
Returns namespace

Specified by:
getNamespace in interface WebResponse
Returns:
namespace

setDateHeader

public void setDateHeader(String name,
                          long date)
Sets date header

Specified by:
setDateHeader in interface WebResponse
Parameters:
name - header name
date - date

setHeader

public void setHeader(String name,
                      String value)
Sets header

Specified by:
setHeader in interface WebResponse
Parameters:
name - header name
value - header value

setIntHeader

public void setIntHeader(String name,
                         int i)
Sets integer header

Specified by:
setIntHeader in interface WebResponse
Parameters:
name - header name
i - integer value

setStatus

public void setStatus(int code)
Sets HTTP status

Specified by:
setStatus in interface WebResponse
Parameters:
code - status code

sendError

public void sendError(int code,
                      String msg)
               throws IOException
Sends error to the client

Specified by:
sendError in interface WebResponse
Parameters:
code - error code
msg - error message
Throws:
IOException


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.