com.uwyn.rife.engine
Class AbstractResponse

java.lang.Object
  extended by com.uwyn.rife.engine.AbstractResponse
All Implemented Interfaces:
Response
Direct Known Subclasses:
HttpResponse, MockResponse

public abstract class AbstractResponse
extends Object
implements Response

This abstract class implements parts of the Response interface to provide behaviour that is specific to RIFE.

Additional abstract methods have been provided to integrate with the concrete back-end classes that extend AbstractResponse.

Since:
1.1
Version:
$Revision: 3634 $
Author:
Geert Bevin (gbevin[remove] at uwyn dot com)

Constructor Summary
protected AbstractResponse(Request request, boolean embedded)
          Constructor that needs to be called by all the constructors of the extending classes.
 
Method Summary
protected abstract  String _getCharacterEncoding()
          This method needs to be implemented by the extending back-end class and will be called by AbstractResponse during the RIFE-specific additional behaviour.
protected abstract  OutputStream _getOutputStream()
          This method needs to be implemented by the extending back-end class and will be called by AbstractResponse during the RIFE-specific additional behaviour.
protected abstract  void _sendRedirect(String location)
          This method needs to be implemented by the extending back-end class and will be called by AbstractResponse during the RIFE-specific additional behaviour.
protected abstract  void _setContentLength(int length)
          This method needs to be implemented by the extending back-end class and will be called by AbstractResponse during the RIFE-specific additional behaviour.
protected abstract  void _setContentType(String contentType)
          This method needs to be implemented by the extending back-end class and will be called by AbstractResponse during the RIFE-specific additional behaviour.
 void clearBuffer()
          Clears the text buffer is it's enabled.
 void close()
          Closed the content output stream.
 void enableTextBuffer(boolean enabled)
          Enables or disabled the text output buffer.
 void flush()
          Forces all the streamed content to be output to the client.
 String getCharacterEncoding()
          See ServletResponse.getCharacterEncoding().
 String getContentType()
          Retrieves the content type that was explicitly set for this response.
 ArrayList<CharSequence> getEmbeddedContent()
          Retrieves the content of the response for embedded usage and integration into another response.
 ElementSupport getLastElement()
          Retrieves the last element that has been processed with this response.
 OutputStream getOutputStream()
          See ServletResponse.getOutputStream().
 Request getRequest()
          Retrieves the request that is associated with this response.
 boolean isContentTypeSet()
          Indicates whether this response's content type has been explicitly set.
 boolean isEmbedded()
          Indicates whether this response is embedded into another response.
 boolean isTextBufferEnabled()
          Indicates whether the text output buffer is enabled.
 void print(Collection<CharSequence> deferredContent)
          Prints a list of text snippets to the request text output.
 void print(Object value)
          Prints the string representation of an object to the request text output.
 void print(Template template)
          Prints the content of a template to the request text output.
 void sendRedirect(String location)
          See HttpServletResponse.sendRedirect(String).
 void setContentLength(int length)
          See ServletResponse.setContentLength(int).
 void setContentType(String contentType)
          See ServletResponse.setContentType(String).
 void setLastElement(ElementSupport element)
          Sets the latest target element of this response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.uwyn.rife.engine.Response
addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, createEmbeddedResponse, encodeURL, getHttpServletResponse, getLocale, getWriter, sendError, sendError, setDateHeader, setHeader, setIntHeader, setLocale, setStatus
 

Constructor Detail

AbstractResponse

protected AbstractResponse(Request request,
                           boolean embedded)
Constructor that needs to be called by all the constructors of the extending classes.

Parameters:
request - the Request that is associated with this response
embedded - true if the response is embedded; or

false otherwise

Since:
1.1
Method Detail

_setContentType

protected abstract void _setContentType(String contentType)
This method needs to be implemented by the extending back-end class and will be called by AbstractResponse during the RIFE-specific additional behaviour. It behaves exactly like its counter-part in the Response interface.

Since:
1.1
See Also:
Response.setContentType(String)

_getCharacterEncoding

protected abstract String _getCharacterEncoding()
This method needs to be implemented by the extending back-end class and will be called by AbstractResponse during the RIFE-specific additional behaviour. It behaves exactly like its counter-part in the Response interface.

Since:
1.1
See Also:
Response.getCharacterEncoding()

_setContentLength

protected abstract void _setContentLength(int length)
This method needs to be implemented by the extending back-end class and will be called by AbstractResponse during the RIFE-specific additional behaviour. It behaves exactly like its counter-part in the Response interface.

Since:
1.1
See Also:
Response.setContentLength(int)

_sendRedirect

protected abstract void _sendRedirect(String location)
This method needs to be implemented by the extending back-end class and will be called by AbstractResponse during the RIFE-specific additional behaviour. It behaves exactly like its counter-part in the Response interface.

Since:
1.1
See Also:
Response.sendRedirect(String)

_getOutputStream

protected abstract OutputStream _getOutputStream()
                                          throws IOException
This method needs to be implemented by the extending back-end class and will be called by AbstractResponse during the RIFE-specific additional behaviour. It behaves exactly like its counter-part in the Request interface.

