Package org.metricshub.jawk.util
Class AwkSettings
java.lang.Object
org.metricshub.jawk.util.AwkSettings
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final AwkSettingsShared immutable settings instance representing the default configuration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNameValueOrFileName(String entry) Add a name=value or filename entry.Getter for the fielddefaultORS.Getter for the fielddefaultRS.Initial Field Separator (FS) value.getInput()Where input is read from.Getter for the fieldlocale.Contains name=value or filename entries.Output stream;System.outby default, which means we will print to stdout by defaultContains variable assignments which are applied prior to executing the script (-v assignments).booleanWhether to trapIllegalFormatExceptionsfor[s]printf;trueby default.booleanWhether to maintain array keys in sorted order;falseby default.voidputVariable(String name, Object value) Put or replace a variable entry.voidsetCatchIllegalFormatExceptions(boolean catchIllegalFormatExceptions) Whether to trapIllegalFormatExceptionsfor[s]printf;trueby default.voidsetDefaultORS(String ors) Sets the default ORS, when not set by the AWK scriptvoidsetDefaultRS(String rs) Sets the default RS, when not set by the AWK scriptvoidsetFieldSeparator(String fieldSeparator) Initial Field Separator (FS) value.voidsetInput(InputStream input) Where input is read from.voidSets the Locale for outputting numbersvoidsetOutputStream(PrintStream pOutputStream) Sets the OutputStream to print to (instead of System.out by default)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.
-
getInput
Where input is read from. By default, this isSystem.in.- Returns:
- the input
-
setInput
Where input is read from. By default, this isSystem.in.- Parameters:
input- the input to set
-
getVariables
Contains variable assignments which are applied prior to executing the script (-v assignments). The values may be of typeInteger,DoubleorString.- Returns:
- the variables
-
setVariables
Contains variable assignments which are applied prior to executing the script (-v assignments). The values may be of typeInteger,DoubleorString.- Parameters:
variables- the variables to set
-
putVariable
Put or replace a variable entry.- Parameters:
name- Variable namevalue- Variable value
-
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
Add a name=value or filename entry.- Parameters:
entry- entry to add
-
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
-
getOutputStream
Output stream;System.outby default, which means we will print to stdout by default- Returns:
- the output stream
-
setOutputStream
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 trapIllegalFormatExceptionsfor[s]printf;trueby default.- Returns:
- the catchIllegalFormatExceptions
-
setCatchIllegalFormatExceptions
public void setCatchIllegalFormatExceptions(boolean catchIllegalFormatExceptions) Whether to trapIllegalFormatExceptionsfor[s]printf;trueby default.- Parameters:
catchIllegalFormatExceptions- the catchIllegalFormatExceptions to set
-
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
-
getDefaultORS
Getter for the field
defaultORS.- Returns:
- the default ORS, when not set by the AWK script
-
setDefaultORS
Sets the default ORS, when not set by the AWK script- Parameters:
ors- The string that separates output records (with the print statement)
-