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