Wrap a range of an existing buffer containing an ASCII sequence.

@param buffer containing the ASCII sequence.
@param offset at which the ASCII sequence begins.
@param length of the ASCII sequence in bytes.
@return this for a fluent API.
513434
public AsciiSequenceView wrap(final DirectBuffer buffer, final int offset, final int length)
    {
        this.buffer = buffer;
        this.offset = offset;
        this.length = length;

        return this;
    }
651593
public int read(byte []buf, int offset, int length) throws IOException
  {
    int strlen = _length;

    int start = offset;
    int end = offset + length;
    
    int index = _index;
    for (; index < strlen && offset < end; index++) {
      int ch = _string.charAt(index);

      if (ch < 0x80)
        buf[offset++] = (byte) ch;
      else if (ch < 0x800 && offset + 1 < end) {
        buf[offset++] = (byte) (0xc0 | (ch >> 6));
        buf[offset++] = (byte) (0x80 | (ch & 0x3f));
      }
      else if (ch < 0x8000 && offset + 2 < end) {
        buf[offset++] = (byte) (0xe0 | (ch >> 12));
        buf[offset++] = (byte) (0x80 | ((ch >> 6) & 0x3f));
        buf[offset++] = (byte) (0x80 | ((ch >> 6) & 0x3f));
      }
      else if (offset == start) {
        throw new IllegalStateException("buffer length is not large enough to decode UTF-8 data");
      }
      else {
        break;
      }
    }

    _index = index;

    return start < offset ? offset - start : -1;
  }
189641
public Sequence createSequenceofLength(int length,char base)
	{
		Sequence sequence=new Sequence();
		byte[] sequenceByte=new byte[length];
		for(int i=0;i<length;i++)
		{
			sequenceByte[i]=(byte)base;
	    }
		
		sequence.setSequence(ByteBuffer.wrap(sequenceByte));
	    return sequence;
	}
566661
public int read(byte []buffer, int offset, int length)
    throws IOException
  {
    return _file.read(buffer, offset, length);
  }
654177
public static ByteBuf copiedBuffer(byte[] array, int offset, int length) {
        if (length == 0) {
            return EMPTY_BUFFER;
        }
        byte[] copy = PlatformDependent.allocateUninitializedArray(length);
        System.arraycopy(array, offset, copy, 0, length);
        return wrappedBuffer(copy);
    }
1203739
public StringsWithLengthBlock read(byte[] buffer, int offset, boolean inclusive)
   {
      int numberOfItems = FastTrackUtility.getInt(buffer, offset);
      offset += 4;

      FastTrackUtility.validateSize(numberOfItems);

      if (inclusive)
      {
         ++numberOfItems;
      }

      m_data = new String[numberOfItems];
      for (int index = 0; index < m_data.length; index++)
      {
         // Two bytes
         offset += 2;
         int itemNameLength = FastTrackUtility.getInt(buffer, offset);
         offset += 4;
         m_data[index] = new String(buffer, offset, itemNameLength, CharsetHelper.UTF16LE);
         offset += itemNameLength;
      }

      m_offset = offset;

      return this;
   }
488889
function( buffer, offset ) {

    if( !Buffer.isBuffer( buffer ) )
      throw new TypeError( 'Value must be a buffer' )

    offset = offset || 0

    return this.fromNumber( buffer.readUIntLE( offset, 3 ) )

  }
134780
private int ensureBuffer(int offset, int length) throws IOException {
		final int lastPos = offset + length - 1;
		final int desiredSize = ((lastPos / BUFFER_SIZE) + 1) * BUFFER_SIZE;
		final int currentSize = this.buffer.length;

		if (desiredSize > currentSize) {
			final byte[] readBuffer = new byte[desiredSize - currentSize];
			final int count = this.in.read(readBuffer);

			if (count > 0) {
				final byte[] newBuffer = new byte[currentSize + count];
				System.arraycopy(this.buffer, 0, newBuffer, 0, currentSize);
				System.arraycopy(readBuffer, 0, newBuffer, currentSize, count);
				this.buffer = newBuffer;
			}
			return (lastPos < this.buffer.length) ? length : length - (lastPos - this.buffer.length + 1);
		}
		return length;
	}
1037600
public static Buffer wrapAndClone(final byte[] buffer) {
        if (buffer == null || buffer.length == 0) {
            throw new IllegalArgumentException("the buffer cannot be null or empty");
        }

        final byte[] b = new byte[buffer.length];
        System.arraycopy(buffer, 0, b, 0, buffer.length);
        return new ByteBuffer(b);
    }
896637
public static void dumpHex(StringBuilder s, byte[] buffer, int offset, int length) {
		dumpHex(s, ByteBuffer.wrap(buffer, offset, length));
	}
596191
function BufferSegment(buf, offset, count) {
  if (!Buffer.isBuffer(buf)) throw new TypeError('buf must be a buffer');

  this.buffer = buf;
  this.offset = offset || 0;
  this.count = count || buf.length;
}
515978
public synchronized int read(byte[] buf, int offset, int length) 
        throws IOException
    {

        if (!waitForContent())
            return -1;
            
         if (length>_buffer.remaining())
            length=_buffer.remaining();
            
         _buffer.get(buf, offset, length);
        return length;
    }
625148
private void newBuffer(int offset) {
    if (maxBufferSize >= 0) {
      buffer = new int[maxBufferSize];
      isByte = new boolean[maxBufferSize];
      bufferOffset = offset;
      currentBufferSize = 0;
    }
  }
1055375
function (offset, length) {

                if (arguments.length === 1) {
                    length = arguments[0];
                    offset = this.offset;
                }

                if (length < 0 || offset + length > this.length) {
                    error.raise(10001, this.length, offset + length);
                }

                var value = '';
                for (var i = 0; i < length; ++i) {
                    var c = this.readUint8(offset + i);
                    value += String.fromCharCode(c);
                }

                this.offset = offset + length;

                return value;
            }
430126
public int read(byte []buffer, int offset, int length)
    throws IOException
  {
    return _stream.read(buffer, offset, length);
  }
971311
public void writeBytes(byte[] buffer, int offset, int length)
        throws IOException
    {
        if (buffer == null) {
            os.write('N');
        }
        else {
            os.write('B');
            os.write(length << 8);
            os.write(length);
            os.write(buffer, offset, length);
        }
    }
799576
public int addBytes(byte[] buf, int offset, int length)
    {
        if (length>unconsumedCapacity())
            length=unconsumedCapacity();
        System.arraycopy(buf,offset,_buf,_bytes,length);
        _bytes+=length;
        return length;
    }