Package io.jawk.ext
Class AbstractExtension
java.lang.Object
io.jawk.ext.AbstractExtension
- All Implemented Interfaces:
JawkExtension
- Direct Known Subclasses:
GawkExtension,StdinExtension
Base class of various extensions.
Provides functionality common to most extensions, such as VM and JRT variable management, and convenience methods such as checkNumArgs() and toAwkString().
- Author:
- Danny Daglas
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeStart(AVM avm, JRT runtime) Called after the runtime global variable slots have been allocated and before the first executable tuple runs.protected static voidcheckNumArgs(Object[] arr, int expectedNum) Verifies that an exact number of arguments has been passed in by checking the length of the argument array.Returns the mapping between Awk keywords and the functions implemented by this extension.getExtensionName.protected JRTgetJrt()Getter for the fieldjrt.protected AwkSettingsGetter for the fieldsettings.protected VariableManagergetVm()Getter for the fieldvm.voidinit(VariableManager vmParam, JRT runtime, AwkSettings conf) Called after the creation and before normal processing of the extension, pass in the Jawk Runtime Manager and the Variable Manager once.protected final StringtoAwkString(Object obj) Convert a Jawk variable to a Jawk string based on the value of the CONVFMT variable.
-
Constructor Details
-
AbstractExtension
public AbstractExtension()
-
-
Method Details
-
getExtensionName
getExtensionName.
- Specified by:
getExtensionNamein interfaceJawkExtension- Returns:
- name of the extension package.
-
init
Called after the creation and before normal processing of the extension, pass in the Jawk Runtime Manager and the Variable Manager once.It is guaranteed init() is called before invoke() is called.
- Specified by:
initin interfaceJawkExtension- Parameters:
vmParam- Reference to the Variable Managerruntime- Reference to the Runtimeconf- Reference to the settings
-
toAwkString
Convert a Jawk variable to a Jawk string based on the value of the CONVFMT variable.- Parameters:
obj- The Jawk variable to convert to a Jawk string.- Returns:
- A string representation of obj after CONVFMT has been applied.
-
checkNumArgs
Verifies that an exact number of arguments has been passed in by checking the length of the argument array.- Parameters:
arr- The arguments to check.expectedNum- The expected number of arguments.
-
getJrt
Getter for the field
jrt.- Returns:
- the Runtime
-
getVm
Getter for the field
vm.- Returns:
- the Variable Manager
-
getSettings
Getter for the field
settings.- Returns:
- the Settings
-
getExtensionFunctions
Returns the mapping between Awk keywords and the functions implemented by this extension. The returned map must be unmodifiable.- Specified by:
getExtensionFunctionsin interfaceJawkExtension- Returns:
- mapping from keyword to
ExtensionFunction
-
beforeStart
Called after the runtime global variable slots have been allocated and before the first executable tuple runs.- Specified by:
beforeStartin interfaceJawkExtension- Parameters:
avm- interpreter instance about to execute the tuple streamruntime- runtime services associated withavm
-