Class JsonTool

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.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:
    Serialized Form
    • 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
      JsonTool()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      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 isJsonContentType​(java.lang.String contentType)
      Check if a given content type is of JSON type
      protected static boolean isJsonMimeType​(java.lang.String mimeType)
      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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • JsonTool

        public JsonTool()
    • Method Detail

      • 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​(java.lang.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​(java.lang.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