This project has retired. For details please refer to its Attic page.
SubscriptionQuery xref
View Javadoc
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 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   */
17  package org.apache.juddi.api.util;
18  
19  import java.util.ArrayList;
20  import java.util.Hashtable;
21  import java.util.List;
22  
23  /**
24   * Enum to represent the methods within the Subscription API.
25   * 
26   * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
27   */
28  public enum SubscriptionQuery implements UDDIQuery {
29      DELETE_SUBSCRIPTION("delete_subscription"),
30      GET_SUBSCRIPTIONRESULTS("get_subscriptionResults"),
31      GET_SUBSCRIPTIONS("get_subscriptions"),
32      SAVE_SUBSCRIPTION("save_subscription");
33          
34      private String _query;
35      private static Hashtable<String, SubscriptionQuery> _subscriptionQueries = null;
36          
37      SubscriptionQuery(final String query) {
38          _query = query;
39      }
40          
41      public String getQuery() {
42          return _query;
43      }
44          
45      public synchronized static void initSubscriptionQueries () {
46          if (_subscriptionQueries == null) {
47                  _subscriptionQueries = new Hashtable();
48  
49                  _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      }
55      
56      public static List<String> getQueries() {
57          if (_subscriptionQueries == null) {
58              initSubscriptionQueries();
59          }
60          
61          List list = new ArrayList<String>(_subscriptionQueries.keySet());
62          return list;
63      }
64  
65      /**
66       * this doesn't appear to be used anywhere and will be removed in a future version
67       * @param query
68       * @return
69       * @deprecated
70       */
71      public static SubscriptionQuery fromQuery(final String query) {
72          if (_subscriptionQueries == null) {
73              initSubscriptionQueries();
74          }
75          
76          if (_subscriptionQueries.contains(query)) {
77              return _subscriptionQueries.get(query);
78          } else {
79              throw new IllegalArgumentException("Unrecognized query " + query);
80          }       
81      }
82  }