PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/message/descriptor/TopologyDirection.java

http://mobicents.googlecode.com/
Java | 76 lines | 55 code | 16 blank | 5 comment | 2 complexity | 296f54a567872212c4e01ad45c61e969 MD5 | raw file
 1package javax.megaco.message.descriptor;
 2
 3import java.io.Serializable;
 4
 5/**
 6 * Topology direction constants used in package javax.megaco.message.descriptor.
 7 * This class defines the topology direction for the megaco package.
 8 * 
 9 */
10public class TopologyDirection implements Serializable {
11	public static final int M_BOTHWAY = 0;
12	public static final int M_ISOLATE = 1;
13	public static final int M_ONEWAY = 2;
14
15	public static final TopologyDirection BOTHWAY = new TopologyDirection(M_BOTHWAY);
16
17	public static final TopologyDirection ISOLATE = new TopologyDirection(M_ISOLATE);
18
19	public static final TopologyDirection ONEWAY = new TopologyDirection(M_ONEWAY);
20
21	private int topology_direction;
22
23	private TopologyDirection(int topology_direction) {
24		this.topology_direction = topology_direction;
25	}
26
27	public int getTopologyDirection() {
28		return this.topology_direction;
29	}
30
31	public static final TopologyDirection getObject(int value) throws IllegalArgumentException {
32		TopologyDirection t = null;
33		switch (value) {
34		case M_BOTHWAY:
35			t = BOTHWAY;
36			break;
37		case M_ISOLATE:
38			t = ISOLATE;
39			break;
40		case M_ONEWAY:
41			t = ONEWAY;
42			break;
43
44		default:
45			throw new IllegalArgumentException("No TopologyDirection for value = " + value);
46		}
47
48		return t;
49	}
50
51	private Object readResolve() {
52		return this.getObject(this.topology_direction);
53	}
54
55	@Override
56	public String toString() {
57		String t = null;
58		switch (this.topology_direction) {
59		case M_BOTHWAY:
60			t = "TopologyDirection[BOTHWAY]";
61			break;
62		case M_ISOLATE:
63			t = "TopologyDirection[ISOLATE]";
64			break;
65		case M_ONEWAY:
66			t = "TopologyDirection[ONEWAY]";
67			break;
68
69		default:
70			t = "TopologyDirection[" + this.topology_direction + "]";
71		}
72
73		return t;
74	}
75
76}