Package io.jawk.jrt
Interface VariableManager
- All Known Implementing Classes:
AVM,SandboxedAVM
public interface VariableManager
The AWK Variable Manager.
It provides getter/setter methods for global AWK variables.
Its purpose is to expose a variable management interface to
the JRT, even though the implementation is provided by
the AWK script at script compile-time.
The getters/setters here do not access all
special AWK variables, such as RSTART
and ENVIRON. That's because these variables
are not referred to within the JRT.
- Author:
- Danny Daglas
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidassignVariable(String name, Object value) Set the contents of a user-defined AWK variable.getARGC()getARGC.getARGV()getARGV.getCONVFMT.getFS()getFS.getOFS()getOFS.getORS()getORS.getRS()getRS.getSUBSEP.default ObjectgetVariable(String name) Returns the current value of a named global variable or JRT-managed special variable.voidincFNR()Increases the FNR variable by 1.voidincNR()Increases the NR variable by 1.voidresetFNR()Resets the FNR variable to 0.voidsetFILENAME(String fileName) Set the contents of the FILENAME variable.voidSet the contents of the NF variable.
-
Method Details
-
getARGC
Object getARGC()getARGC.
- Returns:
- the contents of the ARGC variable.
-
getARGV
Object getARGV()getARGV.
- Returns:
- the contents of the ARGV variable.
-
getCONVFMT
Object getCONVFMT()getCONVFMT.
- Returns:
- the contents of the CONVFMT variable.
-
getFS
Object getFS()getFS.
- Returns:
- the contents of the FS variable.
-
getRS
Object getRS()getRS.
- Returns:
- the contents of the RS variable.
-
getOFS
Object getOFS()getOFS.
- Returns:
- the contents of the OFS variable.
-
getORS
Object getORS()getORS.
- Returns:
- the contents of the ORS variable.
-
getSUBSEP
Object getSUBSEP()getSUBSEP.
- Returns:
- the contents of the SUBSEP variable.
-
getVariable
Returns the current value of a named global variable or JRT-managed special variable.The default implementation returns
nullso thatVariableManagerimplementations written before this lookup hook existed remain source and binary compatible; interpreters should override it.- Parameters:
name- variable name- Returns:
- the variable value, or
nullwhen it is unknown or untyped
-
setFILENAME
Set the contents of the FILENAME variable.- Parameters:
fileName- File name
-
setNF
Set the contents of the NF variable.- Parameters:
newNf- Value for NF
-
incNR
void incNR()Increases the NR variable by 1. -
incFNR
void incFNR()Increases the FNR variable by 1. -
resetFNR
void resetFNR()Resets the FNR variable to 0. -
assignVariable
Set the contents of a user-defined AWK variable. Used when processing name=value command-line arguments (either via -v or via ARGV).- Parameters:
name- The AWK variable name.value- The new contents of the variable.
-