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
FieldsModifier and TypeFieldDescriptionprotected Stringprotected ByteArrayOutputStreamprotected GZIPOutputStreamprotected Elementprotected OutputStreamprotected OutputStreamprotected ArrayList<CharSequence>protected boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractResponse(Request request) Constructor that needs to be called by all the constructors of the extending classes. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract OutputStreamThis method needs to be implemented by the extending back-end class and will be called byAbstractResponseduring 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 byAbstractResponseduring the RIFE2-specific additional behaviour.voidClears the text buffer is it's enabled.voidclose()Closed the content output stream.voidenableTextBuffer(boolean enabled) Enables or disabled the text output buffer.voidflush()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.booleanIndicates whether this response's content type has been explicitly set.booleanIndicates whether the text output buffer is enabled.voidPrints the string representation of an object to the request text output.voidprint(Collection<CharSequence> deferredContent) Prints a list of text snippets to the request text output.voidPrints the content of a template to the request text output.voidsetContentType(String contentType) voidsetLastElement(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, waitMethods 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- theRequestthat 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 byAbstractResponseduring 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 byAbstractResponseduring 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:ResponseSets 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:
setLastElementin interfaceResponse- Parameters:
element- an element that has been executed in the context of this response
-
getLastElement
Description copied from interface:ResponseRetrieves the element that was last processed with- Specified by:
getLastElementin interfaceResponse- Returns:
- the last element
-
isContentTypeSet
public boolean isContentTypeSet()Description copied from interface:ResponseIndicates whether this response's content type has been explicitly set.- Specified by:
isContentTypeSetin interfaceResponse- Returns:
trueif it has been set; orfalseotherwise- See Also:
-
getContentType
Description copied from interface:ResponseRetrieves the content type that was explicitly set for this response.- Specified by:
getContentTypein interfaceResponse- Returns:
- the content type as a String; or
nullif the content type wasn't set - See Also:
-
setContentType
Description copied from interface:Response- Specified by:
setContentTypein interfaceResponse
-
enableTextBuffer
public void enableTextBuffer(boolean enabled) Description copied from interface:ResponseEnables 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:
enableTextBufferin interfaceResponse- Parameters:
enabled-trueto enable the text buffer; orfalseto disable it
-
isTextBufferEnabled
public boolean isTextBufferEnabled()Description copied from interface:ResponseIndicates whether the text output buffer is enabled.- Specified by:
isTextBufferEnabledin interfaceResponse- Returns:
truewhen the text buffer is enabled; orfalsewhen it is disabled.
-
print
Description copied from interface:ResponsePrints the content of a template to the request text output.- Specified by:
printin 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:ResponsePrints a list of text snippets to the request text output.- Specified by:
printin 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:ResponsePrints the string representation of an object to the request text output. The string representation will be created through aString.valueOf(value)call.- Specified by:
printin 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:ResponseClears the text buffer is it's enabled.If the text buffer is disabled, this method does nothing.
- Specified by:
clearBufferin interfaceResponse
-
flush
Description copied from interface:ResponseForces 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:
flushin interfaceResponse- Throws:
EngineException
-
close
Description copied from interface:ResponseClosed the content output stream.All content is
flushedfirst.- Specified by:
closein interfaceResponse- Throws:
EngineException
-
getOutputStream
Description copied from interface:Response- Specified by:
getOutputStreamin interfaceResponse- Throws:
EngineException
-