Get the shape from
the given int buffer
@param buffer the buffer to get the shape information for
@return
163356
public static IntBuffer shapeOf(IntBuffer buffer) {
        Buffer buffer2 = (Buffer) buffer;
        IntBuffer ret = (IntBuffer) buffer2.position(1);
        return ret.slice();
    }
628925
public ByteBuffer getAttributeBuffer(int index) {
        final VertexAttribute attribute = getAttribute(index);
        if (attribute == null) {
            return null;
        }
        return attribute.getData();
    }
1318031
public static long getCRC(byte[] buffer) {
        CRC32 crc = new CRC32();
        crc.update(buffer);
        return crc.getValue();
    }
1044396
@Override
  public Object get(final ByteBuffer buf, final int position)
  {
    final WritableMemory mem = WritableMemory.wrap(buf, ByteOrder.LITTLE_ENDIAN).writableRegion(position, size);
    final Lock lock = stripedLock.getAt(HllSketchBuildBufferAggregator.lockIndex(position)).readLock();
    lock.lock();
    try {
      final Union union = Union.writableWrap(mem);
      return union.getResult(tgtHllType);
    }
    finally {
      lock.unlock();
    }
  }
491709
public static byte[] array(final ByteBuffer buffer)
    {
        if (buffer.isDirect())
        {
            throw new IllegalArgumentException("buffer must wrap an array");
        }

        return (byte[])UNSAFE.getObject(buffer, BYTE_BUFFER_HB_FIELD_OFFSET);
    }
359575
public FloatBuffer get(int index, FloatBuffer buffer) {
        MemUtil.INSTANCE.putf(this, index, buffer);
        return buffer;
    }
454669
public IntBuffer get(int index, IntBuffer buffer) {
        MemUtil.INSTANCE.put(this, index, buffer);
        return buffer;
    }
179206
@Override
	public void getImageBytes(ByteBuffer buffer) {
		final BufferedImage bi = getImage();
		if (bi != null) {
			buffer.put(ImageUtils.imageToBytes(bi));
		}
	}
124297
@Override
    public byte[] readBuffer(final ChannelBuffer buffer) {
        int len = getLength();
        byte[] matched = new byte[len];
        buffer.readBytes(matched);
        return matched;
    }
134819
public static char[] bytesToCharArrayUTFNIO(byte[] buffer) {
        ByteBuffer byteBuffer = ByteBuffer.wrap(buffer);
        CharBuffer charBuffer = Charset.forName(ENCODING).decode(byteBuffer);
        try {
            return charBufferToChars(charBuffer);
        } finally {
            eraseCharBuffer(charBuffer);
        }
    }
596203
public int read(final byte[] buffer) throws IOException {
    // Note that GWT will throw a JavascriptException rather than a NullPointerException if we
    // skip this check and the buffer array is null. This way we ensure that this implementation
    // behaves in the same way as the classes that are emulated.
    if (buffer == null) {
      throw new NullPointerException();
    }
    return this.read(buffer, 0, buffer.length);
  }
1213378
public static String bufferToString(IntBuffer buffer) {
        StringBuilder builder = new StringBuilder();
        int rank = buffer.get(0);
        builder.append("[ ").append(rank).append(", ");
        for (int p = 1; p < rank * 2 + 4; p++) {
            builder.append(buffer.get(p));
            if (p < rank * 2 + 4 - 1)
                builder.append(", ");
        }
        builder.append("]");
        return builder.toString();
    }
92788
public static LinkedBuffer use(byte[] buffer, int start)
    {
        assert start >= 0;
        if (buffer.length - start < MIN_BUFFER_SIZE)
            throw new IllegalArgumentException(MIN_BUFFER_SIZE + " is the minimum buffer size.");

        return new LinkedBuffer(buffer, start, start);
    }
1204310
private int getStartingPoint(String buffer) {
    for (int i = 0; i < buffer.length(); i++) {
      if (!Character.isWhitespace(buffer.charAt(i))) {
        return i;
      }
    }
    return buffer.length();
  }
1180694
public static byte[] toArray(ByteBuffer buffer) {
        if (buffer.hasArray()) {
            byte[] array = buffer.array();
            int from = buffer.arrayOffset() + buffer.position();
            return Arrays.copyOfRange(array, from, from + buffer.remaining());
        } else {
            byte[] to = new byte[buffer.remaining()];
            buffer.slice().get(to);
            return to;
        }
    }
139795
public static byte[] fromHexByteArray(final byte[] buffer)
    {
        final byte[] outputBuffer = new byte[buffer.length >> 1];

        for (int i = 0; i < buffer.length; i += 2)
        {
            final int hi = FROM_HEX_DIGIT_TABLE[buffer[i]] << 4;
            final int lo = FROM_HEX_DIGIT_TABLE[buffer[i + 1]]; // lgtm [java/index-out-of-bounds]
            outputBuffer[i >> 1] = (byte)(hi | lo);
        }

        return outputBuffer;
    }
441311
public static String shapeToString(IntBuffer buffer) {
        val shapeBuff = shapeOf(buffer);
        int rank = Shape.rank(buffer);
        val strideBuff = stride(buffer);
        StringBuilder sb = new StringBuilder();
        sb.append("Rank: " + rank + ",");
        sb.append("Offset: " + Shape.offset(buffer) + "\n");
        sb.append(" Order: " + Shape.order(buffer));
        sb.append(" Shape: [");
        for (int i = 0; i < rank; i++) {
            sb.append(shapeBuff.get(i));
            if (i < rank - 1)
                sb.append(",");
        }
        sb.append("], ");

        sb.append(" stride: [");
        for (int i = 0; i < rank; i++) {
            sb.append(strideBuff.get(i));
            if (i < rank - 1)
                sb.append(",");
        }
        sb.append("]");
        return sb.toString();
    }