1. /*
  2. * @(#)ByteBufferAs-X-Buffer.java 1.14 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. // -- This file was mechanically generated: Do not edit! -- //
  8. package java.nio;
  9. class ByteBufferAsLongBufferL // package-private
  10. extends LongBuffer
  11. {
  12. protected final ByteBuffer bb;
  13. protected final int offset;
  14. ByteBufferAsLongBufferL(ByteBuffer bb) { // package-private
  15. super(-1, 0,
  16. bb.remaining() >> 3,
  17. bb.remaining() >> 3);
  18. this.bb = bb;
  19. // enforce limit == capacity
  20. int cap = this.capacity();
  21. this.limit(cap);
  22. int pos = this.position();
  23. assert (pos <= cap);
  24. offset = pos;
  25. }
  26. ByteBufferAsLongBufferL(ByteBuffer bb,
  27. int mark, int pos, int lim, int cap,
  28. int off)
  29. {
  30. super(mark, pos, lim, cap);
  31. this.bb = bb;
  32. offset = off;
  33. }
  34. public LongBuffer slice() {
  35. int pos = this.position();
  36. int lim = this.limit();
  37. assert (pos <= lim);
  38. int rem = (pos <= lim ? lim - pos : 0);
  39. int off = (pos << 3) + offset;
  40. return new ByteBufferAsLongBufferL(bb, -1, 0, rem, rem, off);
  41. }
  42. public LongBuffer duplicate() {
  43. return new ByteBufferAsLongBufferL(bb,
  44. this.markValue(),
  45. this.position(),
  46. this.limit(),
  47. this.capacity(),
  48. offset);
  49. }
  50. public LongBuffer asReadOnlyBuffer() {
  51. return new ByteBufferAsLongBufferRL(bb,
  52. this.markValue(),
  53. this.position(),
  54. this.limit(),
  55. this.capacity(),
  56. offset);
  57. }
  58. protected int ix(int i) {
  59. return (i << 3) + offset;
  60. }
  61. public long get() {
  62. return Bits.getLongL(bb, ix(nextGetIndex()));
  63. }
  64. public long get(int i) {
  65. return Bits.getLongL(bb, ix(checkIndex(i)));
  66. }
  67. public LongBuffer put(long x) {
  68. Bits.putLongL(bb, ix(nextPutIndex()), x);
  69. return this;
  70. }
  71. public LongBuffer put(int i, long x) {
  72. Bits.putLongL(bb, ix(checkIndex(i)), x);
  73. return this;
  74. }
  75. public LongBuffer compact() {
  76. int pos = position();
  77. int lim = limit();
  78. assert (pos <= lim);
  79. int rem = (pos <= lim ? lim - pos : 0);
  80. ByteBuffer db = bb.duplicate();
  81. db.limit(ix(lim));
  82. db.position(ix(0));
  83. ByteBuffer sb = db.slice();
  84. sb.position(pos << 3);
  85. sb.compact();
  86. position(rem);
  87. limit(capacity());
  88. return this;
  89. }
  90. public boolean isDirect() {
  91. return bb.isDirect();
  92. }
  93. public boolean isReadOnly() {
  94. return false;
  95. }
  96. public ByteOrder order() {
  97. return ByteOrder.LITTLE_ENDIAN;
  98. }
  99. }