001    package railo.runtime.interpreter.ref.op;
002    
003    import railo.runtime.PageContext;
004    import railo.runtime.exp.PageException;
005    import railo.runtime.interpreter.ref.Ref;
006    import railo.runtime.interpreter.ref.RefSupport;
007    import railo.runtime.op.Caster;
008    
009    /**
010     * Plus operation
011     */
012    public final class Div extends RefSupport implements Ref {
013    
014        private Ref right;
015        private Ref left;
016    
017        /**
018         * constructor of the class
019         * @param left
020         * @param right
021         */
022        public Div(Ref left, Ref right) {
023            this.left=left;
024            this.right=right;
025        }
026    
027        @Override
028            public Object getValue(PageContext pc) throws PageException {
029            double r=Caster.toDoubleValue(right.getValue(pc));
030            if(r==0d)throw new ArithmeticException("Division by zero is not possible");
031            return new Double(Caster.toDoubleValue(left.getValue(pc))/r);
032        }
033    
034        @Override
035        public String getTypeName() {
036            return "operation";
037        }
038    
039    }