public class OptionUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static byte[] |
EMPTY_BYTES
Empty byte array.
|
static String |
EMPTY_STRING
Empty byte array.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isCritical(int optionNumber)
Checks if option with this number is critical.
|
static boolean |
isNoCacheKey(int optionNumber)
Checks if option with this number is a NoCacheKey.
|
static boolean |
isUnsafe(int optionNumber)
Checks if option with this number is unsafe.
|
static byte[] |
toBytes(int value)
Convert an integer value to byte array.
|
static byte[] |
toBytes(int value,
int minLength,
int maxLength)
Convert an integer value to byte array.
|
static byte[] |
toBytes(long value)
Convert a long value to byte array.
|
static byte[] |
toBytes(long value,
int minLength,
int maxLength)
Convert a long value to byte array.
|
static byte[] |
toBytes(String string)
Converts a string representation of an option to byte array.
|
static byte[] |
toBytes(String string,
int minLength,
int maxLength)
Converts a string representation of an option to byte array.
|
static byte[] |
toBytesFromHex(String hexString)
Converts a hexadecimal representation of an option to byte array.
|
static byte[] |
toBytesFromHex(String hexString,
int minLength,
int maxLength)
Converts a hexadecimal representation of an option to byte array.
|
static String |
toHexString(byte[] bytes)
Converts an etag value to a String containing the hexadecimal representation.
|
static InputStream |
toInputStream(byte[] bytes)
Warps bytes into an InputStream.
|
static long |
toLong(byte[] bytes)
Converts bytes to long.
|
static String |
toString(byte[] bytes)
Converts an option value interpreted as UTF-8 string.
|
public static final byte[] EMPTY_BYTES
public static final String EMPTY_STRING
public static boolean isCritical(int optionNumber)
true if is option criticalpublic static boolean isNoCacheKey(int optionNumber)
true if is NoCacheKeypublic static boolean isUnsafe(int optionNumber)
true if is unsafepublic static byte[] toBytes(int value)
value - The integer value to convert.public static byte[] toBytes(int value,
int minLength,
int maxLength)
throws OptionValueException
value - The integer value to convert.minLength - The minimum allowed length of the resulting byte array.maxLength - The maximum allowed length of the resulting byte array.OptionValueException - When value cannot be converted to bytes.public static byte[] toBytes(long value)
value - The long value to convert.public static byte[] toBytes(long value,
int minLength,
int maxLength)
throws OptionValueException
value - The long value to convert.minLength - The minimum allowed length of the resulting byte array.maxLength - The maximum allowed length of the resulting byte array.OptionValueException - When value cannot be converted to bytes.public static byte[] toBytes(String string) throws OptionValueException
string - The string representing the bytes value.OptionValueException - When String does not contain a convertible hexadecimal value or is exceeding maximum length.public static byte[] toBytes(String string, int minLength, int maxLength) throws OptionValueException
string - The string representing the bytes value.minLength - The minimum allowed length of the resulting byte array.maxLength - The maximum allowed length of the resulting byte array.OptionValueException - When String does not contain a convertible hexadecimal value or is exceeding maximum length.public static byte[] toBytesFromHex(String hexString) throws OptionValueException
hexString - The string representing the bytes value.OptionValueException - When String does not contain a convertible hexadecimal value or is exceeding maximum length.public static byte[] toBytesFromHex(String hexString, int minLength, int maxLength) throws OptionValueException
hexString - The string representing the bytes value.minLength - The minimum allowed length of the resulting byte array.maxLength - The maximum allowed length of the resulting byte array.OptionValueException - When String does not contain a convertible hexadecimal value or is exceeding maximum length.public static String toHexString(byte[] bytes)
bytes - The option value.public static InputStream toInputStream(byte[] bytes)
bytes - The bytes to expose as inputstream.public static long toLong(byte[] bytes)
bytes - The etag value.public static String toString(byte[] bytes)
bytes - The option value.Copyright © 2019–2025 Teslanet.nl. All rights reserved.