View Javadoc

1   /*
2    * This class was automatically generated with 
3    * <a href="http://www.castor.org">Castor 0.9.4.3</a>, using an XML
4    * Schema.
5    * $Id: Yesno.java,v 1.14 2007/01/04 16:26:14 clq2 Exp $
6    */
7   
8   package org.astrogrid.registry.beans.resource.votable.types;
9   
10    //---------------------------------/
11   //- Imported classes and packages -/
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   * Class Yesno.
22   * 
23   * @version $Revision: 1.14 $ $Date: 2007/01/04 16:26:14 $
24   */
25  public class Yesno implements java.io.Serializable {
26  
27  
28        //--------------------------/
29       //- Class/Member Variables -/
30      //--------------------------/
31  
32      /***
33       * The yes type
34       */
35      public static final int YES_TYPE = 0;
36  
37      /***
38       * The instance of the yes type
39       */
40      public static final Yesno YES = new Yesno(YES_TYPE, "yes");
41  
42      /***
43       * The no type
44       */
45      public static final int NO_TYPE = 1;
46  
47      /***
48       * The instance of the no type
49       */
50      public static final Yesno NO = new Yesno(NO_TYPE, "no");
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       //- Constructors -/
70      //----------------/
71  
72      private Yesno(int type, java.lang.String value) {
73          super();
74          this.type = type;
75          this.stringValue = value;
76      } //-- org.astrogrid.registry.beans.resource.votable.types.Yesno(int, java.lang.String)
77  
78  
79        //-----------/
80       //- Methods -/
81      //-----------/
82  
83      /***
84       * Method enumerateReturns an enumeration of all possible
85       * instances of Yesno
86       */
87      public static java.util.Enumeration enumerate()
88      {
89          return _memberTable.elements();
90      } //-- java.util.Enumeration enumerate() 
91  
92      /***
93       * Method getTypeReturns the type of this Yesno
94       */
95      public int getType()
96      {
97          return this.type;
98      } //-- int getType() 
99  
100     /***
101      * Method init
102      */
103     private static java.util.Hashtable init()
104     {
105         Hashtable members = new Hashtable();
106         members.put("yes", YES);
107         members.put("no", NO);
108         return members;
109     } //-- java.util.Hashtable init() 
110 
111     /***
112      * Method toStringReturns the String representation of this Yesn
113      */
114     public java.lang.String toString()
115     {
116         return this.stringValue;
117     } //-- java.lang.String toString() 
118 
119     /***
120      * Method valueOfReturns a new Yesno based on the given String
121      * value.
122      * 
123      * @param string
124      */
125     public static org.astrogrid.registry.beans.resource.votable.types.Yesno valueOf(java.lang.String string)
126     {
127         java.lang.Object obj = null;
128         if (string != null) obj = _memberTable.get(string);
129         if (obj == null) {
130             String err = "'" + string + "' is not a valid Yesno";
131             throw new IllegalArgumentException(err);
132         }
133         return (Yesno) obj;
134     } //-- org.astrogrid.registry.beans.resource.votable.types.Yesno valueOf(java.lang.String) 
135 
136 }