1
2
3
4
5
6
7
8 package org.astrogrid.applications.beans.v1.types;
9
10
11
12
13
14 import java.io.Serializable;
15 import java.util.Enumeration;
16 import java.util.Hashtable;
17 import org.exolab.castor.xml.Marshaller;
18 import org.exolab.castor.xml.Unmarshaller;
19
20 /***
21 * http method type: get or post
22 *
23 * @version $Revision: 1.8 $ $Date: 2007/01/04 16:26:23 $
24 */
25 public class HttpMethodType implements java.io.Serializable {
26
27
28
29
30
31
32 /***
33 * The get type
34 */
35 public static final int GET_TYPE = 0;
36
37 /***
38 * The instance of the get type
39 */
40 public static final HttpMethodType GET = new HttpMethodType(GET_TYPE, "get");
41
42 /***
43 * The post type
44 */
45 public static final int POST_TYPE = 1;
46
47 /***
48 * The instance of the post type
49 */
50 public static final HttpMethodType POST = new HttpMethodType(POST_TYPE, "post");
51
52 /***
53 * Field _memberTable
54 */
55 private static java.util.Hashtable _memberTable = init();
56
57 /***
58 * Field type
59 */
60 private int type = -1;
61
62 /***
63 * Field stringValue
64 */
65 private java.lang.String stringValue = null;
66
67
68
69
70
71
72 private HttpMethodType(int type, java.lang.String value) {
73 super();
74 this.type = type;
75 this.stringValue = value;
76 }
77
78
79
80
81
82
83 /***
84 * Method enumerateReturns an enumeration of all possible
85 * instances of HttpMethodType
86 */
87 public static java.util.Enumeration enumerate()
88 {
89 return _memberTable.elements();
90 }
91
92 /***
93 * Method getTypeReturns the type of this HttpMethodType
94 */
95 public int getType()
96 {
97 return this.type;
98 }
99
100 /***
101 * Method init
102 */
103 private static java.util.Hashtable init()
104 {
105 Hashtable members = new Hashtable();
106 members.put("get", GET);
107 members.put("post", POST);
108 return members;
109 }
110
111 /***
112 * Method toStringReturns the String representation of this
113 * HttpMethodType
114 */
115 public java.lang.String toString()
116 {
117 return this.stringValue;
118 }
119
120 /***
121 * Method valueOfReturns a new HttpMethodType based on the
122 * given String value.
123 *
124 * @param string
125 */
126 public static org.astrogrid.applications.beans.v1.types.HttpMethodType valueOf(java.lang.String string)
127 {
128 java.lang.Object obj = null;
129 if (string != null) obj = _memberTable.get(string);
130 if (obj == null) {
131 String err = "'" + string + "' is not a valid HttpMethodType";
132 throw new IllegalArgumentException(err);
133 }
134 return (HttpMethodType) obj;
135 }
136
137 }