KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Groups conditions in either an AND or OR group. The conditions can be
26  * property conditions, content conditions or other condition groups.
27  *
28  * @author Matthew Large
29  * @version $Revision: 1.1 $
30  *
31  */

32 public class ConditionGroup {
33     
34     /**
35      * AND group type identifier.
36      */

37     public static final String JavaDoc AND = "and";
38     
39     /**
40      * OR group type identifier.
41      */

42     public static final String JavaDoc OR = "or";
43     
44     /**
45      * Group type of this condition group.
46      */

47     private String JavaDoc m_sType = ConditionGroup.AND;
48     
49     /**
50      * List of {@link PropertyCondition} objects.
51      */

52     private ArrayList JavaDoc m_aPropertyConditions = new ArrayList JavaDoc(3);
53     
54     /**
55      * List of {@link ContentCondition} objects.
56      */

57     private ArrayList JavaDoc m_aContentConditions = new ArrayList JavaDoc(3);
58     
59     /**
60      * List of {@link ConditionGroup} objects.
61      */

62     private ArrayList JavaDoc m_aConditionGroups = new ArrayList JavaDoc(3);
63
64     /**
65      * Constructs a new condition group.
66      *
67      * @param sType Either 'and' or 'or'
68      * @see ConditionGroup#AND
69      * @see ConditionGroup#OR
70      */

71     public ConditionGroup(String JavaDoc sType) {
72         super();
73         this.m_sType=sType;
74     }
75     
76     /**
77      * Returns the type of this ConditionGroup.
78      *
79      * @return String, either 'and' or 'or'
80      * @see ConditionGroup#AND
81      * @see ConditionGroup#OR
82      */

83     public String JavaDoc getType() {
84         return this.m_sType;
85     }
86     
87     /**
88      * Adds a content condition.
89      *
90      * @param cond ContentConditon to be added
91      */

92     public void addContentCondition(ContentCondition cond) {
93         this.m_aContentConditions.add(cond);
94     }
95     
96     /**
97      * Adds a property condition.
98      *
99      * @param cond PropertyCondition to be added
100      */

101     public void addPropertyCondition(PropertyCondition cond) {
102         this.m_aPropertyConditions.add(cond);
103     }
104     
105     /**
106      * Adds a sub condition group.
107      *
108      * @param group ConditionGroup to be added
109      */

110     public void addConditionGroup(ConditionGroup group) {
111         this.m_aConditionGroups.add(group);
112     }
113     
114     /**
115      * Returns the content conditions.
116      *
117      * @return List of {@link ContentCondition} objects
118      */

119     public List JavaDoc getContentConditions() {
120         return (List JavaDoc) this.m_aContentConditions.clone();
121     }
122     
123     /**
124      * Returns the property conditions.
125      *
126      * @return List of {@link PropertyCondition} objects
127      */

128     public List JavaDoc getPropertyConditions() {
129         return (List JavaDoc) this.m_aPropertyConditions.clone();
130     }
131     
132     /**
133      * Returns the sub condition groups.
134      *
135      * @return List of {@link ConditionGroup} objects
136      */

137     public List JavaDoc getConditionGroups() {
138         return (List JavaDoc) this.m_aConditionGroups.clone();
139     }
140
141 }
142
Popular Tags