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