1 |
775 |
jeremybenn |
/* OutputStream.java --
|
2 |
|
|
Copyright (C) 2005, 2006 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.CustomValue;
|
45 |
|
|
import org.omg.CORBA.portable.StreamableValue;
|
46 |
|
|
import org.omg.CORBA.portable.ValueBase;
|
47 |
|
|
|
48 |
|
|
import java.io.Serializable;
|
49 |
|
|
|
50 |
|
|
/**
|
51 |
|
|
* This class defines a new CDR input stream methods, added since
|
52 |
|
|
* CORBA 2.3.
|
53 |
|
|
*
|
54 |
|
|
* This class is abstract; no direct instances can be instantiated.
|
55 |
|
|
* Also, up till v 1.4 inclusive there are no methods that would
|
56 |
|
|
* return it directly.
|
57 |
|
|
*
|
58 |
|
|
* However since 1.3 all methods, declared as returning an
|
59 |
|
|
* org.omg.CORBA.portable.InputStream actually return the instance of this
|
60 |
|
|
* derived class and the new methods are accessible after the casting
|
61 |
|
|
* operation.
|
62 |
|
|
*
|
63 |
|
|
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
|
64 |
|
|
*/
|
65 |
|
|
public abstract class OutputStream
|
66 |
|
|
extends org.omg.CORBA.portable.OutputStream
|
67 |
|
|
{
|
68 |
|
|
/**
|
69 |
|
|
* Writes an abstract interface to the stream. An abstract interface can be
|
70 |
|
|
* eithe CORBA object or value type and is written as a union with the boolean
|
71 |
|
|
* discriminator (false for objects, true for value types).
|
72 |
|
|
*
|
73 |
|
|
* The object from value is separated by fact that all values implement the
|
74 |
|
|
* {@link ValueBase} interface. Also, the passed parameter is treated as value
|
75 |
|
|
* it it does not implement CORBA Object.
|
76 |
|
|
*
|
77 |
|
|
* @param an_interface an abstract interface to write.
|
78 |
|
|
*/
|
79 |
|
|
public void write_abstract_interface(java.lang.Object an_interface)
|
80 |
|
|
{
|
81 |
|
|
boolean isObject = !(an_interface instanceof ValueBase)
|
82 |
|
|
&& an_interface instanceof org.omg.CORBA.Object;
|
83 |
|
|
|
84 |
|
|
write_boolean(isObject);
|
85 |
|
|
|
86 |
|
|
if (isObject)
|
87 |
|
|
write_Object((org.omg.CORBA.Object) an_interface);
|
88 |
|
|
else
|
89 |
|
|
write_value((Serializable) an_interface);
|
90 |
|
|
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
/**
|
94 |
|
|
* Writes a value type into the output stream.
|
95 |
|
|
*
|
96 |
|
|
* The value type must implement either {@link CustomValue} (for user-defined
|
97 |
|
|
* writing method) or {@link StreamableValue} (for standard writing using code,
|
98 |
|
|
* generated by IDL compiler).
|
99 |
|
|
*
|
100 |
|
|
* The written record will have a repository id, matching the class of the
|
101 |
|
|
* passed object. The codebase will not be written.
|
102 |
|
|
*
|
103 |
|
|
* @param value a value type object to write.
|
104 |
|
|
*/
|
105 |
|
|
public void write_value(Serializable value)
|
106 |
|
|
{
|
107 |
|
|
Vio.write(this, value);
|
108 |
|
|
}
|
109 |
|
|
|
110 |
|
|
/**
|
111 |
|
|
* Write value to the stream using the boxed value helper.
|
112 |
|
|
*
|
113 |
|
|
* The value type must implement either {@link CustomValue}
|
114 |
|
|
* (for user-defined writing method) or {@link StreamableValue}
|
115 |
|
|
* (for standard writing using code, generated by IDL compiler).
|
116 |
|
|
*
|
117 |
|
|
* @param value a value to write.
|
118 |
|
|
* @param helper a helper, responsible for the writing operation.
|
119 |
|
|
*/
|
120 |
|
|
public void write_value(Serializable value, BoxedValueHelper helper)
|
121 |
|
|
{
|
122 |
|
|
Vio.write(this, value, helper);
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
/**
|
126 |
|
|
* Writes a value type into the output stream, stating it is an
|
127 |
|
|
* instance of the given class. The written record
|
128 |
|
|
* will have a repository id, matching the passed class.
|
129 |
|
|
* The codebase will not be written. It the object
|
130 |
|
|
* being written is an instance of the different class, this results
|
131 |
|
|
* writing two Id inheritance hierarchy.
|
132 |
|
|
*
|
133 |
|
|
* The value type must implement either {@link CustomValue}
|
134 |
|
|
* (for user-defined writing method) or {@link StreamableValue}
|
135 |
|
|
* (for standard writing using code, generated by IDL compiler).
|
136 |
|
|
*
|
137 |
|
|
* @param value a value type object to write.
|
138 |
|
|
*/
|
139 |
|
|
@SuppressWarnings("unchecked") // Needed for API compatibility
|
140 |
|
|
public void write_value(Serializable value, Class clz)
|
141 |
|
|
{
|
142 |
|
|
Vio.write(this, value, clz);
|
143 |
|
|
}
|
144 |
|
|
|
145 |
|
|
/**
|
146 |
|
|
* Writes a value type into the output stream, stating it has the given
|
147 |
|
|
* repository id.
|
148 |
|
|
*
|
149 |
|
|
* The value type must implement either {@link CustomValue} (for user-defined
|
150 |
|
|
* writing method) or {@link StreamableValue} (for standard writing using code,
|
151 |
|
|
* generated by IDL compiler).
|
152 |
|
|
*
|
153 |
|
|
* @param repository_id a repository id of the value type.
|
154 |
|
|
*
|
155 |
|
|
* @param value a value type object to write.
|
156 |
|
|
*/
|
157 |
|
|
public void write_value(Serializable value, String repository_id)
|
158 |
|
|
{
|
159 |
|
|
Vio.write(this, value, repository_id);
|
160 |
|
|
}
|
161 |
|
|
}
|