1 // Not a test, required by RMI_IIOP.java. |
|
2 |
|
3 // Copyright (C) 2005 Audrius Meskauskas (AudriusA@Bioinformatics.org) |
|
4 |
|
5 // Mauve is free software; you can redistribute it and/or modify |
|
6 // it under the terms of the GNU General Public License as published by |
|
7 // the Free Software Foundation; either version 2, or (at your option) |
|
8 // any later version. |
|
9 |
|
10 // Mauve is distributed in the hope that it will be useful, |
|
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 // GNU General Public License for more details. |
|
14 |
|
15 // You should have received a copy of the GNU General Public License |
|
16 // along with Mauve; see the file COPYING. If not, write to |
|
17 // the Free Software Foundation, 59 Temple Place - Suite 330, |
|
18 // Boston, MA 02111-1307, USA. */ |
|
19 |
|
20 package gnu.testlet.javax.rmi.CORBA.Tie; |
|
21 |
|
22 import java.io.Serializable; |
|
23 |
|
24 /** |
|
25 * This file is part of the CORBA RMI over IIOP the test executable |
|
26 * class being gnu.testlet.javax.rmi.CORBA.Tie.RMI_IIOP. It is a |
|
27 * node of the graph that must be flattened and passed via RMI-IIOP. |
|
28 * |
|
29 * @author Audrius Meskauskas (AudriusA@bluewin.ch) |
|
30 */ |
|
31 public class NodeObject |
|
32 implements Serializable |
|
33 { |
|
34 /** |
|
35 * The label facilitates orientation. |
|
36 */ |
|
37 public String label; |
|
38 |
|
39 /** |
|
40 * The pointer for forming the network. |
|
41 */ |
|
42 public NodeObject a; |
|
43 |
|
44 /** |
|
45 * Another pointer to form a trees. |
|
46 */ |
|
47 public NodeObject b; |
|
48 |
|
49 /** |
|
50 * Another RMI_test. |
|
51 */ |
|
52 RMI_test z_anotherTest; |
|
53 |
|
54 /** |
|
55 * An array of "another RMI tests". |
|
56 */ |
|
57 RMI_test[] anotherTestArray; |
|
58 |
|
59 RMI_test[][][] ku; |
|
60 |
|
61 /** |
|
62 * Some transient field. |
|
63 */ |
|
64 transient Object transientField; |
|
65 |
|
66 /** |
|
67 * Some static field. |
|
68 */ |
|
69 static Object staticField; |
|
70 |
|
71 /** |
|
72 * Use serialVersionUID for interoperability. |
|
73 */ |
|
74 private static final long serialVersionUID = 0x7; |
|
75 |
|
76 public NodeObject(String a_label) |
|
77 { |
|
78 label = a_label; |
|
79 } |
|
80 |
|
81 public NodeObject() |
|
82 { |
|
83 this("<no label>"); |
|
84 } |
|
85 |
|
86 public String toString(int chain) |
|
87 { |
|
88 if (chain > 7) |
|
89 return "..."; |
|
90 StringBuffer sb = new StringBuffer(); |
|
91 |
|
92 sb.append(label); |
|
93 |
|
94 if (b != null) |
|
95 sb.append("(" + b + ")"); |
|
96 |
|
97 sb.append(":"); |
|
98 if (a != null) |
|
99 sb.append(a.toString(chain + 1)); |
|
100 else |
|
101 sb.append("null"); |
|
102 |
|
103 return sb.toString(); |
|
104 } |
|
105 |
|
106 public String toString() |
|
107 { |
|
108 return toString(0); |
|
109 } |
|
110 |
|
111 public static NodeObject create1() |
|
112 { |
|
113 NodeObject a = new NodeObject("a"); |
|
114 NodeObject b = new NodeObject("b"); |
|
115 NodeObject c = new NodeObject("c"); |
|
116 |
|
117 NodeObject d = new NodeObject("d"); |
|
118 NodeObject e = new NodeObject("e"); |
|
119 NodeObject f = new NodeObject("f"); |
|
120 |
|
121 // Lock f on self. |
|
122 f.a = f; |
|
123 |
|
124 // Form a digraph. |
|
125 d.a = e; |
|
126 e.a = d; |
|
127 |
|
128 e.b = f; |
|
129 |
|
130 // Form a triangle. |
|
131 a.a = b; |
|
132 b.a = c; |
|
133 c.a = a; |
|
134 |
|
135 // Add D to a and c. |
|
136 a.b = d; |
|
137 c.b = d; |
|
138 |
|
139 return a; |
|
140 } |
|
141 |
|
142 /** |
|
143 * Create a closed ring. |
|
144 */ |
|
145 public static NodeObject create2() |
|
146 { |
|
147 NodeObject a = new NodeObject("a"); |
|
148 NodeObject b = new NodeObject("b"); |
|
149 NodeObject c = new NodeObject("c"); |
|
150 |
|
151 NodeObject d = new NodeObject("d"); |
|
152 NodeObject e = new NodeObject("e"); |
|
153 NodeObject f = new NodeObject("f"); |
|
154 |
|
155 a.a = b; |
|
156 b.a = c; |
|
157 c.a = d; |
|
158 d.a = e; |
|
159 e.a = f; |
|
160 f.a = a; |
|
161 |
|
162 return a; |
|
163 } |
|
164 |
|
165 public static void main(String[] args) |
|
166 { |
|
167 System.out.println(create1()); |
|
168 System.out.println(create2()); |
|
169 } |
|
170 |
|
171 } |
|