Creates a new single-byte big-endian buffer that holds the specified boolean value.
503295
public static ByteBuf copyBoolean(boolean value) {
        ByteBuf buf = buffer(1);
        buf.writeBoolean(value);
        return buf;
    }
194714
public static Object fromBytes(byte[] b, Class<?> clazz)
    {

        if (clazz.isAssignableFrom(String.class))
        {
            return Bytes.toString(b);
        }
        else if (clazz.equals(int.class) || clazz.isAssignableFrom(Integer.class))
        {
            return Bytes.toInt(b);
        }
        else if (clazz.equals(long.class) || clazz.isAssignableFrom(Long.class))
        {
            return Bytes.toLong(b);
        }
        else if (clazz.equals(boolean.class) || clazz.isAssignableFrom(Boolean.class))
        {
            return Bytes.toBoolean(b);
        }
        else if (clazz.equals(double.class) || clazz.isAssignableFrom(Double.class))
        {
            return Bytes.toDouble(b);
        }
        else if (clazz.equals(float.class) || clazz.isAssignableFrom(Float.class))
        {
            return Bytes.toFloat(b);
        }
        else if (clazz.equals(short.class) || clazz.isAssignableFrom(Short.class))
        {
            return Bytes.toShort(b);
        }
        else if (clazz.equals(BigDecimal.class))
        {
            return Bytes.toBigDecimal(b);
        }
        else
        {
            return PropertyAccessorFactory.getPropertyAccessor(clazz).fromBytes(clazz, b);
        }
    }
677500
@Override
    public Boolean fromBytes(Class targetClass, byte[] data)
    {
        return (data == null || data.length == 0) ? false : data[0] != 0x00;
    }
1167315
public static Buffer wrap(final int value) {
        final int size = value < 0 ? stringSize(-value) + 1 : stringSize(value);
        final byte[] bytes = new byte[size];
        getBytes(value, size, bytes);
        return new ByteBuffer(bytes);
    }
291091
public static byte[] create(byte[] value) {
    if (value == null) {
      return new byte[]{(byte) 251};
    }

    int length = value.length;
    if (length < 251) {

      byte[] buf = new byte[length + 1];
      buf[0] = (byte) length;
      System.arraycopy(value, 0, buf, 1, length);
      return buf;

    } else if (length < 65536) {

      byte[] buf = new byte[length + 3];
      buf[0] = (byte) 0xfc;
      buf[1] = (byte) length;
      buf[2] = (byte) (length >>> 8);
      System.arraycopy(value, 0, buf, 3, length);
      return buf;

    } else if (length < 16777216) {

      byte[] buf = new byte[length + 4];
      buf[0] = (byte) 0xfd;
      buf[1] = (byte) length;
      buf[2] = (byte) (length >>> 8);
      buf[3] = (byte) (length >>> 16);
      System.arraycopy(value, 0, buf, 4, length);
      return buf;

    } else {

      byte[] buf = new byte[length + 9];
      buf[0] = (byte) 0xfe;
      buf[1] = (byte) length;
      buf[2] = (byte) (length >>> 8);
      buf[3] = (byte) (length >>> 16);
      buf[4] = (byte) (length >>> 24);
      //byte[] cannot have a more than 4 byte length size, so buf[5] -> buf[8] = 0x00;
      System.arraycopy(value, 0, buf, 9, length);
      return buf;
    }

  }
874261
def _ParseBooleanValue(self, byte_stream):
    
    if byte_stream == b'\x00':
      return False

    if byte_stream == b'\x01':
      return True

    raise errors.ParseError('Unsupported boolean value.')
