1. /*
  2. * @(#)Message_1_0.java 1.8 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.internal.iiop.messages;
  8. import org.omg.CORBA.INTERNAL;
  9. import org.omg.CORBA.CompletionStatus;
  10. import com.sun.corba.se.internal.core.GIOPVersion;
  11. import com.sun.corba.se.internal.orbutil.MinorCodes;
  12. /*
  13. * This implements the GIOP 1.0 Message header.
  14. *
  15. * @author Ram Jeyaraman 05/14/2000
  16. * @version 1.0
  17. */
  18. public class Message_1_0
  19. extends com.sun.corba.se.internal.iiop.messages.MessageBase {
  20. // Instance variables
  21. int magic = (int) 0;
  22. GIOPVersion GIOP_version = null;
  23. boolean byte_order = false;
  24. byte message_type = (byte) 0;
  25. int message_size = (int) 0;
  26. // Constructor
  27. Message_1_0() {}
  28. Message_1_0(int _magic, boolean _byte_order, byte _message_type,
  29. int _message_size) {
  30. magic = _magic;
  31. GIOP_version = GIOPVersion.V1_0;
  32. byte_order = _byte_order;
  33. message_type = _message_type;
  34. message_size = _message_size;
  35. }
  36. // Accessor methods
  37. public GIOPVersion getGIOPVersion() {
  38. return this.GIOP_version;
  39. }
  40. public int getType() {
  41. return this.message_type;
  42. }
  43. public int getSize() {
  44. return this.message_size;
  45. }
  46. public boolean isLittleEndian() {
  47. return this.byte_order;
  48. }
  49. public boolean moreFragmentsToFollow() {
  50. return false;
  51. }
  52. // Mutator methods
  53. public void setSize(byte[] buf, int size) {
  54. this.message_size = size;
  55. //
  56. // Patch the size field in the header.
  57. //
  58. int patch = size - GIOPMessageHeaderLength;
  59. if (!isLittleEndian()) {
  60. buf[8] = (byte)((patch >>> 24) & 0xFF);
  61. buf[9] = (byte)((patch >>> 16) & 0xFF);
  62. buf[10] = (byte)((patch >>> 8) & 0xFF);
  63. buf[11] = (byte)((patch >>> 0) & 0xFF);
  64. } else {
  65. buf[8] = (byte)((patch >>> 0) & 0xFF);
  66. buf[9] = (byte)((patch >>> 8) & 0xFF);
  67. buf[10] = (byte)((patch >>> 16) & 0xFF);
  68. buf[11] = (byte)((patch >>> 24) & 0xFF);
  69. }
  70. }
  71. public FragmentMessage createFragmentMessage() {
  72. throw new INTERNAL(MinorCodes.FRAGMENTATION_DISALLOWED,
  73. CompletionStatus.COMPLETED_MAYBE);
  74. }
  75. // IO methods
  76. // This should do nothing even if it is called. The Message Header already
  77. // is read off java.io.InputStream (not a CDRInputStream) by IIOPConnection
  78. // in order to choose the correct CDR Version, msg_type, and msg_size.
  79. // So, we would never need to read the Message Header off a CDRInputStream.
  80. public void read(org.omg.CORBA.portable.InputStream istream) {
  81. /*
  82. this.magic = istream.read_long();
  83. this.GIOP_version = (new GIOPVersion()).read(istream);
  84. this.byte_order = istream.read_boolean();
  85. this.message_type = istream.read_octet();
  86. this.message_size = istream.read_ulong();
  87. */
  88. }
  89. public void write(org.omg.CORBA.portable.OutputStream ostream) {
  90. ostream.write_long(this.magic);
  91. nullCheck(this.GIOP_version);
  92. this.GIOP_version.write(ostream);
  93. ostream.write_boolean(this.byte_order);
  94. ostream.write_octet(this.message_type);
  95. ostream.write_ulong(this.message_size);
  96. }
  97. } // class Message_1_0