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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 *16 */17package org.apache.juddi.api.util;
1819import java.util.ArrayList;
20import java.util.Hashtable;
21import java.util.List;
2223/**24 * Enum to represent the queries within the Replication API.25 * 26 * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>27 */28public enum ReplicationQueryimplementsUDDIQuery {
29 GET_CHANGERECORDS("get_changeRecords"),
30 NOTIFY_CHANGERECORDSAVAILABLE("notify_changeRecordsAvailable"),
31 DO_PING("do_ping"),
32 GET_HIGHWATERMARKS("get_highWaterMarks"),
33 TRANSFER_CUSTODY("transfer_custody");
3435private String _query;
36privatestatic Hashtable<String, ReplicationQuery> _replicationQueries = null;
3738ReplicationQuery(final String query) {
39 _query = query;
40 }
4142public String getQuery() {
43return _query;
44 }
4546publicsynchronizedstaticvoid initReplicationQueries () {
47if (_replicationQueries == null) {
48 _replicationQueries = new Hashtable();
4950 _replicationQueries.put(ReplicationQuery.GET_CHANGERECORDS.getQuery(), ReplicationQuery.GET_CHANGERECORDS);
51 _replicationQueries.put(ReplicationQuery.NOTIFY_CHANGERECORDSAVAILABLE.getQuery(), ReplicationQuery.NOTIFY_CHANGERECORDSAVAILABLE);
52 _replicationQueries.put(ReplicationQuery.DO_PING.getQuery(), ReplicationQuery.DO_PING);
53 _replicationQueries.put(ReplicationQuery.GET_HIGHWATERMARKS.getQuery(), ReplicationQuery.GET_HIGHWATERMARKS);
54 _replicationQueries.put(ReplicationQuery.TRANSFER_CUSTODY.getQuery(), ReplicationQuery.TRANSFER_CUSTODY);
55 }
56 }
5758publicstatic List<String> getQueries() {
59if (_replicationQueries == null) {
60 initReplicationQueries();
61 }
6263 List list = new ArrayList<String>(_replicationQueries.keySet());
64return list;
65 }
6667/**68 * this doesn't appear to be used anywhere and will be removed in a future version69 * @param query70 * @return71 * @deprecated72 */73publicstaticReplicationQuery fromQuery(final String query) {
74if (_replicationQueries == null) {
75 initReplicationQueries();
76 }
7778if (_replicationQueries.contains(query)) {
79return _replicationQueries.get(query);
80 } else {
81thrownew IllegalArgumentException("Unrecognized query " + query);
82 }
8384 }
85 }