This project has retired. For details please refer to its Attic page.
CustodyTransferQuery 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 queries within the Custody Transfer API.
25   * 
26   * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
27   */
28  public enum CustodyTransferQuery implements UDDIQuery {
29      DISCARD_TRANSFERTOKEN("discard_transferToken"),
30      GET_TRANSFERTOKEN("get_transferToken"),
31      TRANSFER_ENTITIES("transfer_entities");
32      
33      private String _query;
34      private static Hashtable<String, CustodyTransferQuery> _custodyTransferQueries = null;
35      
36      CustodyTransferQuery(final String query) {
37          _query = query;
38      }
39      
40      public String getQuery() {
41          return _query;
42      }
43      
44      public synchronized static void initCustodyTransferQueries () {
45          if (_custodyTransferQueries == null) {
46                  _custodyTransferQueries = new Hashtable();
47                  _custodyTransferQueries.put("discard_transferToken", CustodyTransferQuery.DISCARD_TRANSFERTOKEN);
48                  _custodyTransferQueries.put("get_transferToken", CustodyTransferQuery.GET_TRANSFERTOKEN);
49                  _custodyTransferQueries.put("transfer_entities", CustodyTransferQuery.TRANSFER_ENTITIES);
50          }
51      }
52      
53      public static List<String> getQueries() {
54          if (_custodyTransferQueries == null) {
55              initCustodyTransferQueries();
56          }
57          
58          List list = new ArrayList<String>(_custodyTransferQueries.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      @Deprecated
69      public static CustodyTransferQuery fromQuery(final String query) {
70          if (_custodyTransferQueries == null) {
71              initCustodyTransferQueries();
72          }
73          
74          //note: at one point this was just .contains(query) which shouldn't work
75          if (_custodyTransferQueries.containsKey(query)) {
76              return _custodyTransferQueries.get(query);
77          } else {
78              throw new IllegalArgumentException("Unrecognized query " + query);
79          }
80      }
81  }