KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > juddi > datatype > request > FindQualifiers


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

16 package org.apache.juddi.datatype.request;
17
18 import java.util.Vector JavaDoc;
19
20 import org.apache.juddi.datatype.RegistryObject;
21
22 /**
23  * "Knows about the creation and populating of FindQualifiers objects.
24  * Returns FindQualifiers."
25  *
26  * Example Usage:
27  *
28  * // build the find qualifiers instance
29  * FindQualifiers qualifiers = new FindQualifiers();
30  * qualifiers.add(new FindQualifier(FindQualifier.exactNameMatch));
31  * qualifiers.add(new FindQualifier(FindQualifier.andAllKeys));
32  *
33  * // set find qualifiers into request
34  * FindBusiness findBusiness = new FindBusiness();
35  * findBusiness.setFindQualifiers(qualifiers);
36  *
37  * @author Steve Viens (sviens@apache.org)
38  */

39 public class FindQualifiers implements RegistryObject
40 {
41   Vector JavaDoc findQualifierVector;
42
43   public boolean exactNameMatch;
44   public boolean caseSensitiveMatch;
45   public boolean orAllKeys;
46   public boolean orLikeKeys;
47   public boolean andAllKeys;
48   public boolean sortByNameAsc;
49   public boolean sortByNameDesc;
50   public boolean sortByDateAsc;
51   public boolean sortByDateDesc;
52   public boolean serviceSubset;
53   public boolean combineCategoryBags;
54
55   /**
56    *
57    */

58   public FindQualifiers()
59   {
60   }
61
62   /**
63    *
64    */

65   public FindQualifiers(int size)
66   {
67     this.findQualifierVector = new Vector JavaDoc(size);
68   }
69
70   /**
71    *
72    */

73   public void addFindQualifier(FindQualifier findQualifier)
74   {
75     // ignore null FindQualifier instances.
76
if (findQualifier == null)
77       return;
78
79     // ignore null/empty FindQualifier values.
80
String JavaDoc qValue = findQualifier.getValue();
81     if ((qValue == null) || (qValue.trim().length() == 0))
82       return;
83
84     if (this.findQualifierVector == null)
85       this.findQualifierVector = new Vector JavaDoc();
86     this.findQualifierVector.add(findQualifier);
87
88     if (qValue.equals(FindQualifier.EXACT_NAME_MATCH))
89       exactNameMatch = true;
90     else if (qValue.equals(FindQualifier.CASE_SENSITIVE_MATCH))
91       caseSensitiveMatch = true;
92     else if (qValue.equals(FindQualifier.OR_ALL_KEYS))
93       orAllKeys = true;
94     else if (qValue.equals(FindQualifier.OR_LIKE_KEYS))
95       orLikeKeys = true;
96     else if (qValue.equals(FindQualifier.AND_ALL_KEYS))
97       andAllKeys = true;
98     else if (qValue.equals(FindQualifier.SORT_BY_NAME_ASC))
99       sortByNameAsc = true;
100     else if (qValue.equals(FindQualifier.SORT_BY_NAME_DESC))
101       sortByNameDesc = true;
102     else if (qValue.equals(FindQualifier.SORT_BY_DATE_ASC))
103       sortByDateAsc = true;
104     else if (qValue.equals(FindQualifier.SORT_BY_DATE_DESC))
105       sortByDateDesc = true;
106     else if (qValue.equals(FindQualifier.SERVICE_SUBSET))
107       serviceSubset = true;
108     else if (qValue.equals(FindQualifier.COMBINE_CATEGORY_BAGS))
109       combineCategoryBags = true;
110   }
111
112   /**
113    *
114    */

115   public void setFindQualifierVector(Vector JavaDoc qualifierVector)
116   {
117     this.exactNameMatch = false;
118     this.caseSensitiveMatch = false;
119     this.orAllKeys = false;
120     this.orLikeKeys = false;
121     this.andAllKeys = false;
122     this.sortByNameAsc = false;
123     this.sortByNameDesc = false;
124     this.sortByDateAsc = false;
125     this.sortByDateDesc = false;
126     this.serviceSubset = false;
127     this.combineCategoryBags = false;
128
129     if ((qualifierVector != null) && (qualifierVector.size() > 0))
130     {
131       for (int i=0; i<qualifierVector.size(); i++)
132         addFindQualifier((FindQualifier)qualifierVector.elementAt(i));
133     }
134   }
135
136   /**
137    *
138    */

139   public Vector JavaDoc getFindQualifierVector()
140   {
141     return this.findQualifierVector;
142   }
143
144   /**
145    *
146    */

147   public int size()
148   {
149     if (this.findQualifierVector != null)
150       return this.findQualifierVector.size();
151     else
152       return 0;
153   }
154
155   // test driver
156
public static void main(String JavaDoc[] args)
157   {
158     FindQualifiers fq = new FindQualifiers();
159     fq.addFindQualifier(new FindQualifier(FindQualifier.CASE_SENSITIVE_MATCH));
160     fq.addFindQualifier(new FindQualifier(""));
161     fq.addFindQualifier(null);
162   }
163 }
Popular Tags