Package org.sentrysoftware.jawk.util
Class AwkSettings
java.lang.Object
org.sentrysoftware.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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addScriptSource
(ScriptSource scriptSource) Add the specified ScriptSourceGetter for the fielddefaultORS
.Getter for the fielddefaultRS
.Compiled destination directory (if provided);"."
by default.Initial Field Separator (FS) value.getInput()
Where input is read from.Getter for the fieldlocale
.Contains name=value or filename entries.Output filename;null
by default, which means the appropriate default file-name will get used.getOutputFilename
(String defaultFileName) Getter for the fieldoutputFilename
.Output stream;System.out
by default, which means we will print to stdout by defaultGetter for the fieldscriptSources
.Contains variable assignments which are applied prior to executing the script (-v assignments).boolean
Whether to enable additional functions (_sleep/_dump);false
by default.boolean
Whether to enable additional type functions (_INTEGER/_DOUBLE/_STRING);false
by default.boolean
Whether to trapIllegalFormatExceptions
for[s]printf
;true
by default.boolean
Whether to dump the intermediate code;false
by default.boolean
Whether to dump the syntax tree;false
by default.boolean
Whether user extensions are enabled;false
by default.boolean
Whether to maintain array keys in sorted order;false
by default.boolean
Write to intermediate file;false
by default.void
setAdditionalFunctions
(boolean additionalFunctions) Whether to enable additional functions (_sleep/_dump);false
by default.void
setAdditionalTypeFunctions
(boolean additionalTypeFunctions) Whether to enable additional type functions (_INTEGER/_DOUBLE/_STRING);false
by default.void
setCatchIllegalFormatExceptions
(boolean catchIllegalFormatExceptions) Whether to trapIllegalFormatExceptions
for[s]printf
;true
by default.void
setDefaultORS
(String ors) Sets the default ORS, when not set by the AWK scriptvoid
setDefaultRS
(String rs) Sets the default RS, when not set by the AWK scriptvoid
setDestinationDirectory
(String destinationDirectory) Compiled destination directory (if provided).void
setDumpIntermediateCode
(boolean dumpIntermediateCode) Whether to dump the intermediate code;false
by default.void
setDumpSyntaxTree
(boolean dumpSyntaxTree) Whether to dump the syntax tree;false
by default.void
setFieldSeparator
(String fieldSeparator) Initial Field Separator (FS) value.void
setInput
(InputStream input) Where input is read from.void
Sets the Locale for outputting numbersvoid
setNameValueOrFileNames
(List<String> nameValueOrFileNames) Contains name=value or filename entries.void
setOutputFilename
(String outputFilename) Output filename;null
by default, which means the appropriate default file-name will get used.void
setOutputStream
(PrintStream pOutputStream) Sets the OutputStream to print to (instead of System.out by default)void
setScriptSources
(List<ScriptSource> scriptSources) Script sources meta info.void
setUserExtensions
(boolean userExtensions) Whether user extensions are enabled;false
by default.void
setUseSortedArrayKeys
(boolean useSortedArrayKeys) Whether to maintain array keys in sorted order;false
by default.void
setVariables
(Map<String, Object> variables) Contains variable assignments which are applied prior to executing the script (-v assignments).void
setWriteIntermediateFile
(boolean writeIntermediateFile) Write to intermediate file;false
by default.toDescriptionString.Provides a description of extensions that are enabled/disabled.
-
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.
-
getOutputFilename
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
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
Add the specified ScriptSource- Parameters:
scriptSource
- ScriptSource instance to add
-
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
,Double
orString
.- Returns:
- the variables
-
setVariables
Contains variable assignments which are applied prior to executing the script (-v assignments). The values may be of typeInteger
,Double
orString
.- Parameters:
variables
- the variables to set
-
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
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
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
Initial Field Separator (FS) value.null
means the default FS value.- Returns:
- the fieldSeparator
-
setFieldSeparator
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
Output filename;null
by default, which means the appropriate default file-name will get used.- Returns:
- the outputFilename
-
setOutputFilename
Output filename;null
by default, which means the appropriate default file-name will get used.- Parameters:
outputFilename
- the outputFilename to set
-
getOutputStream
Output stream;System.out
by 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
-
getDestinationDirectory
Compiled destination directory (if provided);"."
by default.- Returns:
- the destinationDirectory
-
setDestinationDirectory
Compiled destination directory (if provided).- Parameters:
destinationDirectory
- the destinationDirectory to set,"."
by default.
-
isCatchIllegalFormatExceptions
public boolean isCatchIllegalFormatExceptions()Whether to trapIllegalFormatExceptions
for[s]printf
;true
by default.- Returns:
- the catchIllegalFormatExceptions
-
setCatchIllegalFormatExceptions
public void setCatchIllegalFormatExceptions(boolean catchIllegalFormatExceptions) Whether to trapIllegalFormatExceptions
for[s]printf
;true
by 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)
-