Exemplo n.º 1
0
 public override ByteBuffer Put(ByteBuffer src)
 {
     if (src is HeapByteBuffer)
     {
         if (src == this)
         {
             throw new IllegalArgumentException();
         }
         HeapByteBuffer sb = (HeapByteBuffer)src;
         int            n  = sb.Remaining();
         if (n > Remaining())
         {
             throw new BufferOverflowException();
         }
         System.Array.Copy(sb.Hb, sb.Ix(sb.Position()), Hb, Ix(Position()), n);
         sb.Position(sb.Position() + n);
         Position(Position() + n);
     }
     else if (src.Direct)
     {
         int n = src.Remaining();
         if (n > Remaining())
         {
             throw new BufferOverflowException();
         }
         src.Get(Hb, Ix(Position()), n);
         Position(Position() + n);
     }
     else
     {
         base.Put(src);
     }
     return(this);
 }
 internal static ReadOnlyHeapByteBuffer Copy(HeapByteBuffer other, int markOfOther)
 {
     return(new ReadOnlyHeapByteBuffer(other.backingArray, other.Capacity, other.offset)
     {
         limit = other.Limit,
         position = other.Position,
         mark = markOfOther,
         Order = other.Order
     });
 }
Exemplo n.º 3
0
        internal static ReadOnlyHeapByteBuffer Copy(HeapByteBuffer other, int markOfOther)
        {
            ReadOnlyHeapByteBuffer buf = new ReadOnlyHeapByteBuffer(
                other.backingArray, other.Capacity, other.offset);

            buf.limit    = other.Limit;
            buf.position = other.Position;
            buf.mark     = markOfOther;
            buf.SetOrder(other.Order);
            return(buf);
        }
Exemplo n.º 4
0
 static ReadWriteHeapByteBuffer copy(HeapByteBuffer other, int markOfOther)
 {
     ReadWriteHeapByteBuffer buf = new ReadWriteHeapByteBuffer(
             other.backingArray, other.capacity(), other.offset);
     buf.limitJ = other.limit();
     buf.positionJ = other.position();
     buf.markJ = markOfOther;
     buf.order(other.order());
     return buf;
 }