|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface JawkExtension
A Jawk Extension.
Instances of this interface are eligible for insertion into Jawk as an extension to the language. Extensions appear within a Jawk script as function calls.
Extensions introduce native Java modules into the Jawk language. This enables special services into Jawk, such as Sockets, GUIs, databases, etc. natively into Jawk.
Extension functions can be used anywhere an AWK function, builtin or user-defined, can be used. One immediate consideration is the default Jawk input mechanism, where if action rules exist (other than BEGIN/END), Jawk requires input from stdin before processing these rules. It may be desirable to trigger action rules on an extension rather than stdin user input. To prohibit Jawk default behavior, a new command-line argument, "-ni" for "no input", disables Jawk default behavior of consuming input from stdin for action rules.
Note: By disabling Jawk's default behavior of consuming input from stdin, it can cause your script to loop through all of the action rule conditions repeatedly, consuming CPU without bounds. To guard against this, the extesion should provide some sort of poll or block call to avoid out-of-control CPU resource consumption.
Extensions introduce keywords into the Jawk parser. Keywords are of type _EXTENSION_ tokens. As a result, extension keywords cannot collide with other Jawk keywords, variables, or function names. The extension mechanism also guards against keyword collision with other extensions. The Jawk lexer expects extension keywords to match as _ID_'s.
Method Summary | |
---|---|
java.lang.String[] |
extensionKeywords()
All the extended keywords supported by this extension. |
int[] |
getAssocArrayParameterPositions(java.lang.String extension_keyword,
int num_args)
Define the parameters which are expected to be associative arrays. |
java.lang.String |
getExtensionName()
The name of the extension package. |
void |
init(VariableManager vm,
JRT jrt)
Called after the creation and before normal processing of the extension, pass in the Jawk Runtime Manager and the Variable Manager once. |
java.lang.Object |
invoke(java.lang.String keyword,
java.lang.Object[] args)
Invoke extension as a method. |
Method Detail |
---|
void init(VariableManager vm, JRT jrt)
It is guaranteed init() is called before invoke() is called.
java.lang.String getExtensionName()
java.lang.String[] extensionKeywords()
Note: Jawk will throw a runtime exception if the keyword collides with any other keyword in the system, extension or otherwise.
int[] getAssocArrayParameterPositions(java.lang.String extension_keyword, int num_args)
extension_keyword
- The extension keyword to check.num_args
- How many actual parameters are used in the call.
java.lang.Object invoke(java.lang.String keyword, java.lang.Object[] args)
keyword
- The extension keyword.args
- Arguments to the extension.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |