Package rife.engine
Class AbstractResponse
java.lang.Object
rife.engine.AbstractResponse
- All Implemented Interfaces:
Response
- Direct Known Subclasses:
HttpResponse
,MockResponse
This abstract class implements parts of the
Response
interface to
provide behaviour that is specific to RIFE2.
Additional abstract methods have been provided to integrate with the
concrete back-end classes that extend AbstractResponse
.
- Since:
- 1.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected ByteArrayOutputStream
protected GZIPOutputStream
protected Element
protected OutputStream
protected OutputStream
protected ArrayList<CharSequence>
protected boolean
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractResponse
(Request request) Constructor that needs to be called by all the constructors of the extending classes. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract OutputStream
This method needs to be implemented by the extending back-end class and will be called byAbstractResponse
during the RIFE2-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 byAbstractResponse
during the RIFE2-specific additional behaviour.void
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.Retrieves the content type that was explicitly set for this response.Retrieves the element that was last processed withRetrieves the request that is associated with this response.boolean
Indicates whether this response's content type has been explicitly set.boolean
Indicates whether the text output buffer is enabled.void
Prints the string representation of an object to the request text output.void
print
(Collection<CharSequence> deferredContent) Prints a list of text snippets to the request text output.void
Prints the content of a template to the request text output.void
setContentType
(String contentType) void
setLastElement
(Element 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 rife.engine.Response
addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, encodeURL, getCharacterEncoding, getHttpServletResponse, getLocale, getWriter, sendError, sendError, sendRedirect, setContentLength, setDateHeader, setHeader, setIntHeader, setLocale, setStatus
-
Field Details
-
contentType_
-
lastElement_
-
textBufferEnabled_
protected boolean textBufferEnabled_ -
textBuffer_
-
responseOutputStream_
-
gzipByteOutputStream_
-
gzipOutputStream_
-
outputStream_
-
-
Constructor Details
-
AbstractResponse
Constructor that needs to be called by all the constructors of the extending classes.- Parameters:
request
- theRequest
that is associated with this response- Since:
- 1.0
-
-
Method Details
-
_setContentType
This method needs to be implemented by the extending back-end class and will be called byAbstractResponse
during the RIFE2-specific additional behaviour. It behaves exactly like itscounter-part in the Response interface
.- Since:
- 1.0
- See Also:
-
_getOutputStream
This method needs to be implemented by the extending back-end class and will be called byAbstractResponse
during the RIFE2-specific additional behaviour. It behaves exactly like itscounter-part in the Request interface
.- Throws:
IOException
- Since:
- 1.0
- See Also:
-
getRequest
Retrieves the request that is associated with this response.- Returns:
- the associated request
- Since:
- 1.0
-
setLastElement
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 interfaceResponse
- Parameters:
element
- an element that has been executed in the context of this response
-
getLastElement
Description copied from interface:Response
Retrieves the element that was last processed with- Specified by:
getLastElement
in interfaceResponse
- Returns:
- the last element
-
isContentTypeSet
public boolean isContentTypeSet()Description copied from interface:Response
Indicates whether this response's content type has been explicitly set.- Specified by:
isContentTypeSet
in interfaceResponse
- Returns:
true
if it has been set; orfalse
otherwise- See Also:
-
getContentType
Description copied from interface:Response
Retrieves the content type that was explicitly set for this response.- Specified by:
getContentType
in interfaceResponse
- Returns:
- the content type as a String; or
null
if the content type wasn't set - See Also:
-
setContentType
Description copied from interface:Response
- Specified by:
setContentType
in interfaceResponse
-
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 interfaceResponse
- Parameters:
enabled
-true
to enable the text buffer; orfalse
to disable it
-
isTextBufferEnabled
public boolean isTextBufferEnabled()Description copied from interface:Response
Indicates whether the text output buffer is enabled.- Specified by:
isTextBufferEnabled
in interfaceResponse
- Returns:
true
when the text buffer is enabled; orfalse
when it is disabled.
-
print
Description copied from interface:Response
Prints the content of a template to the request text output.- Specified by:
print
in interfaceResponse
- Parameters:
template
- the template that will be printed- Throws:
EngineException
- if an error occurs during the output of the template content- See Also:
-
print
Description copied from interface:Response
Prints a list of text snippets to the request text output.- Specified by:
print
in interfaceResponse
- Parameters:
deferredContent
- the text snippets that will be printed- Throws:
EngineException
- if an error occurs during the output of the text snippets // * @see #print(Template)- See Also:
-
print
Description copied from interface:Response
Prints the string representation of an object to the request text output. The string representation will be created through aString.valueOf(value)
call.- Specified by:
print
in interfaceResponse
- Parameters:
value
- the object that will be output- Throws:
EngineException
- if an error occurs during the output of the content // * @see #print(Template)- See Also:
-
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 interfaceResponse
-
flush
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 interfaceResponse
- Throws:
EngineException
-
close
Description copied from interface:Response
Closed the content output stream.All content is
flushed
first.- Specified by:
close
in interfaceResponse
- Throws:
EngineException
-
getOutputStream
Description copied from interface:Response
- Specified by:
getOutputStream
in interfaceResponse
- Throws:
EngineException
-