KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > vfs > search > Query


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (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 http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.vfs.search;
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.List JavaDoc;
23
24 /**
25  * This class acts as the logical container for all the objects
26  * that form a complete VirtualFileSystem search query.
27  *
28  * @author Matthew Large
29  * @version $Revision: 1.1 $
30  *
31  */

32 public class Query {
33     
34     /**
35      * List of {@link ConditionGroup} objects.
36      */

37     private ArrayList JavaDoc m_aConditionGroups = new ArrayList JavaDoc(3);
38     
39     /**
40      * List of {@link Order} objects.
41      */

42     private ArrayList JavaDoc m_aOrders = new ArrayList JavaDoc(3);
43     
44     /**
45      * List of {@link Scope} objects.
46      */

47     private ArrayList JavaDoc m_aScopes = new ArrayList JavaDoc(3);
48     
49     /**
50      * List of {@link Select} objects.
51      */

52     private ArrayList JavaDoc m_aSelectProps = new ArrayList JavaDoc(3);
53     
54     /**
55      * Limit for the number of results to be returned.
56      */

57     private int m_nLimit = -1;
58     
59     /**
60      * Adds a ConditionGroup to a Query. Multiple nested ConditionGroups
61      * can be added to a Query.
62      *
63      * @param condGroup ConditionGroup to be added
64      */

65     public void addConditionGroup(ConditionGroup condGroup) {
66         this.m_aConditionGroups.add(condGroup);
67     }
68     
69     /**
70      * Returns a list of condition groups.
71      *
72      * @return List of {@link ConditionGroup} objects.
73      */

74     public List JavaDoc getConditionGroups() {
75         return (List JavaDoc) this.m_aConditionGroups.clone();
76     }
77     
78     /**
79      * Adds an Order to a query. Multiple Orders may be added.
80      *
81      * @param order Order to be added
82      */

83     public void addOrder(Order order) {
84         this.m_aOrders.add(order);
85     }
86     
87     /**
88      * Returns a list of orders.
89      *
90      * @return List of {@link Order} objects.
91      */

92     public List JavaDoc getOrders() {
93         return (List JavaDoc) this.m_aOrders.clone();
94     }
95     
96     /**
97      * Adds a Scope to a query. Multiple scopes may be added.
98      *
99      * @param scope Scope to be added
100      */

101     public void addScope(Scope scope) {
102         this.m_aScopes.add(scope);
103     }
104     
105     /**
106      * Returns a list of scopes.
107      *
108      * @return List of {@link Scope} objects
109      */

110     public List JavaDoc getScopes() {
111         return (List JavaDoc) this.m_aScopes.clone();
112     }
113     
114     /**
115      * Adds a SelectProperty to a query. Multiple SelectProperties may be added.
116      *
117      * @param select Select to be added
118      */

119     public void addSelectProperty(Select select) {
120         this.m_aSelectProps.add(select);
121     }
122     
123     /**
124      * Returns a list of selects.
125      *
126      * @return List of {@link Select} objects.
127      */

128     public List JavaDoc getSelectProperties() {
129         return (List JavaDoc) this.m_aSelectProps.clone();
130     }
131     
132     /**
133      * Sets the maximim number of results.
134      *
135      * @param nLimit Number of results to return from the query
136      */

137     public void setLimit(int nLimit) {
138         this.m_nLimit = nLimit;
139     }
140     
141     /**
142      * Returns the result limit.
143      *
144      * @return Result limit.
145      */

146     public int getLimit() {
147         return this.m_nLimit;
148     }
149
150 }
151
Popular Tags