Package org.sentrysoftware.jawk.ext
Class StdinExtension
java.lang.Object
org.sentrysoftware.jawk.ext.AbstractExtension
org.sentrysoftware.jawk.ext.StdinExtension
- All Implemented Interfaces:
JawkExtension
Enable stdin processing in Jawk, to be used in conjunction with the -ni parameter.
Since normal input processing is turned off via -ni, this is provided to enable a way
to read input from stdin.
To use:
StdinGetline() == 1 { print "--> " $0 }
The extension functions are as follows:
-
StdinHasInput -
Returns 1 when StdinGetline() does not block (i.e., when input is available or upon an EOF), 0 otherwise.
Parameters:- none
- 1 when StdinGetline() does not block, 0 otherwise.
-
StdinGetline -
Retrieve a line of input from stdin. The operation will block until input is available, EOF, or an IO error.
Parameters:- none
- 1 upon successful read of a line of input from stdin, 0 upon an EOF, and -1 when an IO error occurs.
-
StdinBlock -
Block until a call to StdinGetline() would not block.
Parameters:- chained block function - optional
- "Stdin" if this block object is triggered
- Author:
- Danny Daglas
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionString[]
All the extended keywords supported by this extension.getExtensionName.void
init
(VariableManager vm, JRT jrt, AwkSettings settings) Called after the creation and before normal processing of the extension, pass in the Jawk Runtime Manager and the Variable Manager once.Invoke extension as a method.Methods inherited from class org.sentrysoftware.jawk.ext.AbstractExtension
getAssocArrayParameterPositions
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.sentrysoftware.jawk.ext.JawkExtension
getAssocArrayParameterPositions
-
Constructor Details
-
StdinExtension
public StdinExtension()
-
-
Method Details
-
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:
init
in interfaceJawkExtension
- Overrides:
init
in classAbstractExtension
- Parameters:
vm
- Reference to the Variable Managerjrt
- Reference to the Runtimesettings
- Reference to the settings
-
getExtensionName
getExtensionName.
- Specified by:
getExtensionName
in interfaceJawkExtension
- Returns:
- name of the extension package.
-
extensionKeywords
All the extended keywords supported by this extension.Note: Jawk will throw a runtime exception if the keyword collides with any other keyword in the system, extension or otherwise.
- Specified by:
extensionKeywords
in interfaceJawkExtension
- Returns:
- the list of keywords the extension provides support for
-
invoke
Invoke extension as a method.- Specified by:
invoke
in interfaceJawkExtension
- Parameters:
keyword
- The extension keyword.args
- Arguments to the extension.- Returns:
- The return value (result) of the extension.
-