org.quattor.pan.dml.operators
Class Add

java.lang.Object
  extended by org.quattor.pan.dml.AbstractOperation
      extended by org.quattor.pan.dml.operators.Add
All Implemented Interfaces:
Operation

public final class Add
extends AbstractOperation

Implements an addition operation for longs, doubles, and strings. If this is a numeric operation and one of the arguments is a double, the result is a double; otherwise, the result is a long.

Author:
loomis

Field Summary
 
Fields inherited from class org.quattor.pan.dml.AbstractOperation
ops, sourceRange
 
Method Summary
 Element execute(Context context)
          Perform the addition of the two top values on the data stack in the given DMLContext.
static Operation newOperation(SourceRange sourceRange, Operation... ops)
          Factory class for creating a new Add operation.
 
Methods inherited from class org.quattor.pan.dml.AbstractOperation
calculateArgs, calculateTerms, checkInvalidSelfContext, checkRestrictedContext, getOperations, getSourceRange, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

newOperation

public static Operation newOperation(SourceRange sourceRange,
                                     Operation... ops)
                              throws SyntaxException
Factory class for creating a new Add operation. Because of optimization, this class may actually return an element if the result can be determined at compile time.

Parameters:
sourceRange - location of this operation in the source
ops - arguments for this operation
Returns:
optimized Operation for this Add expression
Throws:
SyntaxException

execute

public Element execute(Context context)
Perform the addition of the two top values on the data stack in the given DMLContext. This method will handle long, double, and string values. Exceptions are thrown if the types of the arguments do not match or they are another type.

Specified by:
execute in interface Operation
Specified by:
execute in class AbstractOperation
Parameters:
context - evaluation context for the statement
Returns:
Element produced by running operation


Copyright © 2011 Quattor. All Rights Reserved.