001    package railo.runtime.type;
002    
003    import railo.runtime.Component;
004    import railo.runtime.PageContext;
005    import railo.runtime.PageSource;
006    import railo.runtime.component.Member;
007    import railo.runtime.dump.Dumpable;
008    import railo.runtime.exp.PageException;
009    import railo.runtime.ext.function.Function;
010    
011    /**
012     * a user defined function
013     * 
014     */
015    public interface UDF extends Function,Dumpable,Member,Cloneable {
016    
017            public static final int RETURN_FORMAT_WDDX=0;
018            public static final int RETURN_FORMAT_JSON=1;
019            public static final int RETURN_FORMAT_PLAIN=2;
020            public static final int RETURN_FORMAT_SERIALIZE=3;
021            public static final int RETURN_FORMAT_XML=4;
022            
023    
024        /**
025         * abstract method for the function Body
026         * @param pageContext
027         * @throws Throwable
028         */
029        public abstract Object implementation(PageContext pageContext)
030                throws Throwable;
031    
032        /**
033         * return all function arguments of this UDF
034         * @return the arguments.
035         * @throws PageException
036         */
037        public abstract FunctionArgument[] getFunctionArguments();
038    
039        /**
040         * @param pc
041         * @param index
042         * @return default value
043         * @throws PageException
044         */
045        public abstract Object getDefaultValue(PageContext pc, int index) throws PageException;
046        
047    
048        // FUTURE public abstract Object getDefaultValue(PageContext pc, int index, Object defaultValue);
049    
050        /**
051         * @return Returns the functionName.
052         */
053        public abstract String getFunctionName();
054    
055        /**
056         * @return Returns the output.
057         */
058        public abstract boolean getOutput();
059    
060        /**
061         * @return Returns the returnType.
062         */
063        public abstract int getReturnType();
064    
065        public abstract int getReturnFormat();
066    
067        /**
068         * returns null when not defined
069         * @return value of attribute securejson
070         */
071        public abstract Boolean getSecureJson();
072    
073        /**
074         * returns null when not defined
075         * @return value of attribute verifyclient
076         */
077        public abstract Boolean getVerifyClient();
078        
079        /**
080         * @return Returns the returnType.
081         */
082        public abstract String getReturnTypeAsString();
083    
084        public abstract String getDescription();
085        
086        /**
087         * call user defined Funcion with a hashmap of named values
088         * @param pageContext
089         * @param values named values
090         * @param doIncludePath 
091         * @return return value of the function
092         * @throws PageException
093         */
094        public abstract Object callWithNamedValues(PageContext pageContext,
095                Struct values, boolean doIncludePath) throws PageException;
096    
097        /**
098         * call user defined Funcion with parameters as Object Array
099         * @param pageContext
100         * @param args parameters for the function
101         * @param doIncludePath 
102         * @return return value of the function
103         * @throws PageException
104         */
105        public abstract Object call(PageContext pageContext, Object[] args,
106                boolean doIncludePath) throws PageException;
107    
108        /**
109         * @return Returns the displayName.
110         */
111        public abstract String getDisplayName();
112    
113        /**
114         * @return Returns the hint.
115         */
116        public abstract String getHint();
117    
118    
119        public abstract PageSource getPageSource();
120        
121            public abstract Struct getMetaData(PageContext pc) throws PageException; 
122            
123    
124            public UDF duplicate();
125            
126            /**
127             * it is the component in whitch this udf is constructed, must not be the same as active udf
128             * @return owner component
129             * @deprecated 
130             */
131            public Component getOwnerComponent();
132    
133            
134    }