Re: Dot operators...
"Konstantin L. Metlov" <[email protected]> Thu, 15 Aug 2002 23:17:33 +0200 (CEST)
| Newsgroups | gmane.comp.java.jel.general |
|---|---|
| Message-ID | <[email protected]> |
Hello, Well, probably the word "dynamic" is overloaded too much. Let me define several _different_ dynamic things I'll be talking about. 1) "dynamic expressions", "dynamic evaluation of expressions", "dynamic loading of code" these do not have any special meaning in the further text sometimes they are used to express the purpose of JEL. 2) "dynamic library" (let's consider it a term and denote by an acronim "DL") stands for a set of classes whose non-static methods/fields are exported to JEL's namespace. The DL consists of all classes, passed in the second argument array to gnu.jel.Library constructor. The fields/methods of all DL classes become available in the _root_ namespace of the expressions. 3) "dynamic variables interface" (let's shorten it to "DVI") is a JEL interface allowing to add an extendable at run-time mappings between a names (possibly containing dots) in JEL namespace to function calls of getXXXValue() methods. Now, back to the point. The code you've sent is basically the same as before. It registeres the class PTResult as a part of DL. Therefore, making all its non-static methods available in the root namespace of the expressions. In partucular it adds the methods -- public int getTransID() -- public boolean isValid() to the root namespace, allowing the JEL expressions, containing their names to compile. For example the expressions "getTransID()", "getTransID", "getTransID+5", "isValid()", "!isValid()" will be successfully compiled by JEL and executed by java run-time (provided they are invoked the right way, but more on that later **). Your code also adds the "java.lang.String" class to JEL as a part of static library (passed in a first argument of the gnu.jel.Library constructor), which makes all its (j.l.S) _static_ methods/fields available in _root_ namespace of JEL expressions. These methods/fields are CASE_INSENSITIVE_ORDER -- String copyValueOf(char[] data) -- String copyValueOf(char[] data, int offset, int count) -- String valueOf(boolean b) ... -- String valueOf(long l) -- String valueOf(Object obj) NO OTHER NAMES BESIDES MARKED "--" ABOVE ARE DEFINED IN THE NAMESPACE YOU CONSTRUCTED. In particular it means neither "String", nor "testStr". Therefore JEL rightfully tells you that such names are undefined. If you want them defined -- define them. ** invocation of expressions. It is stressed in JEL documentation more than once that the methods of DL classes require "this" pointer to be passed on invocation and, therefore, you need to pass pointers to their instances to the expression's "evaluate" methos, and there must be a one-to-one correspondence between the elements of DL array (which are classes) and elements of "evaluate(Object [] context)" context array on invocation. Instead, in your example, even though you have DL defined the argument of evaluate is "null". I have corrested this problem in the diff file of my previous message to this mailing list (and to you). Did you read it ? Second. You are talking about the dot operator. It is said in the section of the dot operators in JEL manual that their behaviour is controlled by the last argument of the gnu.jel.Library constructor, and that the way to _forbide_ the dot operator is to pass "null" as that argument (just as you do it in your code). Did you read the documentation ? So, my final suggestion on this matter is -- RTFM. Konstantin.