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