001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.vfs.search;
020:
021: import java.util.ArrayList;
022: import java.util.List;
023:
024: /**
025: * This class acts as the logical container for all the objects
026: * that form a complete VirtualFileSystem search query.
027: *
028: * @author Matthew Large
029: * @version $Revision: 1.1 $
030: *
031: */
032: public class Query {
033:
034: /**
035: * List of {@link ConditionGroup} objects.
036: */
037: private ArrayList m_aConditionGroups = new ArrayList(3);
038:
039: /**
040: * List of {@link Order} objects.
041: */
042: private ArrayList m_aOrders = new ArrayList(3);
043:
044: /**
045: * List of {@link Scope} objects.
046: */
047: private ArrayList m_aScopes = new ArrayList(3);
048:
049: /**
050: * List of {@link Select} objects.
051: */
052: private ArrayList m_aSelectProps = new ArrayList(3);
053:
054: /**
055: * Limit for the number of results to be returned.
056: */
057: private int m_nLimit = -1;
058:
059: /**
060: * Adds a ConditionGroup to a Query. Multiple nested ConditionGroups
061: * can be added to a Query.
062: *
063: * @param condGroup ConditionGroup to be added
064: */
065: public void addConditionGroup(ConditionGroup condGroup) {
066: this .m_aConditionGroups.add(condGroup);
067: }
068:
069: /**
070: * Returns a list of condition groups.
071: *
072: * @return List of {@link ConditionGroup} objects.
073: */
074: public List getConditionGroups() {
075: return (List) this .m_aConditionGroups.clone();
076: }
077:
078: /**
079: * Adds an Order to a query. Multiple Orders may be added.
080: *
081: * @param order Order to be added
082: */
083: public void addOrder(Order order) {
084: this .m_aOrders.add(order);
085: }
086:
087: /**
088: * Returns a list of orders.
089: *
090: * @return List of {@link Order} objects.
091: */
092: public List getOrders() {
093: return (List) this .m_aOrders.clone();
094: }
095:
096: /**
097: * Adds a Scope to a query. Multiple scopes may be added.
098: *
099: * @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 getScopes() {
111: return (List) 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 getSelectProperties() {
129: return (List) 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: }
|