Class AwkSettings

java.lang.Object
org.metricshub.jawk.util.AwkSettings

public class AwkSettings extends Object
A simple container for the parameters of a single AWK invocation. These values have defaults. These defaults may be changed through command line arguments, or when invoking Jawk programmatically, from within Java code.
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.
    • getInput

      public InputStream getInput()
      Where input is read from. By default, this is System.in.
      Returns:
      the input
    • setInput

      public void setInput(InputStream input)
      Where input is read from. By default, this is System.in.
      Parameters:
      input - the input to set
    • 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 or String.
      Returns:
      the variables
    • 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 or String.
      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
    • getNameValueOrFileNames

      public List<String> getNameValueOrFileNames()
      Contains name=value or filename entries. Order is important, which is why name=value and filenames are listed in the same List container.
      Returns:
      the nameValueOrFileNames
    • addNameValueOrFileName

      public void addNameValueOrFileName(String entry)
      Add a name=value or filename entry.
      Parameters:
      entry - entry to add
    • 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
    • getOutputStream

      public PrintStream getOutputStream()
      Output stream; System.out by default, which means we will print to stdout by default
      Returns:
      the output stream
    • setOutputStream

      public void setOutputStream(PrintStream pOutputStream)
      Sets the OutputStream to print to (instead of System.out by default)
      Parameters:
      pOutputStream - OutputStream to use for print statements
    • isCatchIllegalFormatExceptions

      public boolean isCatchIllegalFormatExceptions()
      Whether to trap IllegalFormatExceptions for [s]printf; true by default.
      Returns:
      the catchIllegalFormatExceptions
    • setCatchIllegalFormatExceptions

      public void setCatchIllegalFormatExceptions(boolean catchIllegalFormatExceptions)
      Whether to trap IllegalFormatExceptions for [s]printf; true by default.
      Parameters:
      catchIllegalFormatExceptions - the catchIllegalFormatExceptions to set
    • 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
    • getDefaultORS

      public String getDefaultORS()

      Getter for the field defaultORS.

      Returns:
      the default ORS, when not set by the AWK script
    • setDefaultORS

      public void setDefaultORS(String ors)
      Sets the default ORS, when not set by the AWK script
      Parameters:
      ors - The string that separates output records (with the print statement)