Throws:
IOException
Since:
1.1
See Also:
Response.getOutputStream()

getRequest

public Request getRequest()
Retrieves the request that is associated with this response.

Returns:
the associated request
Since:
1.1

getLastElement

public ElementSupport getLastElement()
Retrieves the last element that has been processed with this response.

Returns:
the last processed element
Since:
1.1

setLastElement

public void setLastElement(ElementSupport element)
Description copied from interface: Response
Sets the latest target element of this response. This method is called repeatedly by the engine to make it possible to trace which elements have been processed.

Specified by:
setLastElement in interface Response
Parameters:
element - an element that has been executed in the context of this response

getEmbeddedContent

public ArrayList<CharSequence> getEmbeddedContent()
Description copied from interface: Response
Retrieves the content of the response for embedded usage and integration into another response.

Specified by:
getEmbeddedContent in interface Response
Returns:
the embedded content; or

null if the response is not embedded.


isEmbedded

public boolean isEmbedded()
Description copied from interface: Response
Indicates whether this response is embedded into another response.

Specified by:
isEmbedded in interface Response
Returns:
true if the response is embedded; or

false otherwise.


isContentTypeSet

public boolean isContentTypeSet()
Description copied from interface: Response
Indicates whether this response's content type has been explicitly set.

Specified by:
isContentTypeSet in interface Response
Returns:
true if it has been set; or

false otherwise

See Also:
Response.setContentType(java.lang.String)

getContentType

public String getContentType()
Description copied from interface: Response
Retrieves the content type that was explicitly set for this response.

Specified by:
getContentType in interface Response
Returns:
the content type as a String; or

null if the content type wasn't set

See Also:
Response.setContentType(java.lang.String)

setContentType

public void setContentType(String contentType)
Description copied from interface: Response
See ServletResponse.setContentType(String).

Specified by:
setContentType in interface Response

enableTextBuffer

public void enableTextBuffer(boolean enabled)
Description copied from interface: Response
Enables or disabled the text output buffer.

The buffer is enabled by default and its buffered contents will be flushed when the buffer is disabled.

Specified by:
enableTextBuffer in interface Response
Parameters:
enabled - true to enable the text buffer; or

false to disable it


isTextBufferEnabled

public boolean isTextBufferEnabled()
Description copied from interface: Response
Indicates whether the text output buffer is enabled.

Specified by:
isTextBufferEnabled in interface Response
Returns:
true when the text buffer is enabled; or

false when it is disabled.


print

public void print(Template template)
           throws EngineException
Description copied from interface: Response
Prints the content of a template to the request text output.

Specified by:
print in interface Response
Parameters:
template - the template that will be printed
Throws:
EngineException - if an error occurs during the output of the template content
See Also:
Response.print(Collection), Response.print(Object)

print

public void print(Collection<CharSequence> deferredContent)
           throws EngineException
Description copied from interface: Response
Prints a list of text snippets to the request text output.

Specified by:
print in interface Response
Parameters:
deferredContent - the text snippets that will be printed
Throws:
EngineException - if an error occurs during the output of the text snippets
See Also:
Response.print(Template), Response.print(Object)

print

public void print(Object value)
           throws EngineException
Description copied from interface: Response
Prints the string representation of an object to the request text output. The string representation will be created through a String.valueOf(value) call.

Specified by:
print in interface Response
Parameters:
value - the object that will be output
Throws:
EngineException - if an error occurs during the output of the content
See Also:
Response.print(Template), Response.print(Collection)

getCharacterEncoding

public String getCharacterEncoding()
Description copied from interface: Response
See ServletResponse.getCharacterEncoding().

Specified by:
getCharacterEncoding in interface Response

clearBuffer

public void clearBuffer()
Description copied from interface: Response
Clears the text buffer is it's enabled.

If the text buffer is disabled, this method does nothing.

Specified by:
clearBuffer in interface Response

flush

public void flush()
           throws EngineException
Description copied from interface: Response
Forces all the streamed content to be output to the client.

If the text buffer is enabled, this will flush its content to the output stream first.

Specified by:
flush in interface Response
Throws:
EngineException

close

public void close()
           throws EngineException
Description copied from interface: Response
Closed the content output stream.

All content is flushed first.

Specified by:
close in interface Response
Throws:
EngineException

getOutputStream

public OutputStream getOutputStream()
                             throws EngineException
Description copied from interface: Response
See ServletResponse.getOutputStream().

Specified by:
getOutputStream in interface Response
Throws:
EngineException

setContentLength

public void setContentLength(int length)
                      throws EngineException
Description copied from interface: Response
See ServletResponse.setContentLength(int).

Specified by:
setContentLength in interface Response
Throws:
EngineException

sendRedirect

public void sendRedirect(String location)
                  throws EngineException
Description copied from interface: Response
See HttpServletResponse.sendRedirect(String).

Specified by:
sendRedirect in interface Response
Throws:
EngineException


Copyright © 2001-2007 Uwyn sprl/bvba. All Rights Reserved.