001 package railo.runtime.type; 002 003 import railo.commons.lang.CFTypes; 004 import railo.commons.lang.StringUtil; 005 import railo.runtime.ComponentImpl; 006 import railo.runtime.PageContext; 007 import railo.runtime.component.Property; 008 import railo.runtime.exp.PageException; 009 import railo.runtime.type.Collection.Key; 010 011 public final class UDFGetterProperty extends UDFGSProperty { 012 013 private final Property prop; 014 //private ComponentScope scope; 015 private final Key propName; 016 017 public UDFGetterProperty(ComponentImpl component,Property prop) { 018 super(component,"get"+StringUtil.ucFirst(prop.getName()),new FunctionArgument[0],CFTypes.TYPE_STRING,"wddx"); 019 this.prop=prop; 020 this.propName=KeyImpl.getInstance(prop.getName()); 021 } 022 023 @Override 024 public UDF duplicate(ComponentImpl c) { 025 return new UDFGetterProperty(c,prop); 026 } 027 028 029 public UDF duplicate() { 030 return duplicate(component); 031 } 032 033 @Override 034 public Object call(PageContext pageContext, Object[] args,boolean doIncludePath) throws PageException { 035 return component.getComponentScope().get(pageContext, propName,null); 036 } 037 038 @Override 039 public Object callWithNamedValues(PageContext pageContext, Struct values,boolean doIncludePath) throws PageException { 040 return component.getComponentScope().get(pageContext,propName,null); 041 } 042 043 @Override 044 public Object implementation(PageContext pageContext) throws Throwable { 045 return component.getComponentScope().get(pageContext,propName,null); 046 } 047 048 @Override 049 public Object getDefaultValue(PageContext pc, int index) throws PageException { 050 return null; 051 } 052 053 @Override 054 public Object getDefaultValue(PageContext pc, int index, Object defaultValue) throws PageException { 055 return defaultValue; 056 } 057 058 @Override 059 public String getReturnTypeAsString() { 060 return prop.getType(); 061 } 062 063 064 }