org.apache.struts2.json
Class JSONCleaner

java.lang.Object
  extended by org.apache.struts2.json.JSONCleaner

public abstract class JSONCleaner
extends Object

Isolate the process of cleaning JSON data from the Interceptor class itself.

The allowed and blocked wildcard patterns, combined with defaultBlock, let you filter out values that should not be injected, in the same way that ParameterFilterInterceptor does. Note that you can only remove values from a Map. Removing values from a List is dangerous because it could change the meaning of the data!


Nested Class Summary
static class JSONCleaner.Filter
           
 
Constructor Summary
JSONCleaner()
           
 
Method Summary
 Object clean(String ognlPrefix, Object data)
           
protected  Object cleanList(String ognlPrefix, Object data)
           
protected  Object cleanMap(String ognlPrefix, Object data)
           
protected abstract  Object cleanValue(String ognlName, Object data)
           
 Collection<String> getAllowedCollection()
           
 Collection<String> getBlockedCollection()
           
 Map<String,JSONCleaner.Filter> getIncludesExcludesMap()
           
 boolean isDefaultBlock()
           
 void setAllowed(String allowed)
           
 void setAllowedCollection(Collection<String> allowed)
           
 void setBlocked(String blocked)
           
 void setBlockedCollection(Collection<String> blocked)
           
 void setDefaultBlock(boolean defaultExclude)
           
 void setIncludesExcludesMap(Map<String,JSONCleaner.Filter> map)
          Allow external caching of the compiled result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONCleaner

public JSONCleaner()
Method Detail

clean

public Object clean(String ognlPrefix,
                    Object data)
             throws JSONException
Throws:
JSONException

cleanList

protected Object cleanList(String ognlPrefix,
                           Object data)
                    throws JSONException
Throws:
JSONException

cleanMap

protected Object cleanMap(String ognlPrefix,
                          Object data)
                   throws JSONException
Throws:
JSONException

cleanValue

protected abstract Object cleanValue(String ognlName,
                                     Object data)
                              throws JSONException
Throws:
JSONException

getIncludesExcludesMap

public Map<String,JSONCleaner.Filter> getIncludesExcludesMap()
Returns:
the compiled list of includes and excludes

setIncludesExcludesMap

public void setIncludesExcludesMap(Map<String,JSONCleaner.Filter> map)
Allow external caching of the compiled result.

Parameters:
map - the compiled list of includes and excludes

isDefaultBlock

public boolean isDefaultBlock()
Returns:
value of defaultBlock

setDefaultBlock

public void setDefaultBlock(boolean defaultExclude)
Parameters:
defaultExclude - The defaultExclude to set.

getBlockedCollection

public Collection<String> getBlockedCollection()
Returns:
list of blocked wildcard patterns

setBlockedCollection

public void setBlockedCollection(Collection<String> blocked)
Parameters:
blocked - The blocked to set.

setBlocked

public void setBlocked(String blocked)
Parameters:
blocked - The blocked paramters as comma separated String.

getAllowedCollection

public Collection<String> getAllowedCollection()
Returns:
list of allowed wildcard patterns

setAllowedCollection

public void setAllowedCollection(Collection<String> allowed)
Parameters:
allowed - The allowed to set.

setAllowed

public void setAllowed(String allowed)
Parameters:
allowed - The allowed paramters as comma separated String.


Copyright © 2000–2018 Apache Software Foundation. All rights reserved.