KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > language > markup > xsp > PostgresOldEsqlQuery


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.cocoon.components.language.markup.xsp;
18
19 import java.sql.SQLException JavaDoc;
20 import java.sql.ResultSet JavaDoc;
21 import java.sql.Connection JavaDoc;
22
23 /**
24  * @author <a HREF="mailto:tcurdt@apache.org">Torsten Curdt</a>
25  * @version CVS $Id: PostgresOldEsqlQuery.java 30932 2004-07-29 17:35:38Z vgritsenko $
26  */

27 final public class PostgresOldEsqlQuery extends AbstractEsqlQuery {
28
29     public PostgresOldEsqlQuery(Connection JavaDoc connection, String JavaDoc query) {
30         super(connection, query);
31     }
32
33     /**
34      * Only newInstance may use this contructor
35      * @param resultSet
36      */

37     private PostgresOldEsqlQuery(ResultSet JavaDoc resultSet) {
38         super(resultSet);
39     }
40
41     /**
42      * Create a EsqlQuery of the same type
43      * @param resultSet
44      */

45     public AbstractEsqlQuery newInstance(final ResultSet JavaDoc resultSet) {
46         return(new PostgresOldEsqlQuery(resultSet));
47     }
48
49     public String JavaDoc getQueryString() throws SQLException JavaDoc {
50         if (getSkipRows() > 0) {
51             if (getMaxRows() > -1) {
52                 return (new StringBuffer JavaDoc(super.getQueryString())
53                         .append(" LIMIT ").append(getMaxRows()+1)
54                         .append(",").append(getSkipRows())
55                         .toString());
56             }
57             else {
58                 return (new StringBuffer JavaDoc(super.getQueryString())
59                         .append(" OFFSET ").append(getSkipRows())
60                         .toString());
61             }
62         }
63         else {
64             if (getMaxRows() > -1) {
65                 return (new StringBuffer JavaDoc(super.getQueryString())
66                         .append(" LIMIT ").append(getMaxRows()+1)
67                         .toString());
68             }
69             else {
70                 return (super.getQueryString());
71             }
72         }
73     }
74
75     public void getResultRows() throws SQLException JavaDoc {
76         setPosition(getSkipRows());
77     }
78 }
79
Popular Tags