1. /*
  2. * @(#)Heap-X-Buffer.java 1.27 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. /**
  10. * A read-only HeapIntBuffer. This class extends the corresponding
  11. * read/write class, overriding the mutation methods to throw a {@link
  12. * ReadOnlyBufferException} and overriding the view-buffer methods to return an
  13. * instance of this class rather than of the superclass.
  14. */
  15. class HeapIntBufferR
  16. extends HeapIntBuffer
  17. {
  18. // For speed these fields are actually declared in X-Buffer;
  19. // these declarations are here as documentation
  20. /*
  21. */
  22. HeapIntBufferR(int cap, int lim) { // package-private
  23. super(cap, lim);
  24. this.isReadOnly = true;
  25. }
  26. HeapIntBufferR(int[] buf, int off, int len) { // package-private
  27. super(buf, off, len);
  28. this.isReadOnly = true;
  29. }
  30. protected HeapIntBufferR(int[] buf,
  31. int mark, int pos, int lim, int cap,
  32. int off)
  33. {
  34. super(buf, mark, pos, lim, cap, off);
  35. this.isReadOnly = true;
  36. }
  37. public IntBuffer slice() {
  38. return new HeapIntBufferR(hb,
  39. -1,
  40. 0,
  41. this.remaining(),
  42. this.remaining(),
  43. this.position() + offset);
  44. }
  45. public IntBuffer duplicate() {
  46. return new HeapIntBufferR(hb,
  47. this.markValue(),
  48. this.position(),
  49. this.limit(),
  50. this.capacity(),
  51. offset);
  52. }
  53. public IntBuffer asReadOnlyBuffer() {
  54. return duplicate();
  55. }
  56. public boolean isReadOnly() {
  57. return true;
  58. }
  59. public IntBuffer put(int x) {
  60. throw new ReadOnlyBufferException();
  61. }
  62. public IntBuffer put(int i, int x) {
  63. throw new ReadOnlyBufferException();
  64. }
  65. public IntBuffer put(int[] src, int offset, int length) {
  66. throw new ReadOnlyBufferException();
  67. }
  68. public IntBuffer put(IntBuffer src) {
  69. throw new ReadOnlyBufferException();
  70. }
  71. public IntBuffer compact() {
  72. throw new ReadOnlyBufferException();
  73. }
  74. public ByteOrder order() {
  75. return ByteOrder.nativeOrder();
  76. }
  77. }