KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > ir > gui > remoteobject > Struct


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1999-2004 Gerald Brose
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */

21
22
23 package org.jacorb.ir.gui.remoteobject;
24
25
26
27
28
29 import org.jacorb.ir.gui.typesystem.*;
30
31 import org.jacorb.ir.gui.typesystem.remote.*;
32
33 import org.omg.CORBA.*;
34
35 import java.lang.reflect.*; // zum Auslesen der Felder des Structs
36

37 /**
38
39  * This class was generated by a SmartGuide.
40
41  *
42
43  */

44
45 public class Struct extends ObjectRepresentant implements AbstractContainer{
46
47
48
49
50
51
52
53 /**
54
55  * Struct constructor comment.
56
57  * @param counterPart java.lang.Object
58
59  */

60
61 protected Struct(java.lang.Object JavaDoc counterPart, IRStruct typeSystemNode, String JavaDoc name) {
62
63     super(counterPart,typeSystemNode,name);
64
65 }
66
67 /**
68
69  * This method was created by a SmartGuide.
70
71  * @return ModelParticipant[]
72
73  */

74
75 public ModelParticipant[] contents() {
76
77     if (counterPart!=null) {
78
79         // wir holen uns den Inhalt des Struct per Reflection
80

81         IRStructMember[] members = (IRStructMember[])((AbstractContainer)typeSystemNode).contents();
82
83         ModelParticipant[] result = new ModelParticipant[members.length];
84
85         for (int i=0; i<members.length; i++) {
86
87             try {
88
89                 Field field = counterPart.getClass().getDeclaredField(members[i].getName());
90
91                 result[i] = ObjectRepresentantFactory.create(
92
93                     field.get(counterPart), // per Reflection auslesen
94

95                     members[i].getAssociatedTypeSystemNode(),
96
97                     members[i]);
98
99             }
100
101             catch (Exception JavaDoc e) {
102
103                 e.printStackTrace();
104
105             }
106
107         }
108
109         return result;
110
111     } // if counterPart!=null
112

113     else {
114
115         return new ModelParticipant[0];
116
117     }
118
119 }
120
121 }
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
Popular Tags