38 |
|
|
39 |
package gnu.CORBA; |
package gnu.CORBA; |
40 |
|
|
41 |
import gnu.CORBA.CDR.cdrBufInput; |
import gnu.CORBA.CDR.BufferredCdrInput; |
42 |
import gnu.CORBA.CDR.cdrBufOutput; |
import gnu.CORBA.CDR.BufferedCdrOutput; |
43 |
import gnu.CORBA.CDR.cdrOutput; |
import gnu.CORBA.CDR.AbstractCdrOutput; |
44 |
|
|
45 |
import org.omg.CORBA.Any; |
import org.omg.CORBA.Any; |
46 |
import org.omg.CORBA.LocalObject; |
import org.omg.CORBA.LocalObject; |
125 |
public Any decode(byte[] them) |
public Any decode(byte[] them) |
126 |
throws FormatMismatch |
throws FormatMismatch |
127 |
{ |
{ |
128 |
cdrBufInput input = createInput(them); |
BufferredCdrInput input = createInput(them); |
129 |
cdrBufInput encapsulation = createEncapsulation(them, input); |
BufferredCdrInput encapsulation = createEncapsulation(them, input); |
130 |
|
|
131 |
TypeCode type = encapsulation.read_TypeCode(); |
TypeCode type = encapsulation.read_TypeCode(); |
132 |
|
|
142 |
return readAny(type, encapsulation); |
return readAny(type, encapsulation); |
143 |
} |
} |
144 |
|
|
145 |
private cdrBufInput createEncapsulation(byte[] them, cdrBufInput input) |
private BufferredCdrInput createEncapsulation(byte[] them, BufferredCdrInput input) |
146 |
{ |
{ |
147 |
cdrBufInput encapsulation; |
BufferredCdrInput encapsulation; |
148 |
|
|
149 |
if ((them [ 0 ] | them [ 1 ] | them [ 2 ] | them [ 3 ]) == 0) |
if ((them [ 0 ] | them [ 1 ] | them [ 2 ] | them [ 3 ]) == 0) |
150 |
{ |
{ |
163 |
{ |
{ |
164 |
checkTypePossibility("", that.type()); |
checkTypePossibility("", that.type()); |
165 |
|
|
166 |
cdrBufOutput output = createOutput(that); |
BufferedCdrOutput output = createOutput(that); |
167 |
|
|
168 |
// cdrBufOutput has internal support for this encoding. |
// BufferedCdrOutput has internal support for this encoding. |
169 |
cdrOutput encapsulation = output.createEncapsulation(); |
AbstractCdrOutput encapsulation = output.createEncapsulation(); |
170 |
|
|
171 |
try |
try |
172 |
{ |
{ |
207 |
throw new TypeMismatch(ex.getMessage()); |
throw new TypeMismatch(ex.getMessage()); |
208 |
} |
} |
209 |
|
|
210 |
cdrBufInput input = createInput(them); |
BufferredCdrInput input = createInput(them); |
211 |
cdrBufInput encapsulation = createEncapsulation(them, input); |
BufferredCdrInput encapsulation = createEncapsulation(them, input); |
212 |
return readAny(type, encapsulation); |
return readAny(type, encapsulation); |
213 |
} |
} |
214 |
|
|
218 |
* @param type a type of the Any to read. |
* @param type a type of the Any to read. |
219 |
* @param input the encapsulation stream. |
* @param input the encapsulation stream. |
220 |
*/ |
*/ |
221 |
private Any readAny(TypeCode type, cdrBufInput encapsulation) |
private Any readAny(TypeCode type, BufferredCdrInput encapsulation) |
222 |
throws MARSHAL |
throws MARSHAL |
223 |
{ |
{ |
224 |
gnuAny a = new gnuAny(); |
gnuAny a = new gnuAny(); |
225 |
a.setOrb(orb); |
a.setOrb(orb); |
226 |
|
|
227 |
// cdrBufInput has internal support for this encoding. |
// BufferredCdrInput has internal support for this encoding. |
228 |
a.read_value(encapsulation, type); |
a.read_value(encapsulation, type); |
229 |
return a; |
return a; |
230 |
} |
} |
235 |
{ |
{ |
236 |
checkTypePossibility("", that.type()); |
checkTypePossibility("", that.type()); |
237 |
|
|
238 |
cdrBufOutput output = createOutput(that); |
BufferedCdrOutput output = createOutput(that); |
239 |
|
|
240 |
cdrOutput encapsulation = output.createEncapsulation(); |
AbstractCdrOutput encapsulation = output.createEncapsulation(); |
241 |
|
|
242 |
try |
try |
243 |
{ |
{ |
258 |
|
|
259 |
/** |
/** |
260 |
* Create the CDR output stream for writing the given Any. |
* Create the CDR output stream for writing the given Any. |
261 |
* The cdrBufOutput has internal support for encapsulation encodings. |
* The BufferedCdrOutput has internal support for encapsulation encodings. |
262 |
* |
* |
263 |
* @param that the Any that will be written. |
* @param that the Any that will be written. |
264 |
* |
* |
267 |
* @throws InvalidTypeForEncoding if that Any cannot be written under the |
* @throws InvalidTypeForEncoding if that Any cannot be written under the |
268 |
* given version. |
* given version. |
269 |
*/ |
*/ |
270 |
private cdrBufOutput createOutput(Any that) |
private BufferedCdrOutput createOutput(Any that) |
271 |
throws InvalidTypeForEncoding |
throws InvalidTypeForEncoding |
272 |
{ |
{ |
273 |
cdrBufOutput output = new cdrBufOutput(); |
BufferedCdrOutput output = new BufferedCdrOutput(); |
274 |
output.setOrb(orb); |
output.setOrb(orb); |
275 |
output.setVersion(version); |
output.setVersion(version); |
276 |
return output; |
return output; |
327 |
* |
* |
328 |
* @return the stream. |
* @return the stream. |
329 |
*/ |
*/ |
330 |
private cdrBufInput createInput(byte[] them) |
private BufferredCdrInput createInput(byte[] them) |
331 |
{ |
{ |
332 |
cdrBufInput input = new cdrBufInput(them); |
BufferredCdrInput input = new BufferredCdrInput(them); |
333 |
input.setOrb(orb); |
input.setOrb(orb); |
334 |
input.setVersion(version); |
input.setVersion(version); |
335 |
return input; |
return input; |