org.apache.struts2.json
Class JSONCleaner

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

public abstract class JSONCleaner
extends java.lang.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
 java.lang.Object clean(java.lang.String ognlPrefix, java.lang.Object data)
           
protected  java.lang.Object cleanList(java.lang.String ognlPrefix, java.lang.Object data)
           
protected  java.lang.Object cleanMap(java.lang.String ognlPrefix, java.lang.Object data)
           
protected abstract  java.lang.Object cleanValue(java.lang.String ognlName, java.lang.Object data)
           
 java.util.Collection<java.lang.String> getAllowedCollection()
           
 java.util.Collection<java.lang.String> getBlockedCollection()
           
 java.util.Map<java.lang.String,JSONCleaner.Filter> getIncludesExcludesMap()
           
 boolean isDefaultBlock()
           
 void setAllowed(java.lang.String allowed)
           
 void setAllowedCollection(java.util.Collection<java.lang.String> allowed)
           
 void setBlocked(java.lang.String blocked)
           
 void setBlockedCollection(java.util.Collection<java.lang.String> blocked)
           
 void setDefaultBlock(boolean defaultExclude)
           
 void setIncludesExcludesMap(java.util.Map<java.lang.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 java.lang.Object clean(java.lang.String ognlPrefix,
                              java.lang.Object data)
                       throws JSONException
Throws:
JSONException

cleanList

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

cleanMap

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

cleanValue

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

getIncludesExcludesMap

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

setIncludesExcludesMap

public void setIncludesExcludesMap(java.util.Map<java.lang.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 java.util.Collection<java.lang.String> getBlockedCollection()
Returns:
list of blocked wildcard patterns

setBlockedCollection

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

setBlocked

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

getAllowedCollection

public java.util.Collection<java.lang.String> getAllowedCollection()
Returns:
list of allowed wildcard patterns

setAllowedCollection

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

setAllowed

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


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.