java.lang.Object
org.apache.jena.atlas.lib.Bytes
Byte-oriented operations. Packing and unpacking integers
is in network order (Big endian - which is the preferred order in Java).
See wikipedia Endianness.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StringasHex(byte b) Return a hex string representing the byte.static StringasHex(byte[] bytes) Return a hex string representing the bytes, zero padded to length of byte array.static StringasHex(byte[] bytes, int start, int finish, char[] hexDigits) static StringasHexLC(byte b) static StringasHexLC(byte[] bytes) static StringasHexUC(byte b) static StringasHexUC(byte[] bytes) static byte[]String to UTF8 bytesstatic Stringbytes2string(byte[] x) Return the string for some UTF-8 bytesstatic intcompare(byte[] x1, byte[] x2) Compare two byte arrays which may be of different lengthsstatic intcompareByte(byte b1, byte b2) static byte[]copyOf(byte[] bytes) static byte[]copyOf(byte[] bytes, int start) static byte[]copyOf(byte[] bytes, int start, int length) static StringDecode a string into a ByteBufferstatic StringfromByteBuffer(ByteBuffer bb, CharsetDecoder dec) Decode a string into a ByteBufferstatic StringfromUTF8bytes(byte[] bytes) String from UTF8 bytesstatic final intgetInt(byte[] b) Get an int from a byte array (network order)static final intgetInt(byte[] b, int idx) Get an int from a byte array (network order)static final longgetLong(byte[] b) Get a long from a byte array (network order)static final longgetLong(byte[] b, int idx) Get a long from a byte array (network order)static inthexCharToInt(char c) static byte[]intToBytes(int v) Put an int value into an allocated byte array.static byte[]longToBytes(long v) Put a long value into an allocated byte array.static byte[]packInt(int val) int to byte arraystatic byte[]packLong(long val) long to byte arraystatic final voidsetInt(int value, byte[] b) Put an int into a byte arraystatic final voidsetInt(int x, byte[] b, int idx) Put an int into a byte array from a given positionstatic final voidsetLong(long value, byte[] b) Put a long into a byte arraystatic final voidsetLong(long value, byte[] b, int idx) Put a long into a byte array from a given positionstatic byte[]Return the UTF-8 bytes for a stringstatic inttoByteBuffer(CharSequence s, ByteBuffer bb) Encode a string into a ByteBuffer : on return position is the end of the encodingstatic inttoByteBuffer(CharSequence s, ByteBuffer bb, CharsetEncoder enc) Encode a string into a ByteBuffer : on return position is the end of the encoding
-
Field Details
-
hexDigitsUC
public static final byte[] hexDigitsUC -
hexDigitsLC
public static final byte[] hexDigitsLC
-
-
Method Details
-
asUTF8bytes
String to UTF8 bytes -
fromUTF8bytes
String from UTF8 bytes -
compare
public static int compare(byte[] x1, byte[] x2) Compare two byte arrays which may be of different lengths -
compareByte
public static int compareByte(byte b1, byte b2) -
copyOf
public static byte[] copyOf(byte[] bytes) -
copyOf
public static byte[] copyOf(byte[] bytes, int start) -
copyOf
public static byte[] copyOf(byte[] bytes, int start, int length) -
intToBytes
public static byte[] intToBytes(int v) Put an int value into an allocated byte array.- Parameters:
v-- Returns:
- byte[] array
- See Also:
-
longToBytes
public static byte[] longToBytes(long v) Put a long value into an allocated byte array.- Parameters:
v-- Returns:
- byte[] array
- See Also:
-
getInt
public static final int getInt(byte[] b) Get an int from a byte array (network order)- Parameters:
b- Byte Array
-
getInt
public static final int getInt(byte[] b, int idx) Get an int from a byte array (network order)- Parameters:
b- Byte Arrayidx- Starting point of bytes
-
getLong
public static final long getLong(byte[] b) Get a long from a byte array (network order)- Parameters:
b- Byte Array
-
getLong
public static final long getLong(byte[] b, int idx) Get a long from a byte array (network order)- Parameters:
b- Byte Arrayidx- Starting point of bytes
-
setInt
public static final void setInt(int value, byte[] b) Put an int into a byte array- Parameters:
value- The integerb- byte array
-
setInt
public static final void setInt(int x, byte[] b, int idx) Put an int into a byte array from a given position- Parameters:
x- The integerb- byte arrayidx- starting point
-
setLong
public static final void setLong(long value, byte[] b) Put a long into a byte array- Parameters:
value- The integerb- byte array
-
setLong
public static final void setLong(long value, byte[] b, int idx) Put a long into a byte array from a given position- Parameters:
value- The integerb- byte arrayidx- starting point
-
packInt
public static byte[] packInt(int val) int to byte array -
packLong
public static byte[] packLong(long val) long to byte array -
string2bytes
Return the UTF-8 bytes for a string -
bytes2string
Return the string for some UTF-8 bytes -
toByteBuffer
Encode a string into a ByteBuffer : on return position is the end of the encoding -
toByteBuffer
Encode a string into a ByteBuffer : on return position is the end of the encoding -
fromByteBuffer
Decode a string into a ByteBuffer -
fromByteBuffer
Decode a string into a ByteBuffer -
asHex
Return a hex string representing the bytes, zero padded to length of byte array. -
asHexUC
-
asHexLC
-
asHex
-
asHex
Return a hex string representing the byte. -
asHexUC
-
asHexLC
-
hexCharToInt
public static int hexCharToInt(char c)
-