Class AwkSettings

java.lang.Object
org.sentrysoftware.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
  • 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.
    • getOutputFilename

      public String getOutputFilename(String defaultFileName)

      Getter for the field outputFilename.

      Parameters:
      defaultFileName - The filename to return if -o argument is not used.
      Returns:
      the optarg for the -o parameter, or the defaultFileName parameter if -o is not utilized.
    • getScriptSources

      public List<ScriptSource> getScriptSources()

      Getter for the field scriptSources.

      Returns:
      the script sources meta info. This will usually be either one String container, made up of the script given on the command line directly, with the first non-"-" parameter, or one or multiple script file names (if provided with -f switches).
    • addScriptSource

      public void addScriptSource(ScriptSource scriptSource)
      Add the specified ScriptSource
      Parameters:
      scriptSource - ScriptSource instance to add
    • 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
    • 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
    • setNameValueOrFileNames

      public void setNameValueOrFileNames(List<String> nameValueOrFileNames)
      Contains name=value or filename entries. Order is important, which is why name=value and filenames are listed in the same List container.
      Parameters:
      nameValueOrFileNames - the nameValueOrFileNames to set
    • setScriptSources

      public void setScriptSources(List<ScriptSource> scriptSources)
      Script sources meta info. This will usually be either one String container, made up of the script given on the command line directly, with the first non-"-" parameter, or one or multiple script file names (if provided with -f switches).
      Parameters:
      scriptSources - the scriptSources to set
    • 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
    • isDumpSyntaxTree

      public boolean isDumpSyntaxTree()
      Whether to dump the syntax tree; false by default.
      Returns:
      the dumpSyntaxTree
    • setDumpSyntaxTree

      public void setDumpSyntaxTree(boolean dumpSyntaxTree)
      Whether to dump the syntax tree; false by default.
      Parameters:
      dumpSyntaxTree - the dumpSyntaxTree to set
    • isDumpIntermediateCode

      public boolean isDumpIntermediateCode()
      Whether to dump the intermediate code; false by default.
      Returns:
      the dumpIntermediateCode
    • setDumpIntermediateCode

      public void setDumpIntermediateCode(boolean dumpIntermediateCode)
      Whether to dump the intermediate code; false by default.
      Parameters:
      dumpIntermediateCode - the dumpIntermediateCode to set
    • isAdditionalFunctions

      public boolean isAdditionalFunctions()
      Whether to enable additional functions (_sleep/_dump); false by default.
      Returns:
      the additionalFunctions
    • setAdditionalFunctions

      public void setAdditionalFunctions(boolean additionalFunctions)
      Whether to enable additional functions (_sleep/_dump); false by default.
      Parameters:
      additionalFunctions - the additionalFunctions to set
    • isAdditionalTypeFunctions

      public boolean isAdditionalTypeFunctions()
      Whether to enable additional type functions (_INTEGER/_DOUBLE/_STRING); false by default.
      Returns:
      the additionalTypeFunctions
    • setAdditionalTypeFunctions

      public void setAdditionalTypeFunctions(boolean additionalTypeFunctions)
      Whether to enable additional type functions (_INTEGER/_DOUBLE/_STRING); false by default.
      Parameters:
      additionalTypeFunctions - the additionalTypeFunctions 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
    • isUserExtensions

      public boolean isUserExtensions()
      Whether user extensions are enabled; false by default.
      Returns:
      the userExtensions
    • setUserExtensions

      public void setUserExtensions(boolean userExtensions)
      Whether user extensions are enabled; false by default.
      Parameters:
      userExtensions - the userExtensions to set
    • isWriteIntermediateFile

      public boolean isWriteIntermediateFile()
      Write to intermediate file; false by default.
      Returns:
      the writeIntermediateFile
    • setWriteIntermediateFile

      public void setWriteIntermediateFile(boolean writeIntermediateFile)
      Write to intermediate file; false by default.
      Parameters:
      writeIntermediateFile - the writeIntermediateFile to set
    • getOutputFilename

      public String getOutputFilename()
      Output filename; null by default, which means the appropriate default file-name will get used.
      Returns:
      the outputFilename
    • setOutputFilename

      public void setOutputFilename(String outputFilename)
      Output filename; null by default, which means the appropriate default file-name will get used.
      Parameters:
      outputFilename - the outputFilename 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
    • getDestinationDirectory

      public String getDestinationDirectory()
      Compiled destination directory (if provided); "." by default.
      Returns:
      the destinationDirectory
    • setDestinationDirectory

      public void setDestinationDirectory(String destinationDirectory)
      Compiled destination directory (if provided).
      Parameters:
      destinationDirectory - the destinationDirectory to set, "." by default.
    • 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)