org.apache.openjpa.kernel.exps
Class MathVal

java.lang.Object
  extended by org.apache.openjpa.kernel.exps.Val
      extended by org.apache.openjpa.kernel.exps.MathVal
All Implemented Interfaces:
Serializable, Value
Direct Known Subclasses:
Add, Divide, Mod, Multiply, Subtract

abstract class MathVal
extends Val

Value produced by a mathematical operation on two values.

Author:
Abe White

Constructor Summary
MathVal(Val val1, Val val2)
          Constructor.
 
Method Summary
 void acceptVisit(ExpressionVisitor visitor)
          Accept a visit from a tree visitor.
protected  Object eval(Object candidate, Object orig, StoreContext ctx, Object[] params)
          Return this value for the given candidate.
 Class getType()
          Return the expected type for this value, or Object if the type is unknown.
protected abstract  Object operate(Object o1, Class c1, Object o2, Class c2)
          Return the result of this mathematical operation on the two values.
 void setImplicitType(Class type)
          Set the implicit type of the value, based on how it is used in the filter.
 
Methods inherited from class org.apache.openjpa.kernel.exps.Val
eval, evaluate, evaluate, getMetaData, isAggregate, isVariable, isXPath, setMetaData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathVal

public MathVal(Val val1,
               Val val2)
Constructor. Provide the values to operate on.

Method Detail

getType

public Class getType()
Description copied from interface: Value
Return the expected type for this value, or Object if the type is unknown.


setImplicitType

public void setImplicitType(Class type)
Description copied from interface: Value
Set the implicit type of the value, based on how it is used in the filter. This method is only called on values who return Object from Value.getType().


eval

protected Object eval(Object candidate,
                      Object orig,
                      StoreContext ctx,
                      Object[] params)
Description copied from class: Val
Return this value for the given candidate.

Specified by:
eval in class Val

operate

protected abstract Object operate(Object o1,
                                  Class c1,
                                  Object o2,
                                  Class c2)
Return the result of this mathematical operation on the two values.


acceptVisit

public void acceptVisit(ExpressionVisitor visitor)
Description copied from interface: Value
Accept a visit from a tree visitor.

Specified by:
acceptVisit in interface Value
Overrides:
acceptVisit in class Val


Copyright © 2006-2013 Apache Software Foundation. All Rights Reserved.