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 ByteBufferAsFloatBufferL // package-private
  10. extends FloatBuffer
  11. {
  12. protected final ByteBuffer bb;
  13. protected final int offset;
  14. ByteBufferAsFloatBufferL(ByteBuffer bb) { // package-private
  15. super(-1, 0,
  16. bb.remaining() >> 2,
  17. bb.remaining() >> 2);
  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. ByteBufferAsFloatBufferL(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 FloatBuffer 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 << 2) + offset;
  40. return new ByteBufferAsFloatBufferL(bb, -1, 0, rem, rem, off);
  41. }
  42. public FloatBuffer duplicate() {
  43. return new ByteBufferAsFloatBufferL(bb,
  44. this.markValue(),
  45. this.position(),
  46. this.limit(),
  47. this.capacity(),
  48. offset);
  49. }
  50. public FloatBuffer asReadOnlyBuffer() {
  51. return new ByteBufferAsFloatBufferRL(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 << 2) + offset;
  60. }
  61. public float get() {
  62. return Bits.getFloatL(bb, ix(nextGetIndex()));
  63. }
  64. public float get(int i) {
  65. return Bits.getFloatL(bb, ix(checkIndex(i)));
  66. }
  67. public FloatBuffer put(float x) {
  68. Bits.putFloatL(bb, ix(nextPutIndex()), x);
  69. return this;
  70. }
  71. public FloatBuffer put(int i, float x) {
  72. Bits.putFloatL(bb, ix(checkIndex(i)), x);
  73. return this;
  74. }
  75. public FloatBuffer 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 << 2);
  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. }