1/*2 * Copyright 2001-2008 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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 *16 */17package org.apache.juddi.api.util;
1819import java.util.ArrayList;
20import java.util.Hashtable;
21import java.util.List;
2223/**24 * Enum to represent the methods within the Subscription API.25 * 26 * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>27 */28public enum SubscriptionQueryimplementsUDDIQuery {
29 DELETE_SUBSCRIPTION("delete_subscription"),
30 GET_SUBSCRIPTIONRESULTS("get_subscriptionResults"),
31 GET_SUBSCRIPTIONS("get_subscriptions"),
32 SAVE_SUBSCRIPTION("save_subscription");
3334private String _query;
35privatestatic Hashtable<String, SubscriptionQuery> _subscriptionQueries = null;
3637SubscriptionQuery(final String query) {
38 _query = query;
39 }
4041public String getQuery() {
42return _query;
43 }
4445publicsynchronizedstaticvoid initSubscriptionQueries () {
46if (_subscriptionQueries == null) {
47 _subscriptionQueries = new Hashtable();
4849 _subscriptionQueries.put(SubscriptionQuery.DELETE_SUBSCRIPTION.getQuery(), SubscriptionQuery.DELETE_SUBSCRIPTION);
50 _subscriptionQueries.put(SubscriptionQuery.GET_SUBSCRIPTIONRESULTS.getQuery(), SubscriptionQuery.GET_SUBSCRIPTIONRESULTS);
51 _subscriptionQueries.put(SubscriptionQuery.GET_SUBSCRIPTIONS.getQuery(), SubscriptionQuery.GET_SUBSCRIPTIONS);
52 _subscriptionQueries.put(SubscriptionQuery.SAVE_SUBSCRIPTION.getQuery(), SubscriptionQuery.SAVE_SUBSCRIPTION);
53 }
54 }
5556publicstatic List<String> getQueries() {
57if (_subscriptionQueries == null) {
58 initSubscriptionQueries();
59 }
6061 List list = new ArrayList<String>(_subscriptionQueries.keySet());
62return list;
63 }
6465/**66 * this doesn't appear to be used anywhere and will be removed in a future version67 * @param query68 * @return69 * @deprecated70 */71publicstaticSubscriptionQuery fromQuery(final String query) {
72if (_subscriptionQueries == null) {
73 initSubscriptionQueries();
74 }
7576if (_subscriptionQueries.contains(query)) {
77return _subscriptionQueries.get(query);
78 } else {
79thrownew IllegalArgumentException("Unrecognized query " + query);
80 }
81 }
82 }