KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > entity > util > EntityFindOptions


1 /*
2  * $Id: EntityFindOptions.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2002 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */

24 package org.ofbiz.entity.util;
25
26 import java.sql.ResultSet JavaDoc;
27
28 /**
29  * Contains a number of variables used to select certain advanced finding options.
30  *
31  *@author <a HREF="mailto:jonesde@ofbiz.org">David E. Jones</a>
32  *@author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
33  *@version $Rev: 5462 $
34  *@since 2.0
35  */

36 public class EntityFindOptions implements java.io.Serializable JavaDoc {
37
38     /** Type constant from the java.sql.ResultSet object for convenience */
39     public static final int TYPE_FORWARD_ONLY = ResultSet.TYPE_FORWARD_ONLY;
40
41     /** Type constant from the java.sql.ResultSet object for convenience */
42     public static final int TYPE_SCROLL_INSENSITIVE = ResultSet.TYPE_SCROLL_INSENSITIVE;
43
44     /** Type constant from the java.sql.ResultSet object for convenience */
45     public static final int TYPE_SCROLL_SENSITIVE = ResultSet.TYPE_SCROLL_SENSITIVE;
46
47     /** Concurrency constant from the java.sql.ResultSet object for convenience */
48     public static final int CONCUR_READ_ONLY = ResultSet.CONCUR_READ_ONLY;
49
50     /** Concurrency constant from the java.sql.ResultSet object for convenience */
51     public static final int CONCUR_UPDATABLE = ResultSet.CONCUR_UPDATABLE;
52
53     protected boolean specifyTypeAndConcur = true;
54     protected int resultSetType = TYPE_FORWARD_ONLY;
55     protected int resultSetConcurrency = CONCUR_READ_ONLY;
56     protected int fetchSize = -1;
57     protected int maxRows = -1;
58     protected boolean distinct = false;
59
60     /** Default constructor. Defaults are as follows:
61      * specifyTypeAndConcur = true
62      * resultSetType = TYPE_FORWARD_ONLY
63      * resultSetConcurrency = CONCUR_READ_ONLY
64      * distinct = false
65      * maxRows = 0 (all rows)
66      */

67     public EntityFindOptions() {}
68
69     public EntityFindOptions(boolean specifyTypeAndConcur, int resultSetType, int resultSetConcurrency, int fetchSize, int maxRows, boolean distinct) {
70         this.specifyTypeAndConcur = specifyTypeAndConcur;
71         this.resultSetType = resultSetType;
72         this.resultSetConcurrency = resultSetConcurrency;
73         this.fetchSize = fetchSize;
74         this.maxRows = maxRows;
75         this.distinct = distinct;
76     }
77
78     public EntityFindOptions(boolean specifyTypeAndConcur, int resultSetType, int resultSetConcurrency, boolean distinct) {
79         this(specifyTypeAndConcur, resultSetType, resultSetConcurrency, -1, -1, distinct);
80     }
81
82     /** If true the following two parameters (resultSetType and resultSetConcurrency) will be used to specify
83      * how the results will be used; if false the default values for the JDBC driver will be used
84      */

85     public boolean getSpecifyTypeAndConcur() {
86         return specifyTypeAndConcur;
87     }
88
89     /** If true the following two parameters (resultSetType and resultSetConcurrency) will be used to specify
90      * how the results will be used; if false the default values for the JDBC driver will be used
91      */

92     public void setSpecifyTypeAndConcur(boolean specifyTypeAndConcur) {
93         this.specifyTypeAndConcur = specifyTypeAndConcur;
94     }
95
96     /** Specifies how the ResultSet will be traversed. Available values: ResultSet.TYPE_FORWARD_ONLY,
97      * ResultSet.TYPE_SCROLL_INSENSITIVE or ResultSet.TYPE_SCROLL_SENSITIVE. See the java.sql.ResultSet JavaDoc for
98      * more information. If you want it to be fast, use the common default: ResultSet.TYPE_FORWARD_ONLY.
99      */

100     public int getResultSetType() {
101         return resultSetType;
102     }
103
104     /** Specifies how the ResultSet will be traversed. Available values: ResultSet.TYPE_FORWARD_ONLY,
105      * ResultSet.TYPE_SCROLL_INSENSITIVE or ResultSet.TYPE_SCROLL_SENSITIVE. See the java.sql.ResultSet JavaDoc for
106      * more information. If you want it to be fast, use the common default: ResultSet.TYPE_FORWARD_ONLY.
107      */

108     public void setResultSetType(int resultSetType) {
109         this.resultSetType = resultSetType;
110     }
111
112     /** Specifies whether or not the ResultSet can be updated. Available values:
113      * ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE. Should pretty much always be
114      * ResultSet.CONCUR_READ_ONLY with the Entity Engine.
115      */

116     public int getResultSetConcurrency() {
117         return resultSetConcurrency;
118     }
119
120     /** Specifies whether or not the ResultSet can be updated. Available values:
121      * ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE. Should pretty much always be
122      * ResultSet.CONCUR_READ_ONLY with the Entity Engine.
123      */

124     public void setResultSetConcurrency(int resultSetConcurrency) {
125         this.resultSetConcurrency = resultSetConcurrency;
126     }
127
128     /** Specifies the fetch size for this query. -1 will fall back to datasource settings. */
129     public int getFetchSize() {
130         return fetchSize;
131     }
132
133     /** Specifies the fetch size for this query. -1 will fall back to datasource settings. */
134     public void setFetchSize(int fetchSize) {
135         this.fetchSize = fetchSize;
136     }
137
138     /** Specifies the max number of rows to return, 0 means all rows. */
139     public int getMaxRows() {
140         return maxRows;
141     }
142
143     /** Specifies the max number of rows to return, 0 means all rows. */
144     public void setMaxRows(int maxRows) {
145         this.maxRows = maxRows;
146     }
147
148     /** Specifies whether the values returned should be filtered to remove duplicate values. */
149     public boolean getDistinct() {
150         return distinct;
151     }
152
153     /** Specifies whether the values returned should be filtered to remove duplicate values. */
154     public void setDistinct(boolean distinct) {
155         this.distinct = distinct;
156     }
157 }
158
Popular Tags