/** * Returns a long value from the byte array. * <p>Only {@link #FORMAT_UINT32} and {@link #FORMAT_SINT32} are supported. * <p>The formatType parameter determines how the value * is to be interpreted. For example, setting formatType to * {@link #FORMAT_UINT32} specifies that the first four bytes of the * value at the given offset are interpreted to generate the * return value. * * @param formatType The format type used to interpret the value. * @param offset Offset at which the integer value can be found. * @return Cached value or null of offset exceeds value size. */ @Nullable public Long getLongValue(@LongFormat final int formatType, @IntRange(from = 0) final int offset) { if ((offset + getTypeLen(formatType)) > size()) return null; switch (formatType) { case FORMAT_SINT32: return unsignedToSigned(unsignedBytesToLong(mValue[offset], mValue[offset + 1], mValue[offset + 2], mValue[offset + 3]), 32); case FORMAT_UINT32: return unsignedBytesToLong(mValue[offset], mValue[offset + 1], mValue[offset + 2], mValue[offset + 3]); } return null; }