This project has retired. For details please refer to its Attic page.
QueryStatus xref
View Javadoc
1   /*
2    * Copyright 2001-2015 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   * Statuses of a query.    Successs represents a successful query, failed 
25   * represents one that throws a DispositionFaultMessage.
26   * 
27   * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
28   */
29  public enum QueryStatus {
30      SUCCESS("success"),
31      FAILED ("failed");
32  
33      private String _status;
34      private static Hashtable<String, QueryStatus> _statuses = null;
35      
36      QueryStatus(final String status) {
37          _status = status;
38      }
39      
40      public String getStatus() {
41          return _status;
42      }
43      
44      public synchronized static void initStatuses () {
45          if (_statuses == null) {
46              _statuses = new Hashtable();
47  
48              _statuses.put(QueryStatus.SUCCESS.getStatus(), QueryStatus.SUCCESS);
49              _statuses.put(QueryStatus.FAILED.getStatus(), QueryStatus.FAILED);
50          }
51      }
52  
53      public static List<String> getQueries() {
54          if (_statuses == null) {
55              initStatuses();
56          }
57      
58          List list = new ArrayList<String>(_statuses.keySet());
59          return list;
60      }
61  
62      /**
63       * this doesn't appear to be used anywhere and will be removed in a future version
64       * @param query
65       * @return
66       * @deprecated
67       */
68      public static QueryStatus fromStatus(final String status) {
69          if (_statuses == null) {
70              initStatuses();
71          }
72      
73          if (_statuses.contains(status)) {
74              return _statuses.get(status);
75          } else {
76              throw new IllegalArgumentException("Unrecognized status " + status);
77          }       
78      }
79  }