KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > model > query > cache > QueryConditonDatakey


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

16 package com.jdon.model.query.cache;
17
18 import java.io.Serializable JavaDoc;
19 import java.util.Collection JavaDoc;
20 import java.util.Iterator JavaDoc;
21
22 /**
23  * @author <a HREF="mailto:banqiao@jdon.com">banq</a>
24  *
25  */

26 public class QueryConditonDatakey implements Serializable JavaDoc{
27     
28     private String JavaDoc sqlquery;
29     private Collection JavaDoc queryParams;
30     private int start;
31     private int count = 200;
32     private int blockSize;
33
34         
35     /**
36      * @param sqlquery
37      * @param queryParams
38      */

39     public QueryConditonDatakey(String JavaDoc sqlquery, Collection JavaDoc queryParams) {
40         super();
41         this.sqlquery = sqlquery;
42         this.queryParams = queryParams;
43     }
44     
45     /**
46      * @param sqlquery
47      * @param queryParams
48      */

49     public QueryConditonDatakey(String JavaDoc sqlquery,
50                                 Collection JavaDoc queryParams,
51                                 int start, int count,
52                                 int blockSize) {
53         this.sqlquery = sqlquery;
54         this.queryParams = queryParams;
55         this.start = start;
56         this.count = count;
57         this.blockSize = blockSize;
58     }
59     /**
60      * @return Returns the queryParams.
61      */

62     public Collection JavaDoc getQueryParams() {
63         return queryParams;
64     }
65     /**
66      * @param queryParams The queryParams to set.
67      */

68     public void setQueryParams(Collection JavaDoc queryParams) {
69         this.queryParams = queryParams;
70     }
71     /**
72      * @return Returns the sqlquery.
73      */

74     public String JavaDoc getSqlquery() {
75         return sqlquery;
76     }
77     /**
78      * @param sqlquery The sqlquery to set.
79      */

80     public void setSqlquery(String JavaDoc sqlquery) {
81         this.sqlquery = sqlquery;
82     }
83     
84     
85     
86    
87     /**
88      * @return Returns the start.
89      */

90     public int getStart() {
91         return start;
92     }
93     /**
94      * @param start The start to set.
95      */

96     public void setStart(int start) {
97         this.start = start;
98     }
99     
100     public String JavaDoc getSQlKey(){
101         StringBuffer JavaDoc sb = new StringBuffer JavaDoc(sqlquery);
102         Iterator JavaDoc iter = queryParams.iterator();
103         while (iter.hasNext()) {
104             Object JavaDoc queryParamO = iter.next();
105             if (queryParamO != null){
106                 sb.append("+");
107                 sb.append(queryParamO.toString());
108             }
109         }
110         return sb.toString();
111     }
112     
113     
114     public String JavaDoc toString(){
115         return getSQlKey();
116     }
117     
118     public int getBlockStart(){
119         int blockID = start / count;
120         int blockStart = blockID * count;
121         return blockStart;
122     }
123     
124    
125     /**
126      * @return Returns the blockSize.
127      */

128     public int getBlockSize() {
129         return blockSize;
130     }
131     /**
132      * @param blockSize The blockSize to set.
133      */

134     public void setBlockSize(int blockSize) {
135         this.blockSize = blockSize;
136     }
137     /**
138      * @return Returns the blockSize.
139      */

140     public int getCount() {
141         return count;
142     }
143     /**
144      * @param blockSize The blockSize to set.
145      */

146     public void setCount(int count) {
147         this.count = count;
148     }
149 }
150
Popular Tags