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