IntViewBufferImpl(ByteBuffer bb, int capacity) {
   super(capacity, capacity, 0, -1);
   this.bb = bb;
   this.offset = bb.position();
   this.readOnly = bb.isReadOnly();
   this.endian = bb.order();
   if (bb.isDirect()) this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
 }
 public IntViewBufferImpl(
     ByteBuffer bb,
     int offset,
     int capacity,
     int limit,
     int position,
     int mark,
     boolean readOnly,
     ByteOrder endian) {
   super(capacity, limit, position, mark);
   this.bb = bb;
   this.offset = offset;
   this.readOnly = readOnly;
   this.endian = endian;
   if (bb.isDirect()) this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
 }
  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;
  }
示例#4
0
 public boolean isDirect() {
   return bb.isDirect();
 }