KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > io > IIOPOutputStream


1 /*
2  * @(#)IIOPOutputStream.java 1.51 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 /*
8  * Licensed Materials - Property of IBM
9  * RMI-IIOP v1.0
10  * Copyright IBM Corp. 1998 1999 All Rights Reserved
11  *
12  * US Government Users Restricted Rights - Use, duplication or
13  * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
14  */

15
16 package com.sun.corba.se.impl.io;
17
18 import org.omg.CORBA.INTERNAL JavaDoc;
19 import org.omg.CORBA.portable.OutputStream JavaDoc;
20
21 import java.security.AccessController JavaDoc ;
22 import java.security.PrivilegedAction JavaDoc ;
23
24 import java.io.IOException JavaDoc;
25 import java.io.DataOutputStream JavaDoc;
26 import java.io.Serializable JavaDoc;
27 import java.io.InvalidClassException JavaDoc;
28 import java.io.StreamCorruptedException JavaDoc;
29 import java.io.Externalizable JavaDoc;
30 import java.io.ObjectStreamException JavaDoc;
31 import java.io.NotSerializableException JavaDoc;
32 import java.io.NotActiveException JavaDoc;
33
34 import java.lang.reflect.InvocationTargetException JavaDoc;
35 import java.lang.reflect.Field JavaDoc;
36
37 import java.util.Stack JavaDoc;
38
39 import javax.rmi.CORBA.Util JavaDoc;
40 import javax.rmi.CORBA.ValueHandlerMultiFormat JavaDoc;
41
42 import sun.corba.Bridge ;
43
44 import com.sun.corba.se.impl.io.ObjectStreamClass;
45 import com.sun.corba.se.impl.util.Utility;
46 import com.sun.corba.se.impl.util.RepositoryId;
47
48 import com.sun.corba.se.spi.logging.CORBALogDomains ;
49 import com.sun.corba.se.impl.logging.UtilSystemException ;
50
51 /**
52  * IIOPOutputStream is ...
53  *
54  * @author Stephen Lewallen
55  * @version 0.01, 4/6/98
56  * @since JDK1.1.6
57  */

