/** * Returns the {@code short} value whose big-endian representation is stored in the first 2 bytes * of {@code bytes}; equivalent to {@code ByteBuffer.wrap(bytes).getShort()}. For example, the * input byte array {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that library exposes much more * flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 elements */ @GwtIncompatible // doesn't work public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is stored in the first 2 bytes * of {@code bytes}; equivalent to {@code ByteBuffer.wrap(bytes).getShort()}. For example, the * input byte array {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that library exposes much more * flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 elements */ @GwtIncompatible // doesn't work public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is stored in the first 2 bytes * of {@code bytes}; equivalent to {@code ByteBuffer.wrap(bytes).getShort()}. For example, the * input byte array {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that library exposes much more * flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 elements */ @GwtIncompatible // doesn't work public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Takes two bytes and concatenates the two into a short value * @param byte1 - the first byte * @param byte2 - the training byte * @return - the short value */ public static short bytesToShort(final byte byte1, final byte byte2) { return Shorts.fromBytes(byte1, byte2); }
private static short getShort(byte[] data, int offset) { return Shorts.fromBytes(data[offset++], data[offset]); }
/** * Returns the {@code short} value whose big-endian representation is stored in the first 2 bytes * of {@code bytes}; equivalent to {@code ByteBuffer.wrap(bytes).getShort()}. For example, the * input byte array {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that library exposes much more * flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 elements */ @GwtIncompatible // doesn't work public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is stored in the first 2 bytes * of {@code bytes}; equivalent to {@code ByteBuffer.wrap(bytes).getShort()}. For example, the * input byte array {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that library exposes much more * flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 elements */ @GwtIncompatible // doesn't work public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is * stored in the first 2 bytes of {@code bytes}; equivalent to {@code * ByteBuffer.wrap(bytes).getShort()}. For example, the input byte array * {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that * library exposes much more flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 * elements */ @GwtIncompatible("doesn't work") public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is * stored in the first 2 bytes of {@code bytes}; equivalent to {@code * ByteBuffer.wrap(bytes).getShort()}. For example, the input byte array * {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that * library exposes much more flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 * elements */ @GwtIncompatible("doesn't work") public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is * stored in the first 2 bytes of {@code bytes}; equivalent to {@code * ByteBuffer.wrap(bytes).getShort()}. For example, the input byte array * {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that * library exposes much more flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 * elements */ @GwtIncompatible("doesn't work") public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is * stored in the first 2 bytes of {@code bytes}; equivalent to {@code * ByteBuffer.wrap(bytes).getShort()}. For example, the input byte array * {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that * library exposes much more flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 * elements */ @GwtIncompatible("doesn't work") public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is * stored in the first 2 bytes of {@code bytes}; equivalent to {@code * ByteBuffer.wrap(bytes).getShort()}. For example, the input byte array * {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that * library exposes much more flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 * elements */ @GwtIncompatible("doesn't work") public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is * stored in the first 2 bytes of {@code bytes}; equivalent to {@code * ByteBuffer.wrap(bytes).getShort()}. For example, the input byte array * {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that * library exposes much more flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 * elements */ @GwtIncompatible("doesn't work") public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is * stored in the first 2 bytes of {@code bytes}; equivalent to {@code * ByteBuffer.wrap(bytes).getShort()}. For example, the input byte array * {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that * library exposes much more flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 * elements */ @GwtIncompatible("doesn't work") public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is * stored in the first 2 bytes of {@code bytes}; equivalent to {@code * ByteBuffer.wrap(bytes).getShort()}. For example, the input byte array * {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that * library exposes much more flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 * elements */ @GwtIncompatible("doesn't work") public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is * stored in the first 2 bytes of {@code bytes}; equivalent to {@code * ByteBuffer.wrap(bytes).getShort()}. For example, the input byte array * {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that * library exposes much more flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 * elements */ @GwtIncompatible("doesn't work") public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }
/** * Returns the {@code short} value whose big-endian representation is * stored in the first 2 bytes of {@code bytes}; equivalent to {@code * ByteBuffer.wrap(bytes).getShort()}. For example, the input byte array * {@code {0x54, 0x32}} would yield the {@code short} value {@code 0x5432}. * * <p>Arguably, it's preferable to use {@link java.nio.ByteBuffer}; that * library exposes much more flexibility at little cost in readability. * * @throws IllegalArgumentException if {@code bytes} has fewer than 2 * elements */ @GwtIncompatible("doesn't work") public static short fromByteArray(byte[] bytes) { checkArgument(bytes.length >= BYTES, "array too small: %s < %s", bytes.length, BYTES); return fromBytes(bytes[0], bytes[1]); }