Class AwkSettings
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final AwkSettingsShared immutable settings instance representing the default configuration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGetter for the fielddefaultRS.Initial Field Separator (FS) value.Getter for the fieldlocale.longReturns the number of explicit mutations applied to this settings instance.Contains variable assignments which are applied prior to executing the script (-v assignments).booleanWhether to accept gawk-style arrays of arrays syntax such asa[i][j]and subarray operands in array-only positions such assplit(..., a[i]).booleanWhether to maintain array keys in sorted order;falseby default.voidputVariable(String name, Object value) Put or replace a variable entry.voidsetAllowArraysOfArrays(boolean allowArraysOfArrays) Enables or disables gawk-style arrays of arrays syntax such asa[i][j]and subarray operands in array-only positions such assplit(..., a[i])orfor (k in a[i]).voidsetDefaultRS(String rs) Sets the default RS, when not set by the AWK scriptvoidsetFieldSeparator(String fieldSeparator) Initial Field Separator (FS) value.voidSets the Locale for outputting numbers.voidsetUseSortedArrayKeys(boolean useSortedArrayKeys) Whether to maintain array keys in sorted order;falseby default.voidsetVariables(Map<String, Object> variables) Contains variable assignments which are applied prior to executing the script (-v assignments).toDescriptionString.Provides a description of extensions that are enabled/disabled.
-
Field Details
-
DEFAULT_SETTINGS
Shared immutable settings instance representing the default configuration.
-
-
Constructor Details
-
AwkSettings
public AwkSettings()
-
-
Method Details
-
toDescriptionString
toDescriptionString.
- Returns:
- a human readable representation of the parameters values.
-
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
Contains variable assignments which are applied prior to executing the script (-v assignments). The values may be of typeInteger,Double,String,AssocArray(for array variables), anyMapthat Jawk exposes directly to the script, or anyListthat Jawk materializes as an array with zero-basedLongkeys.- 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
Contains variable assignments which are applied prior to executing the script (-v assignments). The values may be of typeInteger,Double,String,AssocArray(for array variables), anyMapthat Jawk exposes directly to the script, or anyListthat Jawk materializes as an array with zero-basedLongkeys.- Parameters:
variables- the variables to set
-
putVariable
Put or replace a variable entry.- Parameters:
name- Variable namevalue- Variable value
-
getFieldSeparator
Initial Field Separator (FS) value.nullmeans the default FS value.- Returns:
- the fieldSeparator
-
setFieldSeparator
Initial Field Separator (FS) value.nullmeans the default FS value.- Parameters:
fieldSeparator- the fieldSeparator to set
-
isUseSortedArrayKeys
public boolean isUseSortedArrayKeys()Whether to maintain array keys in sorted order;falseby default.- Returns:
- the useSortedArrayKeys
-
setUseSortedArrayKeys
public void setUseSortedArrayKeys(boolean useSortedArrayKeys) Whether to maintain array keys in sorted order;falseby default.- Parameters:
useSortedArrayKeys- the useSortedArrayKeys to set
-
isAllowArraysOfArrays
public boolean isAllowArraysOfArrays()Whether to accept gawk-style arrays of arrays syntax such asa[i][j]and subarray operands in array-only positions such assplit(..., a[i]).- Returns:
truewhen arrays of arrays are enabled at compile time
-
setAllowArraysOfArrays
public void setAllowArraysOfArrays(boolean allowArraysOfArrays) Enables or disables gawk-style arrays of arrays syntax such asa[i][j]and subarray operands in array-only positions such assplit(..., a[i])orfor (k in a[i]).- Parameters:
allowArraysOfArrays-trueto accept arrays-of-arrays features
-
getLocale
Getter for the field
locale.- Returns:
- the Locale that will be used for outputting numbers
-
setLocale
Sets the Locale for outputting numbers.- Parameters:
pLocale- The locale to be used (e.g.:Locale.US)
-
getDefaultRS
Getter for the field
defaultRS.- Returns:
- the default RS, when not set by the AWK script
-
setDefaultRS
Sets the default RS, when not set by the AWK script- Parameters:
rs- The regular expression that separates records
-