This project has retired. For details please refer to its Attic page.
ValueSetCachingQuery 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 ValueSetCaching API.
25   * 
26   * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
27   */
28  public enum ValueSetCachingQuery implements UDDIQuery {
29      GET_ALLVALIDVALUES("get_allValidValues");
30      
31      private String _query;
32      private static Hashtable<String, ValueSetCachingQuery> _valueSetCachingQueries = null;
33          
34      ValueSetCachingQuery(final String query) {
35          _query = query;
36      }
37          
38      public String getQuery() {
39          return _query;
40      }
41          
42      public synchronized static void initValueSetCachingQueries () {
43              if (_valueSetCachingQueries == null) {
44                  _valueSetCachingQueries = new Hashtable();
45  
46                  _valueSetCachingQueries.put(ValueSetCachingQuery.GET_ALLVALIDVALUES.getQuery(), ValueSetCachingQuery.GET_ALLVALIDVALUES);
47              }
48      }
49      
50      public static List<String> getQueries() {
51          if (_valueSetCachingQueries == null) {
52              initValueSetCachingQueries();
53          }
54          
55          List list = new ArrayList<String>(_valueSetCachingQueries.keySet());
56          return list;
57      }
58  
59      /**
60       * this doesn't appear to be used anywhere and will be removed in a future version
61       * @param query
62       * @return
63       * @deprecated
64       */
65      public static ValueSetCachingQuery fromQuery(final String query) {
66          if (_valueSetCachingQueries == null) {
67              initValueSetCachingQueries();
68          }
69          
70          if (_valueSetCachingQueries.contains(query)) {
71              return _valueSetCachingQueries.get(query);
72          } else {
73              throw new IllegalArgumentException("Unrecognized query " + query);
74          }       
75      }
76  }