001 package railo.runtime.interpreter.ref.cast; 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 * cast 011 */ 012 public final class Casting extends RefSupport implements Ref { 013 014 private short type; 015 private Ref ref; 016 private Object val; 017 private PageContext pc; 018 private String strType; 019 020 /** 021 * constructor of the class 022 * @param pc 023 * @param strType 024 * @param type 025 * @param ref 026 */ 027 public Casting(PageContext pc,String strType,short type, Ref ref) { 028 this.pc=pc; 029 this.type=type; 030 this.strType=strType; 031 this.ref=ref; 032 } 033 public Casting(PageContext pc,String strType,short type, Object val) { 034 this.pc=pc; 035 this.type=type; 036 this.strType=strType; 037 this.val=val; 038 } 039 040 /** 041 * @see railo.runtime.interpreter.ref.Ref#getValue() 042 */ 043 public Object getValue() throws PageException { 044 if(val!=null) return Caster.castTo(pc,type,strType,val); 045 return Caster.castTo(pc,type,strType,ref.getValue()); 046 } 047 048 public Ref getRef() { 049 return ref; 050 } 051 052 public String getStringType() { 053 return strType; 054 } 055 056 public short getType() { 057 return type; 058 } 059 060 public String getTypeName() { 061 return "operation"; 062 } 063 }