KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > dyade > aaa > util > EnumerationType


1 /*
2  * Copyright (C) 2000 ScalAgent Distributed Technologies
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA.
18  *
19  */

20 package fr.dyade.aaa.util;
21
22 /**
23  *
24  * Enumerations should implement this interface.
25  * A code example is given below.
26  * <code>
27  * <br>
28  * package fr.dyade.aaa.nw.ar.tests; <br>
29  * <br>
30  * import fr.dyade.aaa.util.EnumerationType; <br>
31  * <br>
32  * public class CnxState implements EnumerationType { <br>
33  * <br>
34  * public static CnxState valueOf(String name) throws Exception { <br>
35  * for (int i = 0; i < names.length; i++) { <br>
36  * if (name.equals(names[i])) <br>
37  * return values[i]; <br>
38  * } <br>
39  * throw new Exception("Format exception: " + name + <br>
40  * " is not a CnxState."); <br>
41  * } <br>
42  * <br>
43  * public final static String[] names = { <br>
44  * "no value", <br>
45  * "opened", <br>
46  * "established", <br>
47  * "reset", <br>
48  * "closed", <br>
49  * "free", <br>
50  * "timeout", <br>
51  * "unchanged" <br>
52  * }; <br>
53  * <br>
54  * <br>
55  * public final static int _CNX_NOVALUE = 0; <br>
56  * <br>
57  * public final static int _CNX_OPENED = 1; <br>
58  * <br>
59  * public final static int _CNX_ESTABLISHED = 2; <br>
60  * <br>
61  * public final static int _CNX_RESET = 3; <br>
62  * <br>
63  * public final static int _CNX_CLOSED = 4; <br>
64  * <br>
65  * public final static int _CNX_FREE = 5; <br>
66  * <br>
67  * public final static int _CNX_TIMEOUT = 6; <br>
68  * <br>
69  * public final static int _CNX_UNCHANGED = 7; <br>
70  * <br>
71  * <br>
72  * public final static CnxState CNX_NOVALUE = new CnxState(_CNX_NOVALUE); <br>
73  * <br>
74  * public final static CnxState CNX_OPENED = new CnxState(_CNX_OPENED); <br>
75  * <br>
76  * public final static CnxState CNX_ESTABLISHED = new CnxState(_CNX_ESTABLISHED); <br>
77  * <br>
78  * public final static CnxState CNX_RESET = new CnxState(_CNX_RESET); <br>
79  * <br>
80  * public final static CnxState CNX_CLOSED = new CnxState(_CNX_CLOSED); <br>
81  * <br>
82  * public final static CnxState CNX_FREE = new CnxState(_CNX_FREE); <br>
83  * <br>
84  * public final static CnxState CNX_TIMEOUT = new CnxState(_CNX_TIMEOUT); <br>
85  * <br>
86  * public final static CnxState CNX_UNCHANGED = new CnxState(_CNX_UNCHANGED); <br>
87  * <br>
88  * public final static CnxState[] values = {CNX_NOVALUE, <br>
89  * CNX_OPENED, <br>
90  * CNX_ESTABLISHED, <br>
91  * CNX_RESET, <br>
92  * CNX_CLOSED, <br>
93  * CNX_FREE, <br>
94  * CNX_TIMEOUT, <br>
95  * CNX_UNCHANGED}; <br>
96  * <br>
97  * private int index; <br>
98  * <br>
99  * private CnxState(int index) { <br>
100  * this.index = index; <br>
101  * } <br>
102  * <br>
103  * public int intValue() { <br>
104  * return index; <br>
105  * } <br>
106  * <br>
107  * public String toString() { <br>
108  * return names[index]; <br>
109  * } <br>
110  * <br>
111  * <br>
112  * } <br>
113  * <br>
114  * </code>
115  */

116
117 public interface EnumerationType extends java.io.Serializable JavaDoc {
118   public int intValue();
119 }
120
Popular Tags