OSDN Git Service

Imported GNU Classpath 0.19 + gcj-import-20051115.
[pf3gnuchains/gcc-fork.git] / libjava / classpath / org / omg / CORBA_2_3 / portable / OutputStream.java
1 /* OutputStream.java --
2    Copyright (C) 2005 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING.  If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
20
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library.  Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
25
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module.  An independent module is a module which is not derived from
33 or based on this library.  If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so.  If you do not wish to do so, delete this
36 exception statement from your version. */
37
38
39 package org.omg.CORBA_2_3.portable;
40
41 import gnu.CORBA.CDR.Vio;
42
43 import org.omg.CORBA.portable.BoxedValueHelper;
44 import org.omg.CORBA.portable.ValueBase;
45
46 import java.io.Serializable;
47
48 /**
49  * This class defines a new CDR input stream methods, added since
50  * CORBA 2.3.
51  *
52  * This class is abstract; no direct instances can be instantiated.
53  * Also, up till v 1.4 inclusive there are no methods that would
54  * return it directly.
55  *
56  * However since 1.3 all methods, declared as returning an
57  * org.omg.CORBA.portable.InputStream actually return the instance of this
58  * derived class and the new methods are accessible after the casting
59  * operation.
60  *
61  * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
62  */
63 public abstract class OutputStream
64   extends org.omg.CORBA.portable.OutputStream
65 {
66   /**
67    * Writes an abstract interface to the stream. An abstract interface can be
68    * eithe CORBA object or value type and is written as a union with the boolean
69    * discriminator (false for objects, true for value types).
70    * 
71    * The object from value is separated by fact that all values implement the
72    * {@link ValueBase} interface. Also, the passed parameter is treated as value
73    * it it does not implement CORBA Object.
74    * 
75    * @param an_interface an abstract interface to write.
76    */
77   public void write_abstract_interface(java.lang.Object an_interface)
78   {
79     boolean isObject = !(an_interface instanceof ValueBase)
80       && an_interface instanceof org.omg.CORBA.Object;
81
82     write_boolean(isObject);
83
84     if (isObject)
85       write_Object((org.omg.CORBA.Object) an_interface);
86     else
87       write_value((Serializable) an_interface);
88
89   }
90
91   /**
92    * Writes a value type into the output stream.
93    * 
94    * The value type must implement either {@link CustomValue} (for user-defined
95    * writing method) or {@link StramableValue} (for standard writing using code,
96    * generated by IDL compiler).
97    * 
98    * The written record will have a repository id, matching the class of the
99    * passed object. The codebase will not be written.
100    * 
101    * @param value a value type object to write.
102    */
103   public void write_value(Serializable value)
104   {
105     Vio.write(this, value);
106   }
107
108   /**
109    * Write value to the stream using the boxed value helper.
110    *
111    * The value type must implement either {@link CustomValue}
112    * (for user-defined writing method) or {@link StramableValue}
113    * (for standard writing using code, generated by IDL compiler).
114    *
115    * @param value a value to write.
116    * @param helper a helper, responsible for the writing operation.
117    */
118   public void write_value(Serializable value, BoxedValueHelper helper)
119   {
120     Vio.write(this, value, helper);
121   }
122
123   /**
124    * Writes a value type into the output stream, stating it is an
125    * instance of the given class. The written record
126    * will have a repository id, matching the passed class.
127    * The codebase will not be written. It the object
128    * being written is an instance of the different class, this results
129    * writing two Id inheritance hierarchy.
130    *
131    * The value type must implement either {@link CustomValue}
132    * (for user-defined writing method) or {@link StramableValue}
133    * (for standard writing using code, generated by IDL compiler).
134    *
135    * @param value a value type object to write.
136    */
137   public void write_value(Serializable value, Class clz)
138   {
139     Vio.write(this, value, clz);
140   }
141
142   /**
143    * Writes a value type into the output stream, stating it has the given
144    * repository id.
145    * 
146    * The value type must implement either {@link CustomValue} (for user-defined
147    * writing method) or {@link StramableValue} (for standard writing using code,
148    * generated by IDL compiler).
149    * 
150    * @param repository_id a repository id of the value type.
151    * 
152    * @param value a value type object to write.
153    */
154   public void write_value(Serializable value, String repository_id)
155   {
156     Vio.write(this, value, repository_id);
157   }
158 }