1. /*
  2. * @(#)ByteBufferWithInfo.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;
  8. public class ByteBufferWithInfo
  9. {
  10. public byte[] buf; // Marshal buffer.
  11. public int buflen; // Total length of buffer. // Unnecessary...
  12. public int index; // Current empty position in buffer.
  13. public int needed; // How many more bytes are needed on overflow.
  14. public boolean fragmented; // Did the overflow operation fragment?
  15. public ByteBufferWithInfo(byte[] buf, int index)
  16. {
  17. this.buf = buf;
  18. if (buf != null)
  19. this.buflen = buf.length;
  20. this.index = index;
  21. this.needed = 0;
  22. this.fragmented = false;
  23. }
  24. public ByteBufferWithInfo (byte[] buf)
  25. {
  26. this(buf, 0);
  27. }
  28. public ByteBufferWithInfo (int buflen)
  29. {
  30. this(new byte[buflen]);
  31. }
  32. // Shallow copy constructor
  33. public ByteBufferWithInfo (ByteBufferWithInfo bbwi)
  34. {
  35. this.buf = bbwi.buf;
  36. this.buflen = bbwi.buflen;
  37. this.index = bbwi.index;
  38. this.needed = bbwi.needed;
  39. this.fragmented = bbwi.fragmented;
  40. }
  41. // So IIOPOutputStream seems more intuitive
  42. public int getSize()
  43. {
  44. return index;
  45. }
  46. public String toString()
  47. {
  48. StringBuffer str = new StringBuffer("ByteBufferWithInfo:");
  49. str.append(" buflen = " + buflen);
  50. str.append(" index = " + index);
  51. str.append(" needed = " + needed);
  52. str.append(" buf = " + (buf == null ? "null" : "not null"));
  53. str.append(" fragmented = " + fragmented);
  54. return str.toString();
  55. }
  56. }