org.jawk.util
Class AwkParameters

java.lang.Object
  extended by org.jawk.util.AwkParameters

public class AwkParameters
extends java.lang.Object

Awk Parameters. It manages the command-line parameters accepted by Jawk. The parameters and their meanings are provided below:

followed by the script (if -f is not provided), then followed by a list containing zero or more of the following parameters:

If no filenames are provided, stdin is used as input to the script (but only if there are input rules).


Field Summary
 boolean additional_functions
          Whether to enable additional functions (_sleep/_dump); false by default.
 boolean additional_type_functions
          Whether to enable additional functions (_INTEGER/_DOUBLE/_STRING); false by default.
 boolean dump_intermediate_code
          Whether to dump the intermediate code; false by default.
 boolean dump_syntax_tree
          Whether to dump the syntax tree; false by default.
 java.lang.String initial_fs_value
          Initial FS value.
 java.util.Map<java.lang.String,java.lang.Object> initial_variables
          Contains variable assignments which are applied prior to executing the script (-v assignments).
 java.util.List<java.lang.String> name_value_filename_list
          Contains name=value or filename entries.
 boolean no_input
          Whether Jawk consumes stdin or ARGV file input; false by default.
 java.lang.String output_filename
          Output filename.
 java.lang.String script_filename
          Script filename (if provided).
 boolean should_compile
          Whether to interpret or compile the script.
 boolean should_compile_and_run
          Whether to compile and execute the script.
 boolean sorted_array_keys
          Whether to maintain array keys in sorted order; false by default.
 boolean trap_illegal_format_exceptions
          Whether to trap illegalformatexceptions for [s]printf; true by default.
 boolean user_extensions
          Whether user extensions are enabled; false by default.
 boolean write_to_intermediate_file
          Write to intermediate file.
 
Constructor Summary
AwkParameters(java.lang.Class mainclass, java.lang.String[] args, java.lang.String extension_description)
          Allocate the parameters, using the command line parameters from the VM entry point (main).
 
Method Summary
 java.lang.String destDirectory()
           
 java.lang.String extensionDescription()
          Provides a description of extensions that are enabled/disabled.
 java.io.InputStream ifInputStream()
          Obtain the InputStream containing the intermediate file.
 boolean isIntermediateFile()
          Determine if the -f optarg is an intermediate file.
 java.lang.String outputFilename(java.lang.String default_filename)
           
 java.io.Reader scriptReader()
          Obtain the Reader containing the script.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initial_variables

public java.util.Map<java.lang.String,java.lang.Object> initial_variables
Contains variable assignments which are applied prior to executing the script (-v assignments).


name_value_filename_list

public java.util.List<java.lang.String> name_value_filename_list
Contains name=value or filename entries. Order is important, which is why name=value and filenames are listed in the same List container.


script_filename

public java.lang.String script_filename
Script filename (if provided). If null, using the first non-"-" parameter.


should_compile

public boolean should_compile
Whether to interpret or compile the script. Initial value is set to false (interpret).


should_compile_and_run

public boolean should_compile_and_run
Whether to compile and execute the script. Initial value is set to false (interpret).


initial_fs_value

public java.lang.String initial_fs_value
Initial FS value. Initially set to null (default FS value).


dump_syntax_tree

public boolean dump_syntax_tree
Whether to dump the syntax tree; false by default.


dump_intermediate_code

public boolean dump_intermediate_code
Whether to dump the intermediate code; false by default.


additional_functions

public boolean additional_functions
Whether to enable additional functions (_sleep/_dump); false by default.


additional_type_functions

public boolean additional_type_functions
Whether to enable additional functions (_INTEGER/_DOUBLE/_STRING); false by default.


sorted_array_keys

public boolean sorted_array_keys
Whether to maintain array keys in sorted order; false by default.


trap_illegal_format_exceptions

public boolean trap_illegal_format_exceptions
Whether to trap illegalformatexceptions for [s]printf; true by default.


user_extensions

public boolean user_extensions
Whether user extensions are enabled; false by default.


no_input

public boolean no_input
Whether Jawk consumes stdin or ARGV file input; false by default.


write_to_intermediate_file

public boolean write_to_intermediate_file
Write to intermediate file. Initially set to false.


output_filename

public java.lang.String output_filename
Output filename. Initially set to null (use appropriate default filename).

Constructor Detail

AwkParameters

public AwkParameters(java.lang.Class mainclass,
                     java.lang.String[] args,
                     java.lang.String extension_description)
Allocate the parameters, using the command line parameters from the VM entry point (main).

The command-line argument semantics are as follows:

Parameters:
mainclass - The main class to print when displaying usage.
args - The command-line arguments provided by the user.
extension_description - a text description of extensions that are enabled (for compiled scripts)
Method Detail

isIntermediateFile

public boolean isIntermediateFile()
Determine if the -f optarg is an intermediate file. Intermediate files end with the .ai extension. No other determination is made whether the file is an intermediate file or not. That is, the content of the file is not checked.

Returns:
true if the -f optarg is an intermediate file (a file ending in .ai), false otherwise.

scriptReader

public java.io.Reader scriptReader()
Obtain the Reader containing the script. This returns non-null only if the -f argument is utilized.

Returns:
The reader which contains the script, null if no script file is provided.

ifInputStream

public java.io.InputStream ifInputStream()
Obtain the InputStream containing the intermediate file. This returns non-null only if the -f argument is utilized and it refers to an intermediate file.

Returns:
The reader which contains the intermediate file, null if either the -f argument is not used, or the argument does not refer to an intermediate file.

outputFilename

public java.lang.String outputFilename(java.lang.String default_filename)
Parameters:
default_filename - The filename to return if -o argument is not used.
Returns:
the optarg for the -o parameter, or the default_filename parameter if -o is not utilized.

destDirectory

public java.lang.String destDirectory()
Returns:
the optarg for the -d parameter, or null if -d is not utilized.

extensionDescription

public java.lang.String extensionDescription()
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.