Package de.xima.fc.mdl.response
Class ServletResponse
java.lang.Object
de.xima.fc.mdl.response.ServletResponse
- All Implemented Interfaces:
IServletResponse
,Serializable
- Direct Known Subclasses:
WorkflowResponse
Default POJO implementation of
IServletResponse
.- Author:
- XIMA MEDIA GmbH
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected byte[]
protected String
protected String
protected boolean
protected int
protected long
protected Map<String,
Serializable> protected EResponseType
protected String
-
Constructor Summary
ConstructorsConstructorDescriptionServletResponse
(IServletResponse response) Creates a new servlet response with all data copied from a given response.ServletResponse
(EResponseType type) Creates a new servlet response without any content.ServletResponse
(EResponseType type, long longValue) Creates a new servlet response with a single numerical response.ServletResponse
(EResponseType type, String value) Creates a new servlet response with plain text response.ServletResponse
(EResponseType type, String value, byte[] binValue) Creates a new servlet response with binary response.ServletResponse
(EResponseType type, String value, byte[] binValue, boolean forceDownload) Creates a new servlet response with binary response. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHttpHeader
(String name, String value) Adds an HTTP header with the given name.byte[]
The binary data for the response.int
long
Applies only whentype
is set toFORM_RECORD
is set, this is the ID of the form record to which to redirect.getType()
getValue()
Whentype
is set to a binary response type (e.g.boolean
Deprecated.Does not have any effect anymore.boolean
void
setAppendFormSessionID
(boolean appendFormSessionID) Deprecated.Does not have any effect anymore.void
setBinValue
(byte[] binValue) void
setContentType
(String contentType) void
setEncoding
(String encoding) void
setForceDownload
(boolean forceDownload) void
setHttpHeader
(Map<String, String> httpHeader) Removes all existing headers and sets a new map of HTTP headers to send with the response.void
setHttpStatusCode
(int httpStatusCode) void
setLongValue
(long longValue) void
setSessionAttributes
(Map<String, Serializable> sessionAttributes) void
setType
(EResponseType type) void
-
Field Details
-
value
-
longValue
protected long longValue -
contentType
-
sessionAttributes
-
httpHeader
-
encoding
-
binValue
protected byte[] binValue -
type
-
forceDownload
protected boolean forceDownload -
appendFormSessionId
protected boolean appendFormSessionId -
httpStatusCode
protected int httpStatusCode
-
-
Constructor Details
-
ServletResponse
Creates a new servlet response with all data copied from a given response. Can be used to modify a servlet response.- Parameters:
response
- An existing servlet response from which to copy the data.
-
ServletResponse
Creates a new servlet response with binary response.- Parameters:
type
- The value forIServletResponse.getType()
.value
- The value forIServletResponse.getValue()
, the name of the file.binValue
- The value forIServletResponse.getBinValue()
, the content of the file.forceDownload
- The value forIServletResponse.isForceDownload()
.
-
ServletResponse
Creates a new servlet response with binary response.- Parameters:
type
- The value forIServletResponse.getType()
.value
- The value forIServletResponse.getValue()
, the name of the file.binValue
- The value forIServletResponse.getBinValue()
, the content of the file.
-
ServletResponse
Creates a new servlet response with plain text response.- Parameters:
type
- The value forIServletResponse.getType()
.value
- The value forIServletResponse.getValue()
, the content of the file or the redirect URL.
-
ServletResponse
Creates a new servlet response with a single numerical response.- Parameters:
type
- The value forIServletResponse.getType()
.longValue
- The value forIServletResponse.getLongValue()
, e.g. the form record ID when the type isFORM_RECORD
.
-
ServletResponse
Creates a new servlet response without any content.- Parameters:
type
- The value forIServletResponse.getType()
.
-
-
Method Details
-
getValue
Description copied from interface:IServletResponse
Whentype
is set to a binary response type (e.g.SHOW_FILE
), the file name of the returned file.When
type
is set to a non-binary response (e.g.JSON
), the plain-text content of the response.- Specified by:
getValue
in interfaceIServletResponse
- Returns:
- The plain-text content of the HTTP response.
-
setValue
- Parameters:
value
- The new value forIServletResponse.getValue()
.
-
getType
- Specified by:
getType
in interfaceIServletResponse
- Returns:
- The type of response, such as whether a plain text or binary file should be returned, or a redirect should be performed.
-
setType
- Parameters:
type
- The new value forIServletResponse.getType()
.
-
getBinValue
public byte[] getBinValue()Description copied from interface:IServletResponse
- Specified by:
getBinValue
in interfaceIServletResponse
- Returns:
- The binary content of the HTTP response.
-
setBinValue
public void setBinValue(byte[] binValue) - Parameters:
binValue
- The new value forIServletResponse.getBinValue()
.
-
isForceDownload
public boolean isForceDownload()Description copied from interface:IServletResponse
- Specified by:
isForceDownload
in interfaceIServletResponse
- Returns:
- If
true
, attempts to prevent browsers from showing the binary content inline. Iffalse
, the browser may show the content inline, which is useful for PDF, image or plain text files. Please note that support for this differs between browsers.
-
setForceDownload
public void setForceDownload(boolean forceDownload) - Parameters:
forceDownload
- The new value forIServletResponse.isForceDownload()
.
-
getEncoding
Description copied from interface:IServletResponse
- Specified by:
getEncoding
in interfaceIServletResponse
- Returns:
- The encoding that is to be used for encoding the response.
-
setEncoding
- Parameters:
encoding
- The new value forIServletResponse.getEncoding()
.
-
setAppendFormSessionID
Deprecated.Does not have any effect anymore.- Parameters:
appendFormSessionID
- The new value that is returned byisAppendFormSessionID()
.
-
isAppendFormSessionID
Deprecated.Does not have any effect anymore.- Returns:
- Returns the boolean flag as set by
setAppendFormSessionID(boolean)
.
-
getLongValue
public long getLongValue()Description copied from interface:IServletResponse
Applies only whentype
is set toFORM_RECORD
is set, this is the ID of the form record to which to redirect.- Specified by:
getLongValue
in interfaceIServletResponse
- Returns:
- The long value content for the response.
-
setLongValue
public void setLongValue(long longValue) - Parameters:
longValue
- The new value forIServletResponse.getLongValue()
.
-
getHttpStatusCode
public int getHttpStatusCode()- Specified by:
getHttpStatusCode
in interfaceIServletResponse
- Returns:
- The HTTP status code of the HTTP response.
-
setHttpStatusCode
public void setHttpStatusCode(int httpStatusCode) - Parameters:
httpStatusCode
- The new value forIServletResponse.getHttpStatusCode()
.
-
getContentType
Description copied from interface:IServletResponse
Applies only whentype
is set toSHOW_FILE
:Must return the content type (=mime type) that is to be sent along with the binary data. When this is either
null
or blank, an attempt is made to guess the content type from the binary data. Please note that this may fail to determine the actual content type, you should always provide a content type.- Specified by:
getContentType
in interfaceIServletResponse
- Returns:
- The content type of the binary data.
-
setContentType
- Parameters:
contentType
- The new value forIServletResponse.getContentType()
.
-
getSessionAttributes
- Specified by:
getSessionAttributes
in interfaceIServletResponse
- Returns:
- A
Map
with attributes that should be written to theHttpSession
. Existing values in theHttpSession
are overwritten.
-
setSessionAttributes
- Parameters:
sessionAttributes
- The new value forIServletResponse.getSessionAttributes()
.
-
getHttpHeader
- Specified by:
getHttpHeader
in interfaceIServletResponse
- Returns:
- A
Map
of HTTP headers that should be sent along with the HTTP response.
-
setHttpHeader
Removes all existing headers and sets a new map of HTTP headers to send with the response.- Parameters:
httpHeader
- The new value forIServletResponse.getHttpHeader()
.
-
addHttpHeader
Adds an HTTP header with the given name. When a value exists already for that name, it is overwritten.- Parameters:
name
- Name of the header.value
- Value of the header.
-