001 package railo.runtime.util; 002 003 import railo.runtime.PageContext; 004 import railo.runtime.exp.PageException; 005 import railo.runtime.type.Collection; 006 import railo.runtime.type.Struct; 007 008 /** 009 * Variable Util 010 */ 011 public interface VariableUtil { 012 013 /** 014 * return a property from the given Object, when property doesn't exists return null 015 * @param pc 016 * @param coll Collection to check 017 * @param key to get from Collection 018 * @return value or null 019 */ 020 public abstract Object getCollection(PageContext pc, Object coll, 021 String key, Object defaultValue); 022 023 /** 024 * return a property from the given Object, when property doesn't exists return null 025 * @param pc 026 * @param coll Collection to check 027 * @param key to get from Collection 028 * @return value or null 029 * @deprecated use instead <code>get(PageContext pc, Object coll, Collection.Key key, Object defaultValue);</code> 030 */ 031 public abstract Object get(PageContext pc, Object coll, String key, Object defaultValue); 032 033 /** 034 * return a property from the given Object, when property doesn't exists return null 035 * @param pc 036 * @param coll Collection to check 037 * @param key to get from Collection 038 * @return value or null 039 */ 040 public abstract Object get(PageContext pc, Object coll, Collection.Key key, Object defaultValue); 041 042 /** 043 * return a property from the given Object, when property doesn't exists return null 044 * @param pc 045 * @param coll Collection to check 046 * @param key to get from Collection 047 * @return value or null 048 */ 049 public abstract Object getLight(PageContext pc, Object coll, String key, Object defaultValue); 050 051 /** 052 * return a property from the given Object, when coll is a query return a Column,when property doesn't exists throw exception 053 * @param pc 054 * @param coll Collection to check 055 * @param key to get from Collection 056 * @return value value to get 057 * @throws PageException 058 */ 059 public abstract Object getCollection(PageContext pc, Object coll, String key) 060 throws PageException; 061 062 /** 063 * return a property from the given Object, when property doesn't exists throw exception 064 * @param pc 065 * @param coll Collection to check 066 * @param key to get from Collection 067 * @return value value to get 068 * @throws PageException 069 */ 070 public abstract Object get(PageContext pc, Object coll, String key) 071 throws PageException; 072 073 /** 074 * sets a value to the Object 075 * @param pc 076 * @param coll Collection to check 077 * @param key to get from Collection 078 * @param value Value to set 079 * @return value setted 080 * @throws PageException 081 */ 082 public abstract Object set(PageContext pc, Object coll, String key, 083 Object value) throws PageException; 084 085 // FUTURE add and set above to depr public Object set(PageContext pc, Object coll, Collection.Key key,Object value) throws PageException { 086 087 /** 088 * sets a value to the Object 089 * @param pc 090 * @param coll Collection to check 091 * @param key to get from Collection 092 * @param value Value to set 093 * @return value setted or null if can't set 094 * @deprecated use instead <code>setEL(PageContext pc, Object coll, Collection.Key key,Object value);</code> 095 */ 096 public abstract Object setEL(PageContext pc, Object coll, String key,Object value); 097 098 /** 099 * sets a value to the Object 100 * @param pc 101 * @param coll Collection to check 102 * @param key to get from Collection 103 * @param value Value to set 104 * @return value setted or null if can't set 105 */ 106 public abstract Object setEL(PageContext pc, Object coll, Collection.Key key,Object value); 107 108 /** 109 * remove value from Collection 110 * @param coll 111 * @param key 112 * @return has cleared or not 113 */ 114 public abstract Object removeEL(Object coll, String key); 115 116 /** 117 * clear value from Collection 118 * @param coll 119 * @param key 120 * @return has cleared or not 121 * @throws PageException 122 */ 123 public abstract Object remove(Object coll, String key) throws PageException; 124 125 /** 126 * call a Function (UDF, Method) with or witout named values 127 * @param pc 128 * @param coll Collection of the UDF Function 129 * @param key name of the function 130 * @param args arguments to call the function 131 * @return return value of the function 132 * @throws PageException 133 */ 134 public abstract Object callFunction(PageContext pc, Object coll, 135 String key, Object[] args) throws PageException; 136 137 /** 138 * call a Function (UDF, Method) without Named Values 139 * @param pc 140 * @param coll Collection of the UDF Function 141 * @param key name of the function 142 * @param args arguments to call the function 143 * @return return value of the function 144 * @throws PageException 145 * @deprecated use instead <code>callFunctionWithoutNamedValues(PageContext pc, Object coll, Collection.Key key, Object[] args)</code> 146 */ 147 public abstract Object callFunctionWithoutNamedValues(PageContext pc, 148 Object coll, String key, Object[] args) throws PageException; 149 150 /** 151 * call a Function (UDF, Method) without Named Values 152 * @param pc 153 * @param coll Collection of the UDF Function 154 * @param key name of the function 155 * @param args arguments to call the function 156 * @return return value of the function 157 * @throws PageException 158 */ 159 public Object callFunctionWithoutNamedValues(PageContext pc, 160 Object coll, Collection.Key key, Object[] args) throws PageException; 161 162 /** 163 * call a Function (UDF, Method) with Named Values 164 * @param pc 165 * @param coll Collection of the UDF Function 166 * @param key name of the function 167 * @param args arguments to call the function 168 * @return return value of the function 169 * @throws PageException 170 * @deprecated use instead <code>callFunctionWithNamedValues(PageContext pc, Object coll, Collection.Key key, Object[] args)</code> 171 */ 172 public abstract Object callFunctionWithNamedValues(PageContext pc, 173 Object coll, String key, Object[] args) throws PageException; 174 175 176 177 /** 178 * call a Function (UDF, Method) with Named Values 179 * @param pc 180 * @param coll Collection of the UDF Function 181 * @param key name of the function 182 * @param args arguments to call the function 183 * @return return value of the function 184 * @throws PageException 185 */ 186 public Object callFunctionWithNamedValues(PageContext pc, 187 Object coll, Collection.Key key, Object[] args) throws PageException; 188 189 public Object callFunctionWithNamedValues(PageContext pc, 190 Object coll, Collection.Key key, Struct args) throws PageException; 191 192 }