KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gcc > rmi > iiop > ValueTypeField


1 /*
2  * Copyright 2004 The Apache Software Foundation or its licensors, as
3  * applicable.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14  * implied.
15  *
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19 package gcc.rmi.iiop;
20
21 import gcc.*;
22 import java.lang.reflect.*;
23
24 public class ValueTypeField
25 {
26     public final Field javaField;
27
28     public final int primitive;
29
30     public final ValueType type;
31
32     public ValueTypeField(Field field)
33     {
34         javaField = field;
35         if (field.getType().isPrimitive())
36         {
37             primitive = PrimitiveType.get(field.getType());
38             type = null;
39         }
40         else
41         {
42             primitive = 0;
43             type = ValueType.getInstance(field.getType());
44         }
45     }
46
47     public boolean getBoolean(Object that)
48     {
49         try
50         {
51             return javaField.getBoolean(that);
52         }
53         catch (Exception ex)
54         {
55             throw new SystemException(ex);
56         }
57     }
58
59     public byte getByte(Object that)
60     {
61         try
62         {
63             return javaField.getByte(that);
64         }
65         catch (Exception ex)
66         {
67             throw new SystemException(ex);
68         }
69     }
70
71     public char getChar(Object that)
72     {
73         try
74         {
75             return javaField.getChar(that);
76         }
77         catch (Exception ex)
78         {
79             throw new SystemException(ex);
80         }
81     }
82
83     public double getDouble(Object that)
84     {
85         try
86         {
87             return javaField.getDouble(that);
88         }
89         catch (Exception ex)
90         {
91             throw new SystemException(ex);
92         }
93     }
94
95     public float getFloat(Object that)
96     {
97         try
98         {
99             return javaField.getFloat(that);
100         }
101         catch (Exception ex)
102         {
103             throw new SystemException(ex);
104         }
105     }
106
107     public int getInt(Object that)
108     {
109         try
110         {
111             return javaField.getInt(that);
112         }
113         catch (Exception ex)
114         {
115             throw new SystemException(ex);
116         }
117     }
118
119     public long getLong(Object that)
120     {
121         try
122         {
123             return javaField.getLong(that);
124         }
125         catch (Exception ex)
126         {
127             throw new SystemException(ex);
128         }
129     }
130
131     public short getShort(Object that)
132     {
133         try
134         {
135             return javaField.getShort(that);
136         }
137         catch (Exception ex)
138         {
139             throw new SystemException(ex);
140         }
141     }
142
143     public Object get(Object that)
144     {
145         try
146         {
147             return javaField.get(that);
148         }
149         catch (Exception ex)
150         {
151             throw new SystemException(ex);
152         }
153     }
154
155     public void setBoolean(Object that, boolean value)
156     {
157         try
158         {
159             javaField.setBoolean(that, value);
160         }
161         catch (Exception ex)
162         {
163             throw new SystemException(ex);
164         }
165     }
166
167     public void setByte(Object that, byte value)
168     {
169         try
170         {
171             javaField.setByte(that, value);
172         }
173         catch (Exception ex)
174         {
175             throw new SystemException(ex);
176         }
177     }
178
179     public void setChar(Object that, char value)
180     {
181         try
182         {
183             javaField.setChar(that, value);
184         }
185         catch (Exception ex)
186         {
187             throw new SystemException(ex);
188         }
189     }
190
191     public void setDouble(Object that, double value)
192     {
193         try
194         {
195             javaField.setDouble(that, value);
196         }
197         catch (Exception ex)
198         {
199             throw new SystemException(ex);
200         }
201     }
202
203     public void setFloat(Object that, float value)
204     {
205         try
206         {
207             javaField.setFloat(that, value);
208         }
209         catch (Exception ex)
210         {
211             throw new SystemException(ex);
212         }
213     }
214
215     public void setInt(Object that, int value)
216     {
217         try
218         {
219             javaField.setInt(that, value);
220         }
221         catch (Exception ex)
222         {
223             throw new SystemException(ex);
224         }
225     }
226
227     public void setLong(Object that, long value)
228     {
229         try
230         {
231             javaField.setLong(that, value);
232         }
233         catch (Exception ex)
234         {
235             throw new SystemException(ex);
236         }
237     }
238
239     public void setShort(Object that, short value)
240     {
241         try
242         {
243             javaField.setShort(that, value);
244         }
245         catch (Exception ex)
246         {
247             throw new SystemException(ex);
248         }
249     }
250
251     public void set(Object that, Object value)
252     {
253         try
254         {
255             javaField.set(that, value);
256         }
257         catch (Exception ex)
258         {
259             throw new SystemException(ex);
260         }
261     }
262 }
263
Popular Tags