View Javadoc

1   /*
2    * Copyright 2001-2004 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.handler;
17  
18  import org.apache.juddi.IRegistry;
19  
20  
21  /***
22   * Base class for the request handler structures.
23   *
24   * @author Steve Viens (sviens@apache.org)
25   */
26  public abstract class AbstractHandler implements IHandler
27  {
28  	/*** 
29  	 * Helper function to set the generic version number 
30  	 * to a default value when null or zero length.
31  	 * 
32  	 * @param generic version number
33  	 * @return generic version number
34  	 */
35  	public String getGeneric(String generic)
36  	{
37  		if ((generic == null) || (generic.trim().length() == 0))
38  	    {
39  		  // Default to UDDI v2 values
40  	      return IRegistry.UDDI_V2_GENERIC;
41  	    }
42  		return generic;
43  	}
44  	/***
45  	 * Helper function to get the namespace given the generic
46  	 * version number.
47  	 * 
48  	 * @param generic - the generic version number
49  	 * @return the namespace String
50  	 */
51  	public String getUDDINamespace(String generic)
52  	{
53  		if (IRegistry.UDDI_V1_GENERIC.equals(generic)) {
54  	        return IRegistry.UDDI_V1_NAMESPACE;
55  		} else if (IRegistry.UDDI_V2_GENERIC.equals(generic)) {
56  	        return IRegistry.UDDI_V2_NAMESPACE;
57  	    } else if (IRegistry.UDDI_V3_GENERIC.equals(generic)) {
58  	        return IRegistry.UDDI_V3_NAMESPACE;
59  	    } else {// Default to UDDI v2 values
60  	       return IRegistry.UDDI_V2_GENERIC;
61  	    }
62  	}
63  }