1. /*
  2. * @(#)Message_1_0.java 1.10 03/12/19
  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. import java.nio.ByteBuffer;
  9. import org.omg.CORBA.INTERNAL;
  10. import org.omg.CORBA.CompletionStatus;
  11. import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
  12. import com.sun.corba.se.spi.logging.CORBALogDomains ;
  13. import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
  14. /*
  15. * This implements the GIOP 1.0 Message header.
  16. *
  17. * @author Ram Jeyaraman 05/14/2000
  18. * @version 1.0
  19. */
  20. public class Message_1_0
  21. extends com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase {
  22. private static ORBUtilSystemException wrapper =
  23. ORBUtilSystemException.get( CORBALogDomains.RPC_PROTOCOL ) ;
  24. // Instance variables
  25. int magic = (int) 0;
  26. GIOPVersion GIOP_version = null;
  27. boolean byte_order = false;
  28. byte message_type = (byte) 0;
  29. int message_size = (int) 0;
  30. // Constructor
  31. Message_1_0() {
  32. }
  33. Message_1_0(int _magic, boolean _byte_order, byte _message_type,
  34. int _message_size) {
  35. magic = _magic;
  36. GIOP_version = GIOPVersion.V1_0;
  37. byte_order = _byte_order;
  38. message_type = _message_type;
  39. message_size = _message_size;
  40. }
  41. // Accessor methods
  42. public GIOPVersion getGIOPVersion() {
  43. return this.GIOP_version;
  44. }
  45. public int getType() {
  46. return this.message_type;
  47. }
  48. public int getSize() {
  49. return this.message_size;
  50. }
  51. public boolean isLittleEndian() {
  52. return this.byte_order;
  53. }
  54. public boolean moreFragmentsToFollow() {
  55. return false;
  56. }
  57. // Mutator methods
  58. public void setSize(ByteBuffer byteBuffer, int size) {
  59. this.message_size = size;
  60. //
  61. // Patch the size field in the header.
  62. //
  63. int patch = size - GIOPMessageHeaderLength;
  64. if (!isLittleEndian()) {
  65. byteBuffer.put(8, (byte)((patch >>> 24) & 0xFF));
  66. byteBuffer.put(9, (byte)((patch >>> 16) & 0xFF));
  67. byteBuffer.put(10, (byte)((patch >>> 8) & 0xFF));
  68. byteBuffer.put(11, (byte)((patch >>> 0) & 0xFF));
  69. } else {
  70. byteBuffer.put(8, (byte)((patch >>> 0) & 0xFF));
  71. byteBuffer.put(9, (byte)((patch >>> 8) & 0xFF));
  72. byteBuffer.put(10, (byte)((patch >>> 16) & 0xFF));
  73. byteBuffer.put(11, (byte)((patch >>> 24) & 0xFF));
  74. }
  75. }
  76. public FragmentMessage createFragmentMessage() {
  77. throw wrapper.fragmentationDisallowed(
  78. CompletionStatus.COMPLETED_MAYBE);
  79. }
  80. // IO methods
  81. // This should do nothing even if it is called. The Message Header already
  82. // is read off java.io.InputStream (not a CDRInputStream) by IIOPConnection
  83. // in order to choose the correct CDR Version, msg_type, and msg_size.
  84. // So, we would never need to read the Message Header off a CDRInputStream.
  85. public void read(org.omg.CORBA.portable.InputStream istream) {
  86. /*
  87. this.magic = istream.read_long();
  88. this.GIOP_version = (new GIOPVersion()).read(istream);
  89. this.byte_order = istream.read_boolean();
  90. this.message_type = istream.read_octet();
  91. this.message_size = istream.read_ulong();
  92. */
  93. }
  94. public void write(org.omg.CORBA.portable.OutputStream ostream) {
  95. ostream.write_long(this.magic);
  96. nullCheck(this.GIOP_version);
  97. this.GIOP_version.write(ostream);
  98. ostream.write_boolean(this.byte_order);
  99. ostream.write_octet(this.message_type);
  100. ostream.write_ulong(this.message_size);
  101. }
  102. } // class Message_1_0