001    package railo.runtime.interpreter.ref.op;
002    
003    import java.math.BigDecimal;
004    
005    import railo.runtime.PageContext;
006    import railo.runtime.exp.PageException;
007    import railo.runtime.interpreter.ref.Ref;
008    import railo.runtime.interpreter.ref.RefSupport;
009    import railo.runtime.interpreter.ref.literal.LBigDecimal;
010    import railo.runtime.op.Caster;
011    
012    /**
013     * Plus operation
014     */
015    public abstract class Big extends RefSupport implements Ref {
016    
017            private Ref right;
018            private Ref left;
019    
020            /**
021             * constructor of the class
022             * @param left
023             * @param right
024             */
025            public Big(Ref left, Ref right) {
026                    
027                    
028                    this.left=left;
029                    this.right=right;
030            }
031    
032            protected static BigDecimal toBigDecimal(PageContext pc,Ref ref) throws PageException {
033                    if(ref instanceof LBigDecimal) return ((LBigDecimal)ref).getBigDecimal();
034                    return new BigDecimal(Caster.toString(ref.getValue(pc)));
035            }
036    
037            protected final BigDecimal getLeft(PageContext pc) throws PageException {
038                    return toBigDecimal(pc,left);
039            }
040            
041            protected final BigDecimal getRight(PageContext pc) throws PageException {
042                    return toBigDecimal(pc,right);
043            }
044    
045            @Override
046        public final String getTypeName() {
047                    return "operation";
048            }
049    
050    }