Logo Search packages:      
Sourcecode: icedtea-java7 version File versions

HeapByteBuffer.java

/*
 * Copyright 2000-2002 Sun Microsystems, Inc.  All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Sun designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Sun in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 */

// -- This file was mechanically generated: Do not edit! -- //

package java.nio;


/**

 * A read/write HeapByteBuffer.






 */

00042 class HeapByteBuffer
    extends ByteBuffer
{

    // For speed these fields are actually declared in X-Buffer;
    // these declarations are here as documentation
    /*

    protected final byte[] hb;
    protected final int offset;

    */

    HeapByteBuffer(int cap, int lim) {          // package-private

      super(-1, 0, lim, cap, new byte[cap], 0);
      /*
      hb = new byte[cap];
      offset = 0;
      */




    }

    HeapByteBuffer(byte[] buf, int off, int len) { // package-private

      super(-1, off, off + len, buf.length, buf, 0);
      /*
      hb = buf;
      offset = 0;
      */




    }

    protected HeapByteBuffer(byte[] buf,
                           int mark, int pos, int lim, int cap,
                           int off)
    {

      super(mark, pos, lim, cap, buf, off);
      /*
      hb = buf;
      offset = off;
      */




    }

00097     public ByteBuffer slice() {
      return new HeapByteBuffer(hb,
                              -1,
                              0,
                              this.remaining(),
                              this.remaining(),
                              this.position() + offset);
    }

00106     public ByteBuffer duplicate() {
      return new HeapByteBuffer(hb,
                              this.markValue(),
                              this.position(),
                              this.limit(),
                              this.capacity(),
                              offset);
    }

00115     public ByteBuffer asReadOnlyBuffer() {

      return new HeapByteBufferR(hb,
                             this.markValue(),
                             this.position(),
                             this.limit(),
                             this.capacity(),
                             offset);



    }



    protected int ix(int i) {
      return i + offset;
    }

00134     public byte get() {
      return hb[ix(nextGetIndex())];
    }

00138     public byte get(int i) {
      return hb[ix(checkIndex(i))];
    }

00142     public ByteBuffer get(byte[] dst, int offset, int length) {
      checkBounds(offset, length, dst.length);
      if (length > remaining())
          throw new BufferUnderflowException();
      System.arraycopy(hb, ix(position()), dst, offset, length);
      position(position() + length);
      return this;
    }

00151     public boolean isDirect() {
      return false;
    }



    public boolean isReadOnly() {
      return false;
    }

00161     public ByteBuffer put(byte x) {

      hb[ix(nextPutIndex())] = x;
      return this;



    }

00170     public ByteBuffer put(int i, byte x) {

      hb[ix(checkIndex(i))] = x;
      return this;



    }

00179     public ByteBuffer put(byte[] src, int offset, int length) {

      checkBounds(offset, length, src.length);
      if (length > remaining())
          throw new BufferOverflowException();
      System.arraycopy(src, offset, hb, ix(position()), length);
      position(position() + length);
      return this;



    }

00192     public ByteBuffer put(ByteBuffer src) {

      if (src instanceof HeapByteBuffer) {
          if (src == this)
            throw new IllegalArgumentException();
          HeapByteBuffer sb = (HeapByteBuffer)src;
          int n = sb.remaining();
          if (n > remaining())
            throw new BufferOverflowException();
          System.arraycopy(sb.hb, sb.ix(sb.position()),
                       hb, ix(position()), n);
          sb.position(sb.position() + n);
          position(position() + n);
      } else if (src.isDirect()) {
          int n = src.remaining();
          if (n > remaining())
            throw new BufferOverflowException();
          src.get(hb, ix(position()), n);
          position(position() + n);
      } else {
          super.put(src);
      }
      return this;



    }

00220     public ByteBuffer compact() {

      System.arraycopy(hb, ix(position()), hb, ix(0), remaining());
      position(remaining());
      limit(capacity());
      return this;



    }





    byte _get(int i) {                    // package-private
      return hb[i];
    }

    void _put(int i, byte b) {                  // package-private

      hb[i] = b;



    }

    // char



00251     public char getChar() {
      return Bits.getChar(this, ix(nextGetIndex(2)), bigEndian);
    }

00255     public char getChar(int i) {
      return Bits.getChar(this, ix(checkIndex(i, 2)), bigEndian);
    }



00261     public ByteBuffer putChar(char x) {

      Bits.putChar(this, ix(nextPutIndex(2)), x, bigEndian);
      return this;



    }

00270     public ByteBuffer putChar(int i, char x) {

      Bits.putChar(this, ix(checkIndex(i, 2)), x, bigEndian);
      return this;



    }

00279     public CharBuffer asCharBuffer() {
      int size = this.remaining() >> 1;
      int off = offset + position();
      return (bigEndian
            ? (CharBuffer)(new ByteBufferAsCharBufferB(this,
                                                 -1,
                                                 0,
                                                 size,
                                                 size,
                                                 off))
            : (CharBuffer)(new ByteBufferAsCharBufferL(this,
                                                 -1,
                                                 0,
                                                 size,
                                                 size,
                                                 off)));
    }


    // short



00302     public short getShort() {
      return Bits.getShort(this, ix(nextGetIndex(2)), bigEndian);
    }

00306     public short getShort(int i) {
      return Bits.getShort(this, ix(checkIndex(i, 2)), bigEndian);
    }



00312     public ByteBuffer putShort(short x) {

      Bits.putShort(this, ix(nextPutIndex(2)), x, bigEndian);
      return this;



    }

00321     public ByteBuffer putShort(int i, short x) {

      Bits.putShort(this, ix(checkIndex(i, 2)), x, bigEndian);
      return this;



    }

00330     public ShortBuffer asShortBuffer() {
      int size = this.remaining() >> 1;
      int off = offset + position();
      return (bigEndian
            ? (ShortBuffer)(new ByteBufferAsShortBufferB(this,
                                                 -1,
                                                 0,
                                                 size,
                                                 size,
                                                 off))
            : (ShortBuffer)(new ByteBufferAsShortBufferL(this,
                                                 -1,
                                                 0,
                                                 size,
                                                 size,
                                                 off)));
    }


    // int



00353     public int getInt() {
      return Bits.getInt(this, ix(nextGetIndex(4)), bigEndian);
    }

00357     public int getInt(int i) {
      return Bits.getInt(this, ix(checkIndex(i, 4)), bigEndian);
    }



00363     public ByteBuffer putInt(int x) {

      Bits.putInt(this, ix(nextPutIndex(4)), x, bigEndian);
      return this;



    }

00372     public ByteBuffer putInt(int i, int x) {

      Bits.putInt(this, ix(checkIndex(i, 4)), x, bigEndian);
      return this;



    }

00381     public IntBuffer asIntBuffer() {
      int size = this.remaining() >> 2;
      int off = offset + position();
      return (bigEndian
            ? (IntBuffer)(new ByteBufferAsIntBufferB(this,
                                               -1,
                                               0,
                                               size,
                                               size,
                                               off))
            : (IntBuffer)(new ByteBufferAsIntBufferL(this,
                                               -1,
                                               0,
                                               size,
                                               size,
                                               off)));
    }


    // long



00404     public long getLong() {
      return Bits.getLong(this, ix(nextGetIndex(8)), bigEndian);
    }

00408     public long getLong(int i) {
      return Bits.getLong(this, ix(checkIndex(i, 8)), bigEndian);
    }



00414     public ByteBuffer putLong(long x) {

      Bits.putLong(this, ix(nextPutIndex(8)), x, bigEndian);
      return this;



    }

00423     public ByteBuffer putLong(int i, long x) {

      Bits.putLong(this, ix(checkIndex(i, 8)), x, bigEndian);
      return this;



    }

00432     public LongBuffer asLongBuffer() {
      int size = this.remaining() >> 3;
      int off = offset + position();
      return (bigEndian
            ? (LongBuffer)(new ByteBufferAsLongBufferB(this,
                                                 -1,
                                                 0,
                                                 size,
                                                 size,
                                                 off))
            : (LongBuffer)(new ByteBufferAsLongBufferL(this,
                                                 -1,
                                                 0,
                                                 size,
                                                 size,
                                                 off)));
    }


    // float



00455     public float getFloat() {
      return Bits.getFloat(this, ix(nextGetIndex(4)), bigEndian);
    }

00459     public float getFloat(int i) {
      return Bits.getFloat(this, ix(checkIndex(i, 4)), bigEndian);
    }



00465     public ByteBuffer putFloat(float x) {

      Bits.putFloat(this, ix(nextPutIndex(4)), x, bigEndian);
      return this;



    }

00474     public ByteBuffer putFloat(int i, float x) {

      Bits.putFloat(this, ix(checkIndex(i, 4)), x, bigEndian);
      return this;



    }

00483     public FloatBuffer asFloatBuffer() {
      int size = this.remaining() >> 2;
      int off = offset + position();
      return (bigEndian
            ? (FloatBuffer)(new ByteBufferAsFloatBufferB(this,
                                                 -1,
                                                 0,
                                                 size,
                                                 size,
                                                 off))
            : (FloatBuffer)(new ByteBufferAsFloatBufferL(this,
                                                 -1,
                                                 0,
                                                 size,
                                                 size,
                                                 off)));
    }


    // double



00506     public double getDouble() {
      return Bits.getDouble(this, ix(nextGetIndex(8)), bigEndian);
    }

00510     public double getDouble(int i) {
      return Bits.getDouble(this, ix(checkIndex(i, 8)), bigEndian);
    }



00516     public ByteBuffer putDouble(double x) {

      Bits.putDouble(this, ix(nextPutIndex(8)), x, bigEndian);
      return this;



    }

00525     public ByteBuffer putDouble(int i, double x) {

      Bits.putDouble(this, ix(checkIndex(i, 8)), x, bigEndian);
      return this;



    }

00534     public DoubleBuffer asDoubleBuffer() {
      int size = this.remaining() >> 3;
      int off = offset + position();
      return (bigEndian
            ? (DoubleBuffer)(new ByteBufferAsDoubleBufferB(this,
                                                   -1,
                                                   0,
                                                   size,
                                                   size,
                                                   off))
            : (DoubleBuffer)(new ByteBufferAsDoubleBufferL(this,
                                                   -1,
                                                   0,
                                                   size,
                                                   size,
                                                   off)));
    }








































}

Generated by  Doxygen 1.6.0   Back to index