Class Config

java.lang.Object
com.benesult.vivjson.Config

public class Config extends Object
Configuration of VivJson.

Environment: Java 9 or later

Last modified: 2025-04-04

Author:
Fumiaki Motegi (motegi@benesult.com)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Version of this interpreter.
    static final String
    Version of VivJson's specification.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Makes configuration instance of default values.
    Config(boolean enableStderr, boolean enableTagDetail, boolean enableOnlyJson, @Nullable String infinity, @Nullable String nan, int maxArraySize, int maxDepth, int maxLoopTimes)
    Makes configuration instance with all custom values.
    Config(Config config)
    Makes configuration instance that is based on the given instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Enables only JSON.
    void
    enableOnlyJson(boolean enable)
    Enables only JSON.
    void
    Enables that error message outputs into stderr.
    void
    enableStderr(boolean enable)
    Enables/disables that error message outputs into stderr.
    void
    Enables that detail of error message's tag.
    void
    enableTagDetail(boolean enable)
    Enables that detail of error message's tag.
    boolean
    Gets whether parsing target is limited only JSON or not.
    static boolean
    getEnableOnlyJson(@Nullable Config config)
    Gets whether parsing target is limited only JSON or not.
    boolean
    Gets whether outputting error message into stderr is enable.
    static boolean
    getEnableStderr(@Nullable Config config)
    Gets whether outputting error message into stderr is enable.
    boolean
    Gets whether detail of error message's tag is enable or not.
    static boolean
    getEnableTagDetail(@Nullable Config config)
    Gets whether detail of error message's tag is enable or not.
    @Nullable String
    Gets infinity's string.
    static @Nullable String
    getInfinity(@Nullable Config config)
    Gets infinity's string.
    int
    Gets maximum array/block size.
    static int
    getMaxArraySize(@Nullable Config config)
    Gets maximum array/block size.
    int
    Gets maximum recursive called times of evaluate method.
    static int
    getMaxDepth(@Nullable Config config)
    Gets maximum recursive called times of evaluate method.
    int
    Gets maximum loop times of "for", "while", and so on.
    static int
    getMaxLoopTimes(@Nullable Config config)
    Gets maximum loop times of "for", "while", and so on.
    @Nullable String
    Gets NaN(Not a Number)'s string.
    static @Nullable String
    getNaN(@Nullable Config config)
    Get NaN(Not a Number)'s string.
    void
    setInfinity(@Nullable String infinity)
    Sets infinity's string.
    void
    setMaxArraySize(int size)
    Sets maximum array/block size.
    void
    setMaxDepth(int depth)
    Set maximum recursive called times of evaluate method.
    void
    setMaxLoopTimes(int times)
    Sets maximum loop times of "for", "while", and so on.
    void
    setNaN(@Nullable String nan)
    Sets NaN(Not a Number)'s string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SPEC_VERSION

      public static final String SPEC_VERSION
      Version of VivJson's specification. It is represented as <Major> "." <Minor> "." <Patch>. For example, "1.0.0".
      See Also:
    • INTERPRETER_VERSION

      public static final String INTERPRETER_VERSION
      Version of this interpreter. It is represented as <Major> "." <Minor> "." <Patch>. For example, "1.0.0".
      This <Major> "." <Minor> is equal to SPEC_VERSION's one.
      See Also:
  • Constructor Details

    • Config

      public Config()
      Makes configuration instance of default values.
    • Config

      public Config(Config config)
      Makes configuration instance that is based on the given instance.
      Parameters:
      config - a configuration instance
    • Config

      public Config(boolean enableStderr, boolean enableTagDetail, boolean enableOnlyJson, @Nullable String infinity, @Nullable String nan, int maxArraySize, int maxDepth, int maxLoopTimes)
      Makes configuration instance with all custom values.
      Parameters:
      enableStderr - enabling stderr. When true is given, error message is outputted into stderr. Otherwise, it is not outputted.
      enableTagDetail - enabling the detail of tag. When true is given, error message's tag contains either of "Lexer", "Parser", or "Evaluator".
      enableOnlyJson - enabling only JSON. When true is given, the given data is parsed as JSON. In other words, script is disabled.
      infinity - Infinity's representation of string. When string is given, Infinity is allowed in JSON. Then the given string is used to input/output Infinity from/to JSON. (Note that it is not surrounded with quotation mark.) When null is given and Infinity is happen, error may be occurred.
      nan - NaN (Not a Number)'s representation of string. When string is given, NaN (Not a Number) is allowed in JSON. Then the given string is used to input/output NaN from/to JSON. (Note that it is not surrounded with quotation mark.) When null is given and NaN is happen, error may be occurred.
      maxArraySize - maximum array/block size
      maxDepth - maximum recursive called times of evaluate method
      maxLoopTimes - maximum loop times of "for", "while", and so on
  • Method Details

    • enableStderr

      public void enableStderr()
      Enables that error message outputs into stderr.
    • enableStderr

      public void enableStderr(boolean enable)
      Enables/disables that error message outputs into stderr.
      Parameters:
      enable - enabling stderr. When True is given, error message is outputted into stderr. Otherwise, it is not outputted.
    • getEnableStderr

      public boolean getEnableStderr()
      Gets whether outputting error message into stderr is enable.
      Returns:
      outputting error message into stderr is enable or not
    • getEnableStderr

      public static boolean getEnableStderr(@Nullable Config config)
      Gets whether outputting error message into stderr is enable.
      Parameters:
      config - Instance of configuration. When it is null, default value is returned.
      Returns:
      outputting error message into stderr is enable or not
    • enableTagDetail

      public void enableTagDetail()
      Enables that detail of error message's tag.
    • enableTagDetail

      public void enableTagDetail(boolean enable)
      Enables that detail of error message's tag.
      Parameters:
      enable - enabling the detail of tag. When true is given, error message's tag contains either of "Lexer", "Parser", or "Evaluator".
    • getEnableTagDetail

      public boolean getEnableTagDetail()
      Gets whether detail of error message's tag is enable or not.
      Returns:
      detail of error message's tag is enable or not.
    • getEnableTagDetail

      public static boolean getEnableTagDetail(@Nullable Config config)
      Gets whether detail of error message's tag is enable or not.
      Parameters:
      config - Instance of configuration. When it is null, default value is returned.
      Returns:
      detail of error message's tag is enable or not.
    • enableOnlyJson

      public void enableOnlyJson()
      Enables only JSON.
    • enableOnlyJson

      public void enableOnlyJson(boolean enable)
      Enables only JSON.
      Parameters:
      enable - enabling only JSON. When true is given, the given data is parsed as JSON. In other words, script is disabled.
    • getEnableOnlyJson

      public boolean getEnableOnlyJson()
      Gets whether parsing target is limited only JSON or not.
      Returns:
      parsing target is limited only JSON or not.
    • getEnableOnlyJson

      public static boolean getEnableOnlyJson(@Nullable Config config)
      Gets whether parsing target is limited only JSON or not.
      Parameters:
      config - Instance of configuration. When it is null, default value is returned.
      Returns:
      parsing target is limited only JSON or not.
    • setInfinity

      public void setInfinity(@Nullable String infinity)
      Sets infinity's string. When string is given, Infinity is allowed in JSON. Then the given string is used to input/output Infinity from/to JSON. (Note that it is not surrounded with quotation mark.) When null is given and Infinity is happen, error may be occurred.
      Parameters:
      infinity - Infinity's string or null.
    • getInfinity

      public @Nullable String getInfinity()
      Gets infinity's string.
      Returns:
      Infinity's string or null. When this is null, Infinity is not allowed.
    • getInfinity

      public static @Nullable String getInfinity(@Nullable Config config)
      Gets infinity's string.
      Parameters:
      config - Instance of configuration. When it is null, default value is returned.
      Returns:
      Infinity's string or null. When this is null, Infinity is not allowed.
    • setNaN

      public void setNaN(@Nullable String nan)
      Sets NaN(Not a Number)'s string. When string is given, NaN (Not a Number) is allowed in JSON. Then the given string is used to input/output NaN from/to JSON. (Note that it is not surrounded with quotation mark.) When null is given and NaN is happen, error may be occurred.
      Parameters:
      nan - NaN(Not a Number)'s string or null.
    • getNaN

      public @Nullable String getNaN()
      Gets NaN(Not a Number)'s string.
      Returns:
      NaN(Not a Number)'s string or null. When this is null, NaN is not allowed.
    • getNaN

      public static @Nullable String getNaN(@Nullable Config config)
      Get NaN(Not a Number)'s string.
      Parameters:
      config - Instance of configuration. When it is null, default value is returned.
      Returns:
      NaN(Not a Number)'s string or null. When this is null, NaN is not allowed.
    • setMaxArraySize

      public void setMaxArraySize(int size)
      Sets maximum array/block size.
      Parameters:
      size - maximum array/block size
    • getMaxArraySize

      public int getMaxArraySize()
      Gets maximum array/block size.
      Returns:
      maximum array/block size
    • getMaxArraySize

      public static int getMaxArraySize(@Nullable Config config)
      Gets maximum array/block size.
      Parameters:
      config - Instance of configuration. When it is null, default value is returned.
      Returns:
      maximum array/block size
    • setMaxDepth

      public void setMaxDepth(int depth)
      Set maximum recursive called times of evaluate method.
      Parameters:
      depth - maximum recursive called times of evaluate method
    • getMaxDepth

      public int getMaxDepth()
      Gets maximum recursive called times of evaluate method.
      Returns:
      maximum recursive called times of evaluate method
    • getMaxDepth

      public static int getMaxDepth(@Nullable Config config)
      Gets maximum recursive called times of evaluate method.
      Parameters:
      config - Instance of configuration. When it is null, default value is returned.
      Returns:
      maximum recursive called times of evaluate method
    • setMaxLoopTimes

      public void setMaxLoopTimes(int times)
      Sets maximum loop times of "for", "while", and so on.
      Parameters:
      times - maximum loop times of "for", "while", and so on
    • getMaxLoopTimes

      public int getMaxLoopTimes()
      Gets maximum loop times of "for", "while", and so on.
      Returns:
      maximum loop times of "for", "while", and so on
    • getMaxLoopTimes

      public static int getMaxLoopTimes(@Nullable Config config)
      Gets maximum loop times of "for", "while", and so on.
      Parameters:
      config - Instance of configuration. When it is null, default value is returned.
      Returns:
      maximum loop times of "for", "while", and so on