Class JSONCleaner

java.lang.Object
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!

  • Constructor Details

    • JSONCleaner

      public JSONCleaner()
  • Method Details

    • 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 parameters 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.