Class JsonTool

java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.apache.velocity.tools.generic.ImportSupport
org.apache.velocity.tools.generic.JsonTool
org.apache.velocity.tools.view.JsonTool
All Implemented Interfaces:
Serializable, Iterable

@DefaultKey("json") @ValidScope("request") public class JsonTool extends org.apache.velocity.tools.generic.JsonTool
View version of JsonTool. It adds an automatic parsing of the HTTP query body content, if it is found to be of JSON type.
Since:
VelocityTools 3.0
Version:
$Id:$
Author:
Claude Brisson
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.velocity.tools.generic.ImportSupport

    org.apache.velocity.tools.generic.ImportSupport.SafeClosingHttpURLConnectionReader
  • Field Summary

    Fields inherited from class org.apache.velocity.tools.generic.JsonTool

    importSupport

    Fields inherited from class org.apache.velocity.tools.generic.ImportSupport

    RESOURCE_KEY, URL_KEY, VALID_SCHEME_CHARS

    Fields inherited from class org.apache.velocity.tools.generic.SafeConfig

    LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    configure(org.apache.velocity.tools.generic.ValueParser parser)
    Configuration.
    protected void
    initializeImportSupport(org.apache.velocity.tools.generic.ValueParser config)
    Importsupport initialization
    protected static boolean
    Check if a given content type is of JSON type
    protected static boolean
    Check if a given mime type is of JSON type

    Methods inherited from class org.apache.velocity.tools.generic.JsonTool

    fetch, get, get, initJSON, initJSON, iterator, keys, keySet, parse, read, root, size, toString

    Methods inherited from class org.apache.velocity.tools.generic.ImportSupport

    acquireLocalURLReader, acquireLocalURLString, acquireReader, acquireRemoteURLReader, acquireRemoteURLString, acquireString, getClasspathResource, getContentTypeAttribute, getFileResource, getProtocol, getResourceReader, getResourceString, isRemoteURL, setSafeMode

    Methods inherited from class org.apache.velocity.tools.generic.SafeConfig

    configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface Iterable

    forEach, spliterator
  • Constructor Details

    • JsonTool

      public JsonTool()
  • Method Details

    • initializeImportSupport

      protected void initializeImportSupport(org.apache.velocity.tools.generic.ValueParser config)
      Importsupport initialization
      Overrides:
      initializeImportSupport in class org.apache.velocity.tools.generic.JsonTool
      Parameters:
      config - configuration values
    • isJsonMimeType

      protected static boolean isJsonMimeType(String mimeType)
      Check if a given mime type is of JSON type
      Parameters:
      mimeType - mime type
      Returns:
      whether given mime type is of JSON type
    • isJsonContentType

      protected static boolean isJsonContentType(String contentType)
      Check if a given content type is of JSON type
      Parameters:
      contentType - content type
      Returns:
      whether given content type is of JSON type
    • configure

      protected void configure(org.apache.velocity.tools.generic.ValueParser parser)
      Configuration. Parses request body if appropriate.
      Overrides:
      configure in class org.apache.velocity.tools.generic.JsonTool
      Parameters:
      parser - configuration values