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            /**
024             * @see railo.runtime.type.UDF#duplicate()
025             */
026            public UDF duplicate(ComponentImpl c) {
027                    return new UDFGetterProperty(c,prop);
028            }
029            
030    
031            public UDF duplicate() {
032                    return duplicate(component);
033            }
034            
035            /**
036             * @see railo.runtime.type.UDF#call(railo.runtime.PageContext, java.lang.Object[], boolean)
037             */
038            public Object call(PageContext pageContext, Object[] args,boolean doIncludePath) throws PageException {
039                    return component.getComponentScope().get(pageContext, propName,null);
040            }
041    
042            /**
043             * @see railo.runtime.type.UDF#callWithNamedValues(railo.runtime.PageContext, railo.runtime.type.Struct, boolean)
044             */
045            public Object callWithNamedValues(PageContext pageContext, Struct values,boolean doIncludePath) throws PageException {
046                    return component.getComponentScope().get(pageContext,propName,null);
047            }
048    
049            /**
050             * @see railo.runtime.type.UDF#implementation(railo.runtime.PageContext)
051             */
052            public Object implementation(PageContext pageContext) throws Throwable {
053                    return component.getComponentScope().get(pageContext,propName,null);
054            }
055            
056            /**
057             * @see railo.runtime.type.UDF#getDefaultValue(railo.runtime.PageContext, int)
058             */
059            public Object getDefaultValue(PageContext pc, int index) throws PageException {
060                    return null;
061            }
062    
063            /**
064             * @see railo.runtime.type.UDF#getReturnTypeAsString()
065             */
066            public String getReturnTypeAsString() {
067                    return prop.getType();
068            }
069    
070    
071    }