|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jawk.ext.AbstractExtension
org.jawk.ext.CoreExtension
public class CoreExtension
Extensions which make developing in Jawk and interfacing other extensions with Jawk much easier.
The extension functions which are available are as follows:
Array(array,1,3,5,7,9)Map(map,k1,v1,k2,v2,...,kN,vN),
or Map(k1,v1,k2,v2,...,kN,vN).MapUnion(map,k1,v1,k2,v2,...,kN,vN)cnt = MapCopy(aa_target, aa_source)typestring = TypeOf(item)str = String(3)dbl = Double(3)Halt()r = Timeout(300)Throw("this is an awkruntimeexception")print Version(aa)str = Date()b = FileExists("/a/b/c")
We attempt to alleviate these difficulties by adding references to Jawk via the CoreExtension module. References convert associative arrays into unique strings called reference handles. Since reference handles are strings, they can be assigned and returned via AWK functions without restriction. And, reference handles are then used by other reference extension functions to perform common associative array operations, such as associative array cell lookup and assignment, key existence check, and key iteration.
The reference model functions are explained below:
handle = NewRef(assocarray)val = DeRef(handle, key)return assocarray[key]
UnRef(handle)while(key = InRef(handle)) ...
for (key in assocarray)
...
where assocarray is the associative array referred to by
handle in the reference cache.
b = IsInRef(handle, key)
if (key in assocarray)
...
where assocarray is the associative array referred to by
handle in the reference cache.
DumpRefs()
| Field Summary |
|---|
| Fields inherited from class org.jawk.ext.AbstractExtension |
|---|
jrt, vm |
| Constructor Summary | |
|---|---|
CoreExtension()
|
|
| Method Summary | |
|---|---|
java.lang.String[] |
extensionKeywords()
All the extended keywords supported by this extension. |
int[] |
getAssocArrayParameterPositions(java.lang.String extension_keyword,
int num_args)
Assume no guarantee of any extension parameter being an associative array. |
java.lang.String |
getExtensionName()
The name of the extension package. |
java.lang.Object |
invoke(java.lang.String keyword,
java.lang.Object[] args)
Invoke extension as a method. |
| Methods inherited from class org.jawk.ext.AbstractExtension |
|---|
checkNumArgs, init, toAwkString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.jawk.ext.JawkExtension |
|---|
init |
| Constructor Detail |
|---|
public CoreExtension()
| Method Detail |
|---|
public java.lang.String getExtensionName()
JawkExtension
getExtensionName in interface JawkExtensionpublic java.lang.String[] extensionKeywords()
JawkExtensionNote: Jawk will throw a runtime exception if the keyword collides with any other keyword in the system, extension or otherwise.
extensionKeywords in interface JawkExtension
public int[] getAssocArrayParameterPositions(java.lang.String extension_keyword,
int num_args)
AbstractExtension
getAssocArrayParameterPositions in interface JawkExtensiongetAssocArrayParameterPositions in class AbstractExtensionextension_keyword - The extension keyword to check.num_args - The number of actual parameters used in this
extension invocation.
public java.lang.Object invoke(java.lang.String keyword,
java.lang.Object[] args)
JawkExtension
invoke in interface JawkExtensionkeyword - The extension keyword.args - Arguments to the extension.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||