KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gcc > rmi > iiop > Protocol


1 /*
2  * Copyright 2004 The Apache Software Foundation or its licensors, as
3  * applicable.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19 package gcc.rmi.iiop;
20
21 public abstract class Protocol
22 {
23     public static final int IIOP = 1;
24     public static final int IIOPS = 2;
25     public static final int HTTP = 3;
26     public static final int HTTPS = 4;
27
28     public static String getName(int protocol)
29     {
30         switch (protocol)
31         {
32             case IIOP: return "iiop";
33             case IIOPS: return "iiop";
34             case HTTP: return "http";
35             case HTTPS: return "https";
36             default: throw new IllegalArgumentException("protocol = " + protocol);
37         }
38     }
39
40     public static String getScheme(int protocol)
41     {
42         switch (protocol)
43         {
44             case IIOP: return "iiop:";
45             case IIOPS: return "iiop:";
46             case HTTP: return "http:";
47             case HTTPS: return "https:";
48             default: throw new IllegalArgumentException("protocol = " + protocol);
49         }
50     }
51
52     public static int getNumber(String protocol)
53     {
54         if (protocol.equals("iiop"))
55         {
56             return IIOP;
57         }
58         else if (protocol.equals("iiops"))
59         {
60             return IIOPS;
61         }
62         else if (protocol.equals("http"))
63         {
64             return HTTP;
65         }
66         else if (protocol.equals("https"))
67         {
68             return HTTPS;
69         }
70         else
71         {
72             throw new IllegalArgumentException("protocol = " + protocol);
73         }
74     }
75 }
76
Popular Tags