001 package railo.runtime.type; 002 003 import java.util.Map; 004 005 import railo.runtime.db.SQL; 006 import railo.runtime.exp.PageException; 007 008 /** 009 * inteface for resultset (query) object 010 */ 011 public interface Query extends Collection, Iterator,com.allaire.cfx.Query { 012 013 /** 014 * Constant <code>ORDER_ASC</code>, used for method sort 015 */ 016 public static final int ORDER_ASC=1; 017 018 /** 019 * Constant <code>ORDER_DESC</code>, used for method sort 020 */ 021 public static final int ORDER_DESC=2; 022 023 024 /** 025 * @return return how many lines are affected by a update/insert 026 */ 027 public int getUpdateCount(); 028 029 /** 030 * return a value of the resultset by specified column and row 031 * @param key column to get 032 * @param row row to get from (1-recordcount) 033 * @return value at the called poition 034 * @throws PageException if invalid position definition 035 * @deprecated use instead <code>{@link #getAt(railo.runtime.type.Collection.Key, int)}</code> 036 */ 037 public Object getAt(String key,int row) throws PageException; 038 039 /** 040 * return a value of the resultset by specified column and row 041 * @param key column to get 042 * @param row row to get from (1-recordcount) 043 * @return value at the called poition 044 * @throws PageException if invalid position definition 045 */ 046 public Object getAt(Collection.Key key,int row) throws PageException; 047 048 /** 049 * return a value of the resultset by specified column and row, otherwise to getAt this method throw no exception if value dont exist (return null) 050 * @param key column to get 051 * @param row row to get from (1-recordcount) 052 * @return value at the called poition 053 * @deprecated use instead <code>{@link #getAt(railo.runtime.type.Collection.Key, int, Object)}</code> 054 */ 055 public Object getAt(String key,int row, Object defaultValue); 056 057 /** 058 * return a value of the resultset by specified column and row, otherwise to getAt this method throw no exception if value dont exist (return null) 059 * @param key column to get 060 * @param row row to get from (1-recordcount) 061 * @return value at the called poition 062 */ 063 public Object getAt(Collection.Key key,int row, Object defaultValue); 064 065 /** 066 * set a value at the defined position 067 * @param key column to set 068 * @param row row to set 069 * @param value value to fill 070 * @return filled value 071 * @throws PageException 072 * @deprecated use instead <code>{@link #setAtEL(railo.runtime.type.Collection.Key, int, Object)}</code> 073 */ 074 public Object setAt(String key,int row, Object value) throws PageException; 075 076 /** 077 * set a value at the defined position 078 * @param key column to set 079 * @param row row to set 080 * @param value value to fill 081 * @return filled value 082 * @throws PageException 083 */ 084 public Object setAt(Collection.Key key,int row, Object value) throws PageException; 085 086 /** 087 * set a value at the defined position 088 * @param key column to set 089 * @param row row to set 090 * @param value value to fill 091 * @return filled value 092 * @deprecated use instead <code>{@link #setAtEL(railo.runtime.type.Collection.Key, int, Object)}</code> 093 */ 094 public Object setAtEL(String key,int row, Object value); 095 096 /** 097 * set a value at the defined position 098 * @param key column to set 099 * @param row row to set 100 * @param value value to fill 101 * @return filled value 102 */ 103 public Object setAtEL(Collection.Key key,int row, Object value); 104 105 /** 106 * adds a new row to the resultset 107 * @param count count of rows to add 108 * @return return if row is addded or nod (always true) 109 */ 110 public boolean addRow(int count); 111 112 /** 113 * remove row from query 114 * @param row 115 * @return return new rowcount 116 * @throws PageException 117 */ 118 public int removeRow(int row) throws PageException; 119 120 /** 121 * remove row from query 122 * @param row 123 * @return return new rowcount 124 */ 125 public int removeRowEL(int row); 126 127 /** 128 * adds a new column to the resultset 129 * @param columnName name of the new column 130 * @param content content of the new column inside a array (must have same size like query has records) 131 * @return if column is added return true otherwise false (always true, throw error when false) 132 * @throws PageException 133 * @deprecated use instead <code>{@link #addColumn(railo.runtime.type.Collection.Key, Array)}</code> 134 */ 135 public boolean addColumn(String columnName, Array content) throws PageException; 136 137 /** 138 * adds a new column to the resultset 139 * @param columnName name of the new column 140 * @param content content of the new column inside a array (must have same size like query has records) 141 * @return if column is added return true otherwise false (always true, throw error when false) 142 * @throws PageException 143 */ 144 public boolean addColumn(Collection.Key columnName, Array content) throws PageException; 145 146 /** 147 * adds a new column to the resultset 148 * @param columnName name of the new column 149 * @param content content of the new column inside a array (must have same size like query has records) 150 * @param type data type from (java.sql.Types) 151 * @return if column is added return true otherwise false (always true, throw error when false) 152 * @throws PageException 153 * @deprecated use instead <code>{@link #addColumn(railo.runtime.type.Collection.Key, Array, int)}</code> 154 */ 155 public boolean addColumn(String columnName, Array content, int type) throws PageException; 156 157 /** 158 * adds a new column to the resultset 159 * @param columnName name of the new column 160 * @param content content of the new column inside a array (must have same size like query has records) 161 * @param type data type from (java.sql.Types) 162 * @return if column is added return true otherwise false (always true, throw error when false) 163 * @throws PageException 164 */ 165 public boolean addColumn(Collection.Key columnName, Array content, int type) throws PageException; 166 167 /** 168 * @return Coloned Object 169 */ 170 public Object clone(); 171 172 173 /** 174 * @return return all types 175 */ 176 public int[] getTypes(); 177 178 /** 179 * @return returns all types as Map (key==column) 180 */ 181 public Map getTypesAsMap(); 182 183 /** 184 * return the query column matching to key 185 * @param key key to get 186 * @return QieryColumn object 187 * @throws PageException 188 * @deprecated use instead <code>{@link #getColumn(railo.runtime.type.Collection.Key)}</code> 189 */ 190 public QueryColumn getColumn(String key) throws PageException; 191 192 /** 193 * return the query column matching to key 194 * @param key key to get 195 * @return QieryColumn object 196 * @throws PageException 197 */ 198 public QueryColumn getColumn(Collection.Key key) throws PageException; 199 200 /** 201 * return the query column matching to key, if key not exist return null 202 * @param key key to get 203 * @return QieryColumn object 204 * @deprecated use instead <code>{@link #getColumn(railo.runtime.type.Collection.Key, QueryColumn)}</code> 205 */ 206 public QueryColumn getColumn(String key,QueryColumn column); 207 208 /** 209 * return the query column matching to key, if key not exist return null 210 * @param key key to get 211 * @return QieryColumn object 212 */ 213 public QueryColumn getColumn(Collection.Key key,QueryColumn column); 214 215 /** 216 * remove column matching to key 217 * @param key key to remove 218 * @return QueryColumn object removed 219 * @throws PageException 220 * @deprecated use instead <code>{@link #removeColumn(railo.runtime.type.Collection.Key)}</code> 221 */ 222 public QueryColumn removeColumn(String key) throws PageException; 223 224 /** 225 * remove column matching to key 226 * @param key key to remove 227 * @return QueryColumn object removed 228 * @throws PageException 229 */ 230 public QueryColumn removeColumn(Collection.Key key) throws PageException; 231 232 233 /** 234 * remove column matching to key 235 * @param key key to remove 236 * @return QueryColumn object removed or null if column not exist 237 * @deprecated use instead <code>{@link #removeColumnEL(railo.runtime.type.Collection.Key)}</code> 238 */ 239 public QueryColumn removeColumnEL(String key); 240 241 242 /** 243 * remove column matching to key 244 * @param key key to remove 245 * @return QueryColumn object removed or null if column not exist 246 */ 247 public QueryColumn removeColumnEL(Collection.Key key); 248 249 /** 250 * sets the execution Time of the query 251 * @param l 252 */ 253 public void setExecutionTime(long l); 254 255 /** 256 * sorts a query by a column, direction is asc 257 * @param column colun to sort 258 * @throws PageException 259 * @deprecated use instead <code>{@link #sort(railo.runtime.type.Collection.Key)}</code> 260 */ 261 public void sort(String column) throws PageException; 262 263 /** 264 * sorts a query by a column, direction is asc 265 * @param column colun to sort 266 * @throws PageException 267 */ 268 public void sort(Collection.Key column) throws PageException; 269 270 /** 271 * sorts a query by a column 272 * @param strColumn column to sort 273 * @param order sort type (Query.ORDER_ASC or Query.ORDER_DESC) 274 * @throws PageException 275 * @deprecated use instead <code>{@link #sort(railo.runtime.type.Collection.Key, int)}</code> 276 */ 277 public void sort(String strColumn, int order) throws PageException; 278 279 /** 280 * sorts a query by a column 281 * @param strColumn column to sort 282 * @param order sort type (Query.ORDER_ASC or Query.ORDER_DESC) 283 * @throws PageException 284 */ 285 public void sort(Collection.Key strColumn, int order) throws PageException; 286 287 /** 288 * sets if query is form cache or not 289 * @param isCached is cached or not 290 */ 291 public void setCached(boolean isCached); 292 293 /** 294 * is query from cache or not 295 * @return is cached or not 296 */ 297 public boolean isCached(); 298 299 /** 300 * @return returns struct with meta data to the query 301 */ 302 //public Struct getMetaData(); 303 304 /** 305 * @return returns array with meta data to the query (only column names and type) 306 */ 307 public Array getMetaDataSimple(); 308 309 310 311 public void rename(Collection.Key columnName,Collection.Key newColumnName) throws PageException; 312 313 public Collection.Key[] getColumnNames(); 314 315 public String[] getColumnNamesAsString(); 316 317 public Query getGeneratedKeys(); 318 319 public SQL getSql(); 320 321 public String getTemplate(); 322 323 /** 324 * @return return the query execution time in nanoseconds 325 */ 326 public long getExecutionTime(); 327 328 /** 329 * @return returns the execution time 330 * @deprecated use <code>getExecutionTime()</code> instead 331 */ 332 public int executionTime(); 333 334 335 }