KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > xs > xml > XsFormChoice


1 /*
2  * Copyright 2003, 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  */

17 package org.apache.ws.jaxme.xs.xml;
18
19
20 /** <p>Implementation of the following simple type:
21  * <pre>
22  * &lt;xs:simpleType name="formChoice"&gt;
23  * &lt;xs:annotation&gt;
24  * &lt;xs:documentation&gt;
25  * A utility type, not for public use
26  * &lt;/xs:documentation&gt;
27  * &lt;/xs:annotation&gt;
28  * &lt;xs:restriction base="xs:NMTOKEN"&gt;
29  * &lt;xs:enumeration value="qualified"/&gt;
30  * &lt;xs:enumeration value="unqualified"/&gt;
31  * &lt;/xs:restriction&gt;
32  * &lt;/xs:simpleType&gt;
33  * </pre></p>
34  *
35  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
36  */

37 public class XsFormChoice {
38   public static final XsFormChoice QUALIFIED = new XsFormChoice("qualified");
39   public static final XsFormChoice UNQUALIFIED = new XsFormChoice("unqualified");
40   private final String JavaDoc value;
41   private XsFormChoice(String JavaDoc pValue) {
42     value = pValue;
43   }
44   public String JavaDoc toString() { return value; }
45   public String JavaDoc getValue() { return value; }
46   public int hashCode() {
47     return value.hashCode();
48   }
49   public boolean equals(Object JavaDoc o) {
50     return o != null && XsFormChoice.class.equals(o.getClass()) &&
51       value.equals(((XsFormChoice) o).value);
52   }
53   public static XsFormChoice valueOf(String JavaDoc pValue) {
54     if ("qualified".equals(pValue)) {
55       return QUALIFIED;
56     } else if ("unqualified".equals(pValue)) {
57       return UNQUALIFIED;
58     } else {
59       throw new IllegalArgumentException JavaDoc("Invalid form value: " + pValue + ", expected either of 'qualified' or 'unqualified'" );
60     }
61   }
62 }
63
Popular Tags