The KeyObject class is used by the results table to access methods and fields
of objects. This allows complex Java objects to be accessed using the same dot-syntax used
to access tables.
For example:
nM> res mystr "hello world"
nM> res mystr.charAt(2)
O: MYSTR.CHARAT(2) = l
nM> res mystr.class
O: MYSTR.CLASS = class java.lang.String
The simplified look-up of the keys is done as follows (see State Diagram for details):
null, return null.Table or KeyVector then do a normal
Table lookup.Keyable call
getKey(..) or setKey(..). If null is returned
continue on, otherwise return the result of calling getKey(..) or
setKey(..)."SIZE" then return the array size.)Chainable goto the next object in the chain and
repeat.
When looking for methods to access KeyObject looks for public
methods whose parameters match and whose names...
getXDelta has the acronym XD).getFrequency has the abbreviation FREQ).
Note: If a class is not public only the public methods
in a public superclass or interface will be accessible.
The Keyable interface allows a class to be accessible via a set of keys. To
use Keyable simply implement the three methods in the interface:
| Method Name | Description |
|---|---|
| getKeys() | Lists the available keys. |
| getKey(key) | Gets a key, returns null if unable to get a key via this interface. |
| setKey(key,value) | Sets a key, returns null if unable to get a key via this interface,
otherwise returns the new value of the key. |
The Chainable interface tells KeyObject that there is another class
sitting below this one that KeyObject can pass the keys on to. To use
Chainable simply implement the two methods in the interface:
| Method Name | Description |
|---|---|
| getNextLink() | Gets the next link in the chain that KeyObject should pass keys down
to. |
| getPrevLink() | Gets the previous link in the chain (or null if not applicable).
KeyObject does not use this method but some of the query functions
do. |
KeyObject can be found
in the KeyObject API documentation.