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