58
59 public class IIOPOutputStream
60     extends com.sun.corba.se.impl.io.OutputStreamHook
61 {
62     private UtilSystemException wrapper = UtilSystemException.get(
63     CORBALogDomains.RPC_ENCODING ) ;
64
65     private static Bridge bridge =
66     (Bridge)AccessController.doPrivileged(
67         new PrivilegedAction JavaDoc() {
68         public Object JavaDoc run() {
69             return Bridge.get() ;
70         }
71         }
72     ) ;
73
74     private org.omg.CORBA_2_3.portable.OutputStream JavaDoc orbStream;
75
76     private Object JavaDoc currentObject = null;
77
78     private ObjectStreamClass currentClassDesc = null;
79
80     private int recursionDepth = 0;
81
82     private int simpleWriteDepth = 0;
83
84     private IOException JavaDoc abortIOException = null;
85
86     private java.util.Stack JavaDoc classDescStack = new java.util.Stack JavaDoc();
87
88     // Used when calling an object's writeObject method
89
private Object JavaDoc[] writeObjectArgList = {this};
90
91     public IIOPOutputStream()
92     throws java.io.IOException JavaDoc
93    {
94     super();
95     }
96
97     // If using RMI-IIOP stream format version 2, this tells
98
// the ORB stream (which must be a ValueOutputStream) to
99
// begin a new valuetype to contain the optional data
100
// of the writeObject method.
101
protected void beginOptionalCustomData() {
102
103         if (streamFormatVersion == 2) {
104                 
105             org.omg.CORBA.portable.ValueOutputStream JavaDoc vout
106                 = (org.omg.CORBA.portable.ValueOutputStream JavaDoc)orbStream;
107                 
108             vout.start_value(currentClassDesc.getRMIIIOPOptionalDataRepId());
109         }
110     }
111
112     public final void setOrbStream(org.omg.CORBA_2_3.portable.OutputStream JavaDoc os) {
113         orbStream = os;
114     }
115
116     public final org.omg.CORBA_2_3.portable.OutputStream JavaDoc getOrbStream() {
117         return orbStream;
118     }
119
120     public final void increaseRecursionDepth(){
121     recursionDepth++;
122     }
123
124     public final int decreaseRecursionDepth(){
125     return --recursionDepth;
126     }
127
128     /**
129      * Override the actions of the final method "writeObject()"
130      * in ObjectOutputStream.
131      * @since JDK1.1.6
132      */

133     public final void writeObjectOverride(Object JavaDoc obj)
134     throws IOException JavaDoc
135     {
136         writeObjectState.writeData(this);
137
138     Util.writeAbstractObject((OutputStream JavaDoc)orbStream, obj);
139     }
140
141     /**
142      * Override the actions of the final method "writeObject()"
143      * in ObjectOutputStream.
144      * @since JDK1.1.6
145      */

146     public final void simpleWriteObject(Object JavaDoc obj, byte formatVersion)
147     /* throws IOException */
148     {
149         byte oldStreamFormatVersion = streamFormatVersion;
150
151         streamFormatVersion = formatVersion;
152
153         Object JavaDoc prevObject = currentObject;
154         ObjectStreamClass prevClassDesc = currentClassDesc;
155         simpleWriteDepth++;
156
157         try {
158         // if (!checkSpecialClasses(obj) && !checkSubstitutableSpecialClasses(obj))
159
outputObject(obj);
160
161         } catch (IOException JavaDoc ee) {
162             if (abortIOException == null)
163         abortIOException = ee;
164         } finally {
165             /* Restore state of previous call incase this is a nested call */
166             streamFormatVersion = oldStreamFormatVersion;
167             simpleWriteDepth--;
168             currentObject = prevObject;
169             currentClassDesc = prevClassDesc;
170         }
171
172         /* If the recursion depth is 0, test for and clear the pending exception.
173          * If there is a pending exception throw it.
174          */

175         IOException JavaDoc pending = abortIOException;
176         if (simpleWriteDepth == 0)
177             abortIOException = null;
178         if (pending != null) {
179         bridge.throwException( pending ) ;
180         }
181     }
182
183     // Required by the superclass.
184
ObjectStreamField[] getFieldsNoCopy() {
185         return currentClassDesc.getFieldsNoCopy();
186     }
187
188     /**
189      * Override the actions of the final method "defaultWriteObject()"
190      * in ObjectOutputStream.
191      * @since JDK1.1.6
192      */

193     public final void defaultWriteObjectDelegate()
194     /* throws IOException */
195     {
196         try {
197         if (currentObject == null || currentClassDesc == null)
198         // XXX I18N, Logging needed.
199
throw new NotActiveException JavaDoc("defaultWriteObjectDelegate");
200
201         ObjectStreamField[] fields =
202         currentClassDesc.getFieldsNoCopy();
203         if (fields.length > 0) {
204         outputClassFields(currentObject, currentClassDesc.forClass(),
205                   fields);
206         }
207         } catch(IOException JavaDoc ioe) {
208         bridge.throwException(ioe);
209     }
210     }
211
212     /**
213      * Override the actions of the final method "enableReplaceObject()"
214      * in ObjectOutputStream.
215      * @since JDK1.1.6
216      */

217     public final boolean enableReplaceObjectDelegate(boolean enable)
218     /* throws SecurityException */
219     {
220         return false;
221         
222     }
223
224
225     protected final void annotateClass(Class JavaDoc<?> cl) throws IOException JavaDoc{
226     // XXX I18N, Logging needed.
227
throw new IOException JavaDoc("Method annotateClass not supported");
228     }
229
230     public final void close() throws IOException JavaDoc{
231         // no op
232
}
233
234     protected final void drain() throws IOException JavaDoc{
235         // no op
236
}
237
238     public final void flush() throws IOException JavaDoc{
239         try{
240             orbStream.flush();
241         } catch(Error JavaDoc e) {
242         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
243         ioexc.initCause(e) ;
244         throw ioexc ;
245     }
246     }
247
248     protected final Object JavaDoc replaceObject(Object JavaDoc obj) throws IOException JavaDoc{
249     // XXX I18N, Logging needed.
250
throw new IOException JavaDoc("Method replaceObject not supported");
251     }
252
253     /**
254      * Reset will disregard the state of any objects already written
255      * to the stream. The state is reset to be the same as a new
256      * ObjectOutputStream. The current point in the stream is marked
257      * as reset so the corresponding ObjectInputStream will be reset
258      * at the same point. Objects previously written to the stream
259      * will not be refered to as already being in the stream. They
260      * will be written to the stream again.
261      * @since JDK1.1
262      */

263     public final void reset() throws IOException JavaDoc{
264         try{
265             //orbStream.reset();
266

267         if (currentObject != null || currentClassDesc != null)
268         // XXX I18N, Logging needed.
269
throw new IOException JavaDoc("Illegal call to reset");
270
271         abortIOException = null;
272
273         if (classDescStack == null)
274         classDescStack = new java.util.Stack JavaDoc();
275         else
276         classDescStack.setSize(0);
277
278         } catch(Error JavaDoc e) {
279         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
280         ioexc.initCause(e) ;
281         throw ioexc ;
282     }
283     }
284
285     public final void write(byte b[]) throws IOException JavaDoc{
286         try{
287             writeObjectState.writeData(this);
288
289             orbStream.write_octet_array(b, 0, b.length);
290         } catch(Error JavaDoc e) {
291         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
292         ioexc.initCause(e) ;
293         throw ioexc ;
294     }
295     }
296
297     public final void write(byte b[], int off, int len) throws IOException JavaDoc{
298         try{
299             writeObjectState.writeData(this);
300
301             orbStream.write_octet_array(b, off, len);
302         } catch(Error JavaDoc e) {
303         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
304         ioexc.initCause(e) ;
305         throw ioexc ;
306     }
307     }
308
309     public final void write(int data) throws IOException JavaDoc{
310         try{
311             writeObjectState.writeData(this);
312
313             orbStream.write_octet((byte)(data & 0xFF));
314         } catch(Error JavaDoc e) {
315         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
316         ioexc.initCause(e) ;
317         throw ioexc ;
318     }
319     }
320
321     public final void writeBoolean(boolean data) throws IOException JavaDoc{
322         try{
323             writeObjectState.writeData(this);
324
325             orbStream.write_boolean(data);
326         } catch(Error JavaDoc e) {
327         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
328         ioexc.initCause(e) ;
329         throw ioexc ;
330     }
331     }
332
333     public final void writeByte(int data) throws IOException JavaDoc{
334         try{
335             writeObjectState.writeData(this);
336
337             orbStream.write_octet((byte)data);
338         } catch(Error JavaDoc e) {
339         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
340         ioexc.initCause(e) ;
341         throw ioexc ;
342     }
343     }
344
345     public final void writeBytes(String JavaDoc data) throws IOException JavaDoc{
346         try{
347             writeObjectState.writeData(this);
348
349             byte buf[] = data.getBytes();
350             orbStream.write_octet_array(buf, 0, buf.length);
351         } catch(Error JavaDoc e) {
352         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
353         ioexc.initCause(e) ;
354         throw ioexc ;
355     }
356     }
357
358     public final void writeChar(int data) throws IOException JavaDoc{
359         try{
360             writeObjectState.writeData(this);
361
362             orbStream.write_wchar((char)data);
363         } catch(Error JavaDoc e) {
364         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
365         ioexc.initCause(e) ;
366         throw ioexc ;
367     }
368     }
369
370     public final void writeChars(String JavaDoc data) throws IOException JavaDoc{
371         try{
372             writeObjectState.writeData(this);
373
374             char buf[] = data.toCharArray();
375             orbStream.write_wchar_array(buf, 0, buf.length);
376         } catch(Error JavaDoc e) {
377         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
378         ioexc.initCause(e) ;
379         throw ioexc ;
380     }
381     }
382
383     public final void writeDouble(double data) throws IOException JavaDoc{
384         try{
385             writeObjectState.writeData(this);
386
387             orbStream.write_double(data);
388         } catch(Error JavaDoc e) {
389         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
390         ioexc.initCause(e) ;
391         throw ioexc ;
392     }
393     }
394
395     public final void writeFloat(float data) throws IOException JavaDoc{
396         try{
397             writeObjectState.writeData(this);
398
399             orbStream.write_float(data);
400         } catch(Error JavaDoc e) {
401         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
402         ioexc.initCause(e) ;
403         throw ioexc ;
404     }
405     }
406
407     public final void writeInt(int data) throws IOException JavaDoc{
408         try{
409             writeObjectState.writeData(this);
410
411             orbStream.write_long(data);
412         } catch(Error JavaDoc e) {
413         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
414         ioexc.initCause(e) ;
415         throw ioexc ;
416     }
417     }
418
419     public final void writeLong(long data) throws IOException JavaDoc{
420         try{
421             writeObjectState.writeData(this);
422
423             orbStream.write_longlong(data);
424         } catch(Error JavaDoc e) {
425         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
426         ioexc.initCause(e) ;
427         throw ioexc ;
428     }
429     }
430
431     public final void writeShort(int data) throws IOException JavaDoc{
432         try{
433             writeObjectState.writeData(this);
434
435             orbStream.write_short((short)data);
436         } catch(Error JavaDoc e) {
437         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
438         ioexc.initCause(e) ;
439         throw ioexc ;
440     }
441     }
442
443     protected final void writeStreamHeader() throws IOException JavaDoc{
444         // no op
445
}
446
447     /**
448      * Helper method for correcting the Kestrel bug 4367783 (dealing
449      * with larger than 8-bit chars). The old behavior is preserved
450      * in orbutil.IIOPInputStream_1_3 in order to interoperate with
451      * our legacy ORBs.
452      */

453     protected void internalWriteUTF(org.omg.CORBA.portable.OutputStream JavaDoc stream,
454                                     String JavaDoc data)
455     {
456         stream.write_wstring(data);
457     }
458
459     public final void writeUTF(String JavaDoc data) throws IOException JavaDoc{
460         try{
461             writeObjectState.writeData(this);
462
463             internalWriteUTF(orbStream, data);
464         } catch(Error JavaDoc e) {
465         IOException JavaDoc ioexc = new IOException JavaDoc(e.getMessage());
466         ioexc.initCause(e) ;
467         throw ioexc ;
468     }
469     }
470
471     // INTERNAL UTILITY METHODS
472
/*
473      * Check for special cases of serializing objects.
474      * These objects are not subject to replacement.
475      */

476     private boolean checkSpecialClasses(Object JavaDoc obj) throws IOException JavaDoc {
477
478         /*
479          * If this is a class, don't allow substitution
480          */

481         //if (obj instanceof Class) {
482
// throw new IOException("Serialization of Class not supported");
483
//}
484

485         if (obj instanceof ObjectStreamClass) {
486         // XXX I18N, Logging needed.
487
throw new IOException JavaDoc("Serialization of ObjectStreamClass not supported");
488         }
489
490         return false;
491     }
492
493     /*
494      * Check for special cases of substitutable serializing objects.
495      * These classes are replaceable.
496      */

497     private boolean checkSubstitutableSpecialClasses(Object JavaDoc obj)
498     throws IOException JavaDoc
499     {
500         if (obj instanceof String JavaDoc) {
501             orbStream.write_value((java.io.Serializable JavaDoc)obj);
502             return true;
503         }
504
505         //if (obj.getClass().isArray()) {
506
// outputArray(obj);
507
// return true;
508
//}
509

510         return false;
511     }
512
513     /*
514      * Write out the object
515      */

516     private void outputObject(final Object JavaDoc obj) throws IOException JavaDoc{
517
518         currentObject = obj;
519         Class JavaDoc currclass = obj.getClass();
520
521         /* Get the Class descriptor for this class,
522          * Throw a NotSerializableException if there is none.
523          */

524         currentClassDesc = ObjectStreamClass.lookup(currclass);
525         if (currentClassDesc == null) {
526         // XXX I18N, Logging needed.
527
throw new NotSerializableException JavaDoc(currclass.getName());
528         }
529
530         /* If the object is externalizable,
531          * call writeExternal.
532          * else do Serializable processing.
533          */

534         if (currentClassDesc.isExternalizable()) {
535         // Write format version
536
orbStream.write_octet(streamFormatVersion);
537
538             Externalizable JavaDoc ext = (Externalizable JavaDoc)obj;
539             ext.writeExternal(this);
540             
541         } else {
542
543             /* The object's classes should be processed from supertype to subtype
544              * Push all the clases of the current object onto a stack.
545              * Remember the stack pointer where this set of classes is being pushed.
546              */

547             int stackMark = classDescStack.size();
548             try {
549             ObjectStreamClass next;
550             while ((next = currentClassDesc.getSuperclass()) != null) {
551                 classDescStack.push(currentClassDesc);
552                 currentClassDesc = next;
553             }
554
555             /*
556              * For currentClassDesc and all the pushed class descriptors
557              * If the class is writing its own data
558              * set blockData = true; call the class writeObject method
559              * If not
560              * invoke either the defaultWriteObject method.
561              */

562             do {
563
564                     WriteObjectState oldState = writeObjectState;
565
566                     try {
567
568                         setState(NOT_IN_WRITE_OBJECT);
569
570                         if (currentClassDesc.hasWriteObject()) {
571                             invokeObjectWriter(currentClassDesc, obj );
572                         } else {
573                             defaultWriteObjectDelegate();
574                         }
575                     } finally {
576                         setState(oldState);
577                     }
578
579             } while (classDescStack.size() > stackMark &&
580                  (currentClassDesc = (ObjectStreamClass)classDescStack.pop()) != null);
581             } finally {
582         classDescStack.setSize(stackMark);
583             }
584         }
585     }
586
587     /*
588      * Invoke writer.
589      * _REVISIT_ invokeObjectWriter and invokeObjectReader behave inconsistently with each other since
590      * the reader returns a boolean...fix later
591      */

592     private void invokeObjectWriter(ObjectStreamClass osc, Object JavaDoc obj)
593     throws IOException JavaDoc
594     {
595     Class JavaDoc c = osc.forClass() ;
596
597         try {
598
599         // Write format version
600
orbStream.write_octet(streamFormatVersion);
601
602             writeObjectState.enterWriteObject(this);
603
604         // writeObject(obj, c, this);
605
osc.writeObjectMethod.invoke( obj, writeObjectArgList ) ;
606
607             writeObjectState.exitWriteObject(this);
608
609         } catch (InvocationTargetException JavaDoc e) {
610             Throwable JavaDoc t = e.getTargetException();
611             if (t instanceof IOException JavaDoc)
612             throw (IOException JavaDoc)t;
613             else if (t instanceof RuntimeException JavaDoc)
614             throw (RuntimeException JavaDoc) t;
615             else if (t instanceof Error JavaDoc)
616             throw (Error JavaDoc) t;
617             else
618         // XXX I18N, Logging needed.
619
throw new Error JavaDoc("invokeObjectWriter internal error",e);
620         } catch (IllegalAccessException JavaDoc e) {
621             // cannot happen
622
}
623     }
624
625     void writeField(ObjectStreamField field, Object JavaDoc value) throws IOException JavaDoc {
626         switch (field.getTypeCode()) {
627             case 'B':
628                 if (value == null)
629                     orbStream.write_octet((byte)0);
630                 else
631                     orbStream.write_octet(((Byte JavaDoc)value).byteValue());
632         break;
633         case 'C':
634                 if (value == null)
635                     orbStream.write_wchar((char)0);
636                 else
637                     orbStream.write_wchar(((Character JavaDoc)value).charValue());
638         break;
639         case 'F':
640                 if (value == null)
641                     orbStream.write_float((float)0);
642                 else
643                     orbStream.write_float(((Float JavaDoc)value).floatValue());
644         break;
645             case 'D':
646                 if (value == null)
647                     orbStream.write_double((double)0);
648                 else
649                     orbStream.write_double(((Double JavaDoc)value).doubleValue());
650         break;
651         case 'I':
652                 if (value == null)
653                     orbStream.write_long((int)0);
654                 else
655                     orbStream.write_long(((Integer JavaDoc)value).intValue());
656         break;
657         case 'J':
658                 if (value == null)
659                     orbStream.write_longlong((long)0);
660                 else
661                     orbStream.write_longlong(((Long JavaDoc)value).longValue());
662         break;
663         case 'S':
664                 if (value == null)
665                     orbStream.write_short((short)0);
666                 else
667                     orbStream.write_short(((Short JavaDoc)value).shortValue());
668         break;
669         case 'Z':
670                 if (value == null)
671                     orbStream.write_boolean(false);
672                 else
673                     orbStream.write_boolean(((Boolean JavaDoc)value).booleanValue());
674         break;
675         case '[':
676         case 'L':
677                 // What to do if it's null?
678
writeObjectField(field, value);
679         break;
680         default:
681         // XXX I18N, Logging needed.
682
throw new InvalidClassException JavaDoc(currentClassDesc.getName());
683         }
684     }
685
686     private void writeObjectField(ObjectStreamField field,
687                                   Object JavaDoc objectValue) throws IOException JavaDoc {
688
689         if (ObjectStreamClassCorbaExt.isAny(field.getTypeString())) {
690             javax.rmi.CORBA.Util.writeAny(orbStream, objectValue);
691         }
692         else {
693             Class JavaDoc type = field.getType();
694             int callType = ValueHandlerImpl.kValueType;
695                     
696             if (type.isInterface()) {
697                 String JavaDoc className = type.getName();
698                 
699                 if (java.rmi.Remote JavaDoc.class.isAssignableFrom(type)) {
700                     
701                     // RMI Object reference...
702

703                     callType = ValueHandlerImpl.kRemoteType;
704                     
705                     
706                 } else if (org.omg.CORBA.Object JavaDoc.class.isAssignableFrom(type)){
707                     
708                     // IDL Object reference...
709
callType = ValueHandlerImpl.kRemoteType;
710                     
711                 } else if (RepositoryId.isAbstractBase(type)) {
712                     // IDL Abstract Object reference...
713
callType = ValueHandlerImpl.kAbstractType;
714                 } else if (ObjectStreamClassCorbaExt.isAbstractInterface(type)) {
715                     callType = ValueHandlerImpl.kAbstractType;
716                 }
717             }
718                     
719             switch (callType) {
720             case ValueHandlerImpl.kRemoteType:
721                 Util.writeRemoteObject(orbStream, objectValue);
722                 break;
723             case ValueHandlerImpl.kAbstractType:
724                 Util.writeAbstractObject(orbStream, objectValue);
725                 break;
726             case ValueHandlerImpl.kValueType:
727                 try{
728                     orbStream.write_value((java.io.Serializable JavaDoc)objectValue, type);
729                 }
730                 catch(ClassCastException JavaDoc cce){
731                     if (objectValue instanceof java.io.Serializable JavaDoc)
732                         throw cce;
733                     else
734                         Utility.throwNotSerializableForCorba(objectValue.getClass().getName());
735                 }
736             }
737         }
738     }
739
740     /* Write the fields of the specified class by invoking the appropriate
741      * write* method on this class.
742      */

743     private void outputClassFields(Object JavaDoc o, Class JavaDoc cl,
744                    ObjectStreamField[] fields)
745     throws IOException JavaDoc, InvalidClassException JavaDoc {
746
747         for (int i = 0; i < fields.length; i++) {
748             if (fields[i].getField() == null)
749         // XXX I18N, Logging needed.
750
throw new InvalidClassException JavaDoc(cl.getName(),
751                         "Nonexistent field " + fields[i].getName());
752
753         try {
754         switch (fields[i].getTypeCode()) {
755             case 'B':
756             byte byteValue = fields[i].getField().getByte( o ) ;
757             orbStream.write_octet(byteValue);
758             break;
759             case 'C':
760             char charValue = fields[i].getField().getChar( o ) ;
761             orbStream.write_wchar(charValue);
762             break;
763             case 'F':
764             float floatValue = fields[i].getField().getFloat( o ) ;
765             orbStream.write_float(floatValue);
766             break;
767             case 'D' :
768             double doubleValue = fields[i].getField().getDouble( o ) ;
769             orbStream.write_double(doubleValue);
770             break;
771             case 'I':
772             int intValue = fields[i].getField().getInt( o ) ;
773             orbStream.write_long(intValue);
774             break;
775             case 'J':
776             long longValue = fields[i].getField().getLong( o ) ;
777             orbStream.write_longlong(longValue);
778             break;
779             case 'S':
780             short shortValue = fields[i].getField().getShort( o ) ;
781             orbStream.write_short(shortValue);
782             break;
783             case 'Z':
784             boolean booleanValue = fields[i].getField().getBoolean( o ) ;
785             orbStream.write_boolean(booleanValue);
786             break;
787             case '[':
788             case 'L':
789             Object JavaDoc objectValue = fields[i].getField().get( o ) ;
790             writeObjectField(fields[i], objectValue);
791             break;
792             default:
793             // XXX I18N, Logging needed.
794
throw new InvalidClassException JavaDoc(cl.getName());
795         }
796         } catch (IllegalAccessException JavaDoc exc) {
797         throw wrapper.illegalFieldAccess( exc, fields[i].getName() ) ;
798         }
799         }
800     }
801 }
802
803
Popular Tags