commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Horsman <b...@logicalcobwebs.co.uk>
Subject [PATCH] Re: [jexl] - checking for unresolved variables
Date Sat, 10 Jan 2004 19:21:58 GMT
Jexl Patch:

I've made some changes to allow for strict checking of unknown variables
inside an expression. Please see attached patch plus one new class
(UnknownVariableException). The changes were simple enough. The 

  JexlHelper.createContext() 

method is now overridden with a new 

  JexlHelper.createContext(boolean strict) 

method. The old one just calls the new one with strict = false. So the
default behaviour is unchanged.

Then I decided to make HashMapContext use the composition pattern to
contain a HashMap rather than extend it. This allowed me to ensure that
everything else used my new getVar() method rather than getting stuff
directly from the Map. The getVar() method contains the code that
decides whether to throw an Exception (strict) or return a null
(lenient).

This meant changes to JexlContext and quite a few changes (mostly to
test classes) that were using jc.getVars() to get direct access to the
Map. IMHO, it is a bad idea to expose the map in that way.

Finally, I added a test method called testUnknownVariables() to JexlTest
to check it all works. And it does :) 

-
Bill

Mime
View raw message