1134833
static void putLong(ByteBuffer buffer, long value) {
        value = (value << 1) ^ (value >> 63);
        if (value >>> 7 == 0) {
            buffer.put((byte) value);
        } else {
            buffer.put((byte) ((value & 0x7F) | 0x80));
            if (value >>> 14 == 0) {
                buffer.put((byte) (value >>> 7));
            } else {
                buffer.put((byte) (value >>> 7 | 0x80));
                if (value >>> 21 == 0) {
                    buffer.put((byte) (value >>> 14));
                } else {
                    buffer.put((byte) (value >>> 14 | 0x80));
                    if (value >>> 28 == 0) {
                        buffer.put((byte) (value >>> 21));
                    } else {
                        buffer.put((byte) (value >>> 21 | 0x80));
                        if (value >>> 35 == 0) {
                            buffer.put((byte) (value >>> 28));
                        } else {
                            buffer.put((byte) (value >>> 28 | 0x80));
                            if (value >>> 42 == 0) {
                                buffer.put((byte) (value >>> 35));
                            } else {
                                buffer.put((byte) (value >>> 35 | 0x80));
                                if (value >>> 49 == 0) {
                                    buffer.put((byte) (value >>> 42));
                                } else {
                                    buffer.put((byte) (value >>> 42 | 0x80));
                                    if (value >>> 56 == 0) {
                                        buffer.put((byte) (value >>> 49));
                                    } else {
                                        buffer.put((byte) (value >>> 49 | 0x80));
                                        buffer.put((byte) (value >>> 56));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
1181567
protected ByteBuffer toBytes(BigInteger value, int significantBytes) {
    byte[] rawBytes = value.toByteArray();
    byte[] result;
    if (rawBytes.length == significantBytes) {
      result = rawBytes;
    } else {
      result = new byte[significantBytes];
      int start, length;
      if (rawBytes[0] == 0) {
        // that's a sign byte, ignore (it can cause rawBytes.length == significantBytes + 1)
        start = 1;
        length = rawBytes.length - 1;
      } else {
        start = 0;
        length = rawBytes.length;
      }
      System.arraycopy(rawBytes, start, result, significantBytes - length, length);
    }
    return ByteBuffer.wrap(result);
  }
1367990
@SuppressWarnings("deprecation")
    public static ByteBuf writeShortBE(ByteBuf buf, int shortValue) {
        return buf.order() == ByteOrder.BIG_ENDIAN? buf.writeShort(shortValue) : buf.writeShortLE(shortValue);
    }
1113028
private BigInteger toBigInteger(Object value) {
		if (value instanceof Long) {
			return BigInteger.valueOf((Long) value);
		} else if(value instanceof Boolean) {
			return BigInteger.valueOf((boolean)value ? 1 : 0);
		}
		final String valueStr = convertToStr(value);
		if (StrUtil.isBlank(valueStr)) {
			return null;
		}
		return new BigInteger(valueStr);
	}
1017720
public static ByteBuf copyDouble(double value) {
        ByteBuf buf = buffer(8);
        buf.writeDouble(value);
        return buf;
    }
637321
public static byte[] getBytesLittleEndian(long value) {
		byte[] b = new byte[8];
		b[0] = (byte)(value & 0xFF);
		b[1] = (byte)((value >> 8) & 0xFF);
		b[2] = (byte)((value >> 16) & 0xFF);
		b[3] = (byte)((value >> 24) & 0xFF);
		b[4] = (byte)((value >> 32) & 0xFF);
		b[5] = (byte)((value >> 40) & 0xFF);
		b[6] = (byte)((value >> 48) & 0xFF);
		b[7] = (byte)((value >> 56) & 0xFF);
		return b;
	}
607803
public static SaneWord fromBytes(byte[] byteValue, int offset) {
    Preconditions.checkArgument(offset >= 0, "offset must be positive or zero");
    Preconditions.checkArgument(offset + SIZE_IN_BYTES <= byteValue.length);
    return new SaneWord(Arrays.copyOfRange(byteValue, offset, offset + SIZE_IN_BYTES));
  }
968475
function ByteBuffer(arg) {
    var initial_size;
    if (arg == null) {
        initial_size = 1024 * 1024;
    } else if (typeof arg === "number") {
        initial_size = arg;
    } else if (arg instanceof Uint8Array) {
        this.buffer = arg;
        this.position = 0;  // Overwrite
        return;
    } else {
        // typeof arg -> String
        throw typeof arg + " is invalid parameter type for ByteBuffer constructor";
    }
    // arg is null or number
    this.buffer = new Uint8Array(initial_size);
    this.position = 0;
}
1284701
public static DynamicByteBuffer create(byte[] buffer ) {
        DynamicByteBuffer buf = new DynamicByteBuffer( buffer.length );
        buf.buffer = buffer;
        return buf;
    }
698589
public static BigDecimal deserializeBigDecimal(ByteBuffer buffer) {
        byte decimalBytes[] = new byte[16];
        buffer.get(decimalBytes);
        if (java.util.Arrays.equals(decimalBytes, NULL_INDICATOR)) {
            return null;
        }
        final BigDecimal bd = new BigDecimal(
                new BigInteger(decimalBytes),
                        kDefaultScale, context);
        if (bd.precision() > 38) {
            throw new RuntimeException("Decimal " + bd + " has more than 38 digits of precision.");
        }
        return bd;
    }
1092495
function writeDoubleLEW(buffer, value, offset, isBigEndian, noAssert) {
  if (!noAssert) {
    assert.ok(value !== undefined && value !== null,
        'missing value');

    assert.ok(typeof (isBigEndian) === 'boolean',
        'missing or invalid endian');

    assert.ok(offset !== undefined && offset !== null,
        'missing offset');

    assert.ok(offset + 7 < buffer.length,
        'Trying to write beyond buffer length');

    verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308);
  }

  writeIEEE754LEW(buffer, value, offset, 52, 8);
}