Package io.jawk.util

Class AwkSettings

java.lang.Object
io.jawk.util.AwkSettings

public class AwkSettings extends Object
Reusable behavioral configuration for the Jawk engine.

Instances hold settings that control how the AWK interpreter behaves (field separator, locale, sorted keys, initial variables, and default record separator) but do not carry per-execution state such as input sources, filename arguments, or output destinations. This separation allows a single AwkSettings object to be shared across many invocations of Awk.eval(io.jawk.AwkExpression), Awk.script(io.jawk.AwkProgram), or Awk.createAvm().

Output is configured on the execution builder returned by Awk.script(String) or Awk.script(io.jawk.AwkProgram) and is therefore always per-execution.

Author:
Danny Daglas
  • Field Details

    • DEFAULT_SETTINGS

      public static final AwkSettings DEFAULT_SETTINGS
      Shared immutable settings instance representing the default configuration.
  • Constructor Details

    • AwkSettings

      public AwkSettings()
  • Method Details

    • toDescriptionString

      public String toDescriptionString()

      toDescriptionString.

      Returns:
      a human readable representation of the parameters values.
    • toExtensionDescription

      public String toExtensionDescription()
      Provides a description of extensions that are enabled/disabled. The default compiler implementation uses this method to describe extensions which are compiled into the script. The description is then provided to the user within the usage.
      Returns:
      A description of the extensions which are enabled/disabled.
    • getVariables

      public Map<String,Object> getVariables()
      Contains variable assignments which are applied prior to executing the script (-v assignments). The values may be of type Integer, Double, String, AssocArray (for array variables), any Map that Jawk exposes directly to the script, or any List that Jawk materializes as an array with zero-based Long keys.
      Returns:
      the variables
    • getModificationCount

      public long getModificationCount()
      Returns the number of explicit mutations applied to this settings instance.

      The value is intended for cache invalidation only; it has no behavioral meaning other than changing whenever one of the configuration mutators is called.

      Returns:
      the current modification counter
    • setVariables

      public void setVariables(Map<String,Object> variables)
      Contains variable assignments which are applied prior to executing the script (-v assignments). The values may be of type Integer, Double, String, AssocArray (for array variables), any Map that Jawk exposes directly to the script, or any List that Jawk materializes as an array with zero-based Long keys.
      Parameters:
      variables - the variables to set
    • putVariable

      public void putVariable(String name, Object value)
      Put or replace a variable entry.
      Parameters:
      name - Variable name
      value - Variable value
    • getFieldSeparator

      public String getFieldSeparator()
      Initial Field Separator (FS) value. null means the default FS value.
      Returns:
      the fieldSeparator
    • setFieldSeparator

      public void setFieldSeparator(String fieldSeparator)
      Initial Field Separator (FS) value. null means the default FS value.
      Parameters:
      fieldSeparator - the fieldSeparator to set
    • isUseSortedArrayKeys

      public boolean isUseSortedArrayKeys()
      Whether to maintain array keys in sorted order; false by default.
      Returns:
      the useSortedArrayKeys
    • setUseSortedArrayKeys

      public void setUseSortedArrayKeys(boolean useSortedArrayKeys)
      Whether to maintain array keys in sorted order; false by default.
      Parameters:
      useSortedArrayKeys - the useSortedArrayKeys to set
    • isAllowArraysOfArrays

      public boolean isAllowArraysOfArrays()
      Whether to accept gawk-style arrays of arrays syntax such as a[i][j] and subarray operands in array-only positions such as split(..., a[i]).
      Returns:
      true when arrays of arrays are enabled at compile time
    • setAllowArraysOfArrays

      public void setAllowArraysOfArrays(boolean allowArraysOfArrays)
      Enables or disables gawk-style arrays of arrays syntax such as a[i][j] and subarray operands in array-only positions such as split(..., a[i]) or for (k in a[i]).
      Parameters:
      allowArraysOfArrays - true to accept arrays-of-arrays features
    • getLocale

      public Locale getLocale()

      Getter for the field locale.

      Returns:
      the Locale that will be used for outputting numbers
    • setLocale

      public void setLocale(Locale pLocale)
      Sets the Locale for outputting numbers.
      Parameters:
      pLocale - The locale to be used (e.g.: Locale.US)
    • getDefaultRS

      public String getDefaultRS()

      Getter for the field defaultRS.

      Returns:
      the default RS, when not set by the AWK script
    • setDefaultRS

      public void setDefaultRS(String rs)
      Sets the default RS, when not set by the AWK script
      Parameters:
      rs - The regular expression that separates records