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
public class ServletResponse extends Object implements IServletResponse
Default POJO implementation ofIServletResponse
.- Author:
- XIMA MEDIA GmbH
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
appendFormSessionId
protected byte[]
binValue
protected String
contentType
protected String
encoding
protected boolean
forceDownload
protected Map<String,String>
httpHeader
protected int
httpStatusCode
protected long
longValue
protected Map<String,Serializable>
sessionAttributes
protected EResponseType
type
protected String
value
-
Constructor Summary
Constructors Constructor Description ServletResponse(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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addHttpHeader(String name, String value)
Adds an HTTP header with the given name.byte[]
getBinValue()
The binary data for the response.String
getContentType()
String
getEncoding()
Map<String,String>
getHttpHeader()
int
getHttpStatusCode()
long
getLongValue()
Applies only whentype
is set toFORM_RECORD
is set, this is the ID of the form record to which to redirect.Map<String,Serializable>
getSessionAttributes()
EResponseType
getType()
String
getValue()
Whentype
is set to a binary response type (e.g.boolean
isAppendFormSessionID()
Deprecated.Does not have any effect anymore.boolean
isForceDownload()
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
setValue(String value)
-
-
-
Field Detail
-
value
protected String value
-
longValue
protected long longValue
-
contentType
protected String contentType
-
sessionAttributes
protected Map<String,Serializable> sessionAttributes
-
encoding
protected String encoding
-
binValue
protected byte[] binValue
-
type
protected EResponseType type
-
forceDownload
protected boolean forceDownload
-
appendFormSessionId
protected boolean appendFormSessionId
-
httpStatusCode
protected int httpStatusCode
-
-
Constructor Detail
-
ServletResponse
public ServletResponse(IServletResponse response)
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
public ServletResponse(EResponseType type, String value, byte[] binValue, boolean forceDownload)
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
public ServletResponse(EResponseType type, String value, byte[] binValue)
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
public ServletResponse(EResponseType type, String value)
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
public ServletResponse(EResponseType type, long longValue)
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
public ServletResponse(EResponseType type)
Creates a new servlet response without any content.- Parameters:
type
- The value forIServletResponse.getType()
.
-
-
Method Detail
-
getValue
public String 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
public void setValue(String value)
- Parameters:
value
- The new value forIServletResponse.getValue()
.
-
getType
public EResponseType 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
public void setType(EResponseType type)
- 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
public String getEncoding()
Description copied from interface:IServletResponse
- Specified by:
getEncoding
in interfaceIServletResponse
- Returns:
- The encoding that is to be used for encoding the response.
-
setEncoding
public void setEncoding(String encoding)
- Parameters:
encoding
- The new value forIServletResponse.getEncoding()
.
-
setAppendFormSessionID
@Deprecated public void setAppendFormSessionID(boolean appendFormSessionID)
Deprecated.Does not have any effect anymore.- Parameters:
appendFormSessionID
- The new value that is returned byisAppendFormSessionID()
.
-
isAppendFormSessionID
@Deprecated public boolean 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
public String 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
public void setContentType(String contentType)
- Parameters:
contentType
- The new value forIServletResponse.getContentType()
.
-
getSessionAttributes
public Map<String,Serializable> getSessionAttributes()
- Specified by:
getSessionAttributes
in interfaceIServletResponse
- Returns:
- A
Map
with attributes that should be written to theHttpSession
. Existing values in theHttpSession
are overwritten.
-
setSessionAttributes
public void setSessionAttributes(Map<String,Serializable> sessionAttributes)
- Parameters:
sessionAttributes
- The new value forIServletResponse.getSessionAttributes()
.
-
getHttpHeader
public Map<String,String> getHttpHeader()
- Specified by:
getHttpHeader
in interfaceIServletResponse
- Returns:
- A
Map
of HTTP headers that should be sent along with the HTTP response.
-
setHttpHeader
public void setHttpHeader(Map<String,String> httpHeader)
Removes all existing headers and sets a new map of HTTP headers to send with the response.- Parameters:
httpHeader
- The new value forIServletResponse.getHttpHeader()
.
-
-