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).booleanisPosix()Whether POSIX compile-time behavior is enforced, rejecting gawk syntax such as arrays of arrays (a[i][j], subarray operands likesplit(..., a[i])) and typed regexp literals (@/re/), and treating the gawk-specificBEGINFILE/ENDFILEpatterns as ordinary identifiers.booleanWhether to maintain array keys in sorted order;falseby default.protected final voidvoidputVariable(String name, Object value) Put or replace a variable entry.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.voidsetPosix(boolean posix) Enables or disables POSIX compile-time behavior.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
-
isPosix
public boolean isPosix()Whether POSIX compile-time behavior is enforced, rejecting gawk syntax such as arrays of arrays (a[i][j], subarray operands likesplit(..., a[i])) and typed regexp literals (@/re/), and treating the gawk-specificBEGINFILE/ENDFILEpatterns as ordinary identifiers.- Returns:
truewhen POSIX compile-time behavior is enforced
-
setPosix
public void setPosix(boolean posix) Enables or disables POSIX compile-time behavior. When enabled, gawk syntax such as arrays of arrays (a[i][j], subarray operands likesplit(..., a[i])orfor (k in a[i])) and typed regexp literals (@/re/) is rejected, and the gawk-specificBEGINFILE/ENDFILEpatterns are not special.- Parameters:
posix-trueto enforce POSIX compile-time behavior
-
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
-
markModified
protected final void markModified()
-