KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > protocol > giopmsgheaders > Message_1_2


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

7 package com.sun.corba.se.impl.protocol.giopmsgheaders;
8
9 import java.nio.ByteBuffer JavaDoc;
10
11 import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
12
13 public class Message_1_2 extends Message_1_1
14 {
15     protected int request_id = (int) 0;
16
17     Message_1_2() {}
18     
19     Message_1_2(int _magic, GIOPVersion _GIOP_version, byte _flags,
20             byte _message_type, int _message_size) {
21
22         super(_magic,
23               _GIOP_version,
24               _flags,
25               _message_type,
26               _message_size);
27     }
28
29     /**
30      * The byteBuffer is presumed to have contents of the message already
31      * read in. It must have 12 bytes of space at the beginning for the GIOP header,
32      * but the header doesn't have to be copied in.
33      */

34     public void unmarshalRequestID(ByteBuffer JavaDoc byteBuffer) {
35         int b1, b2, b3, b4;
36
37         if (!isLittleEndian()) {
38             b1 = (byteBuffer.get(GIOPMessageHeaderLength+0) << 24) & 0xFF000000;
39             b2 = (byteBuffer.get(GIOPMessageHeaderLength+1) << 16) & 0x00FF0000;
40             b3 = (byteBuffer.get(GIOPMessageHeaderLength+2) << 8) & 0x0000FF00;
41             b4 = (byteBuffer.get(GIOPMessageHeaderLength+3) << 0) & 0x000000FF;
42         } else {
43             b1 = (byteBuffer.get(GIOPMessageHeaderLength+3) << 24) & 0xFF000000;
44             b2 = (byteBuffer.get(GIOPMessageHeaderLength+2) << 16) & 0x00FF0000;
45             b3 = (byteBuffer.get(GIOPMessageHeaderLength+1) << 8) & 0x0000FF00;
46             b4 = (byteBuffer.get(GIOPMessageHeaderLength+0) << 0) & 0x000000FF;
47         }
48
49         this.request_id = (b1 | b2 | b3 | b4);
50     }
51
52     public void write(org.omg.CORBA.portable.OutputStream JavaDoc ostream) {
53     if (this.encodingVersion == Message.CDR_ENC_VERSION) {
54         super.write(ostream);
55         return;
56     }
57     GIOPVersion gv = this.GIOP_version; // save
58
this.GIOP_version = GIOPVersion.getInstance((byte)13,
59                             this.encodingVersion);
60     super.write(ostream);
61     this.GIOP_version = gv; // restore
62
}
63 }
64
65
Popular Tags