QJCC homepage

biz.chitec.quarterback.util.logic
Interface LogicExpr.Converter

Enclosing interface:
LogicExpr

public static interface LogicExpr.Converter

Special interface for value conversion. In some cases, it might be necessary to transform the values in universe-aware logical expressions (INExpr, EqualsExpr,...) before the actual evaluation of the expression can take place. E.g. the data might be given in an obscure data type which has to be converted first.

In this case, a LogicExpr.Converter instance can be used to perform this conversion in conjunction with the convertValues() method of the LogicExpr. A call could look like this:

 final Statement dbstmt=Connection.getStatement();
 anylogicexpr.convertValues(new LogicExpr.Converter() {
   public Object convert(Object o) {
     if (o instanceof AnObscureClass)
       return new Integer(((AnObscureClass)o).findMainIndexOfMyself(dbstmt));
     return o;
   }
 });
 
Implementing the conversion this way, we have the advantage that the LogicExpr framework does not need to know any peculiarities about the conversion procedure. It may be super-complicated or requiring a database or whatsoever.

The converter will always get the contents of the values. E.g. InExpr will pass over the contents of the value list, not the list itself.

If the convert() method fails for any reason, it should throw a RuntimeException. In this case, the conversion process will be aborted by passing the exception up the stack. The LogicExpr may be left partly converted.


Method Summary
 java.lang.Object convert(java.lang.Object o)
          Convert the given value into something else.
 

Method Detail

convert

public java.lang.Object convert(java.lang.Object o)
Convert the given value into something else.

Parameters:
o - A value in an expression
Returns:
The converted value, or the originally passed object, if no conversion is needed

QJCC homepage