public class JSONInterceptor extends AbstractInterceptor
Constructor and Description |
---|
JSONInterceptor() |
Modifier and Type | Method and Description |
---|---|
protected String |
addCallbackIfApplicable(javax.servlet.http.HttpServletRequest request,
String json) |
String |
getCallbackParameter() |
boolean |
getDebug() |
protected List |
getIncludeProperties()
Returns the appropriate set of includes, based on debug setting.
|
String |
intercept(ActionInvocation invocation) |
RPCResponse |
invoke(Object object,
Map data) |
boolean |
isEnableGZIP() |
boolean |
isEnableSMD() |
boolean |
isExcludeNullProperties() |
boolean |
isNoCache() |
void |
setCallbackParameter(String callbackParameter) |
void |
setContentType(String contentType) |
void |
setDebug(boolean debug)
Turns debugging on or off
|
void |
setDefaultEncoding(String val) |
void |
setDevMode(String mode) |
void |
setEnableGZIP(boolean enableGZIP)
Setting this property to "true" will compress the output.
|
void |
setEnableSMD(boolean enableSMD) |
void |
setExcludeNullProperties(boolean excludeNullProperties)
Do not serialize properties with a null value
|
void |
setExcludeProperties(String commaDelim)
Sets a comma-delimited list of regular expressions to match properties
that should be excluded from the JSON output.
|
void |
setExcludeWildcards(String commaDelim)
Sets a comma-delimited list of wildcard expressions to match
properties that should be excluded from the JSON output.
|
void |
setIgnoreHierarchy(boolean ignoreHierarchy)
Ignore properties defined on base classes of the root object.
|
void |
setIgnoreSMDMethodInterfaces(boolean ignoreSMDMethodInterfaces)
Ignore annotations on methods in interfaces You may need to set to this
true if your action is a proxy/enhanced as annotations are not inherited
|
void |
setIncludeProperties(String commaDelim)
Sets a comma-delimited list of regular expressions to match properties
that should be included from the JSON output.
|
void |
setIncludeWildcards(String commaDelim)
Sets a comma-delimited list of wildcard expressions to match
properties that should be included from the JSON output.
|
void |
setJSONCleaner(JSONCleaner dataCleaner)
Sets the JSONCleaner to be used
|
void |
setJSONPopulator(JSONPopulator populator)
Sets the JSONPopulator to be used
|
void |
setNoCache(boolean noCache)
Add headers to response to prevent the browser from caching the response
|
void |
setPrefix(boolean prefix)
Add "{} && " to generated JSON
|
void |
setRoot(String root)
Sets the root object to be deserialized, defaults to the Action
|
void |
setWrapWithComments(boolean wrapWithComments)
Wrap generated JSON with comments.
|
destroy, init
public String intercept(ActionInvocation invocation) throws Exception
intercept
in interface Interceptor
intercept
in class AbstractInterceptor
Exception
public RPCResponse invoke(Object object, Map data) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, JSONException, InstantiationException, NoSuchMethodException, IntrospectionException
protected String addCallbackIfApplicable(javax.servlet.http.HttpServletRequest request, String json)
public boolean isEnableSMD()
public void setEnableSMD(boolean enableSMD)
public void setIgnoreSMDMethodInterfaces(boolean ignoreSMDMethodInterfaces)
public void setWrapWithComments(boolean wrapWithComments)
wrapWithComments
- public void setDefaultEncoding(String val)
public void setIgnoreHierarchy(boolean ignoreHierarchy)
ignoreHierarchy
- public void setRoot(String root)
root
- OGNL expression of root object to be serializedpublic void setJSONPopulator(JSONPopulator populator)
populator
- JSONPopulatorpublic void setJSONCleaner(JSONCleaner dataCleaner)
dataCleaner
- JSONCleanerpublic boolean getDebug()
public void setDebug(boolean debug)
debug
- true or falsepublic void setDevMode(String mode)
public void setExcludeProperties(String commaDelim)
commaDelim
- A comma-delimited list of regular expressionspublic void setExcludeWildcards(String commaDelim)
commaDelim
- A comma-delimited list of wildcard expressionspublic void setIncludeProperties(String commaDelim)
commaDelim
- A comma-delimited list of regular expressionspublic void setIncludeWildcards(String commaDelim)
commaDelim
- A comma-delimited list of wildcard expressionsprotected List getIncludeProperties()
public boolean isEnableGZIP()
public void setEnableGZIP(boolean enableGZIP)
enableGZIP
- Enable compressed outputpublic boolean isNoCache()
public void setNoCache(boolean noCache)
noCache
- public boolean isExcludeNullProperties()
public void setExcludeNullProperties(boolean excludeNullProperties)
excludeNullProperties
- public void setCallbackParameter(String callbackParameter)
public String getCallbackParameter()
public void setPrefix(boolean prefix)
prefix
- public void setContentType(String contentType)
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.