Class Strings
- Author:
- Apache Directory Project
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic intareEquals(byte[] bytes, int index, byte[] bytes2) Check if a text is present at the current position in a buffer.static intCheck if a text is present at the current position in a buffer.static intareEquals(char[] chars, int index, char[] chars2) Check if a text is present at the current position in a buffer.static intareEquals(char[] chars, int index, char[] chars2, boolean caseSensitive) Check if a text is present at the current position in a buffer.static intCheck if a text is present at the current position in a buffer.static intCheck if a text is present at the current position in a buffer.static booleanCheck if a text is present at the current position in another string.static StringasciiBytesToString(byte[] bytes) Transform an array of ASCII bytes to a string. the byte array should contains only values in [0, 127].static bytebyteAt(byte[] bytes, int index) Get the byte at a given position in a byte array, checking for limitsstatic StringbyteToString(byte b) Helper function that dump a byte as a double digit valuestatic StringcenterTrunc(String str, int head, int tail) Truncates large Strings showing a portion of the String's head and tail with the center cut out and replaced with '...'.static charcharAt(char[] chars, int index) Get the char at a given position in a byte array, checking for limitsstatic charGet the character at a given position in a string, checking for limitsstatic intcompare(byte[] b1, byte[] b2) Compate two byte arrraysstatic byte[]copy(byte[] value) Copy a byte array into a new byte arraystatic StringA deep trim of a string remove whitespace from the ends as well as excessive whitespace within the inside of the string between non-whitespace characters.static StringPut common code to deepTrim(String) and deepTrimToLower here.static StringdeepTrimToLower(String string) This does the same thing as a trim but we also lowercase the string while performing the deep trim within the same buffer.static StringdumpByte(byte octet) Helper function that dump a byte in hex formstatic StringdumpBytes(byte[] buffer) Helper function that dump an array of bytes in hex formstatic chardumpHex(byte hex) Helper function that returns a char from an hexstatic StringdumpHexPairs(byte[] buffer) Helper function that dump an array of bytes in hex pair form, without '0x' and space charsstatic booleanCompares two Strings, returningtrueif they are equal.static StringformatHtml(String source, boolean replaceNl, boolean replaceTag, boolean replaceQuote) This method is used to insert HTML block dynamicallystatic byte[]getBytesUtf8(String string) Return UTF-8 encoded byte[] representation of a Stringstatic byte[]getBytesUtf8Ascii(String string) When the string to convert to bytes is pure ascii, this is a faster method than the getBytesUtf8.static StringGet the default charsetstatic StringFrom commons-httpclients.static StringFrom commons-httpclients.static StringFrom commons-httpclients.static StringFrom commons-httpclients.static StringgetUUID(long value) Create a new UUID using a long as the least significant bitsstatic booleanisCharASCII(byte[] byteArray, int index, char car) Test if the current character is equal to a specific character.static booleanisCharASCII(char[] charArray, int index, char car) Test if the current character is equal to a specific character.static booleanisCharASCII(String string, int index, char car) Test if the current character is equal to a specific character.static booleanisEmpty(byte[] bytes) Checks if a bytes array is empty or null.static booleanChecks if a String is empty ("") or null.static booleanisIA5String(String str) Check that a String is a valid IA5String.static booleanisNotEmpty(String str) Checks if a String is not empty ("") and not null.static booleanisPrintableString(String str) Check that a String is a valid PrintableString.static booleanisValidUuid(String uuid) Checks to see if a String is a valid UUID.static StringlistToString(List<?> list) Utility method that return a String representation of a liststatic StringlistToString(List<?> list, String tabs) Utility method that return a String representation of a liststatic StringConverts a String to lower case as perString.toLowerCase().static StringlowerCaseAscii(String str) Rewrote the toLowercase method to improve performances.static StringmapToString(Map<?, ?> map) Utility method that return a String representation of a map.static StringmapToString(Map<?, ?> map, String tabs) Utility method that return a String representation of a map.static intPast an ASCII String to a numberstatic StringsetToString(Set<?> set) Utility method that return a String representation of a setstatic byte[]toByteArray(String hexString) Get byte array from hex stringstatic StringtoHexString(byte[] res) Gets a hex string from byte array.static StringtoLowerCase(byte[] value) Rewrote the toLowercase method to improve performances.static StringtoLowerCase(String value) Deprecated.static StringtoLowerCaseAscii(String value) Rewrote the toLowercase method to improve performances.static StringtoUpperCase(String value) Deprecated.static StringtoUpperCaseAscii(String value) Rewrote the toLowercase method to improve performances.static byte[]trim(byte[] bytes) Removes spaces (char <= 32) from both start and ends of this bytes array, handlingnullby returningnull.static StringRemoves spaces (char <= 32) from both start and ends of this String, handlingnullby returningnull.static StringtrimConsecutiveToOne(String str, char ch) Trims several consecutive characters into one.static inttrimLeft(byte[] bytes, int pos) Removes spaces (char <= 32) from start of this array, handlingnullby returningnull.static voidRemoves spaces (char <= 32) from a position in this array, handlingnullby returningnull.static inttrimLeft(char[] chars, int pos) Removes spaces (char <= 32) from start of this array, handlingnullby returningnull.static StringRemoves spaces (char <= 32) from start of this String, handlingnullby returningnull.static voidRemoves spaces (char <= 32) from a position in this array, handlingnullby returningnull.static inttrimRight(byte[] bytes, int pos) Removes spaces (char <= 32) from end of this array, handlingnullby returningnull.static StringRemoves spaces (char <= 32) from end of this string, handlingnullby returningnull.static inttrimRight(char[] chars, int pos) Removes spaces (char <= 32) from end of this array, handlingnullby returningnull.static StringRemoves spaces (char <= 32) from end of this String, handlingnullby returningnull.static StringRemoves spaces (char <= 32) from end of this String, handlingnullby returningnull.static StringRemoves spaces (char <= 32) from end of this string, handlingnullby returningnull.static StringConverts a String to upper case as perString.toUpperCase(Locale).static Stringutf8ToString(byte[] bytes) Return an UTF-8 encoded Stringstatic Stringutf8ToString(byte[] bytes, int length) Return an UTF-8 encoded Stringstatic Stringutf8ToString(byte[] bytes, int start, int length) Return an UTF-8 encoded Stringstatic byte[]uuidToBytes(String string) converts the string representation of an UUID to bytesstatic StringuuidToString(byte[] bytes) converts the bytes of a UUID to string
-
Field Details
-
HEX_CHAR
public static final byte[] HEX_CHARHex chars -
EMPTY_BYTES
public static final byte[] EMPTY_BYTESAn empty byte array -
EMPTY_STRING
-
EMPTY_STRING_ARRAY
An empty String array
-
-
Method Details
-
dumpBytes
Helper function that dump an array of bytes in hex form- Parameters:
buffer- The bytes array to dump- Returns:
- A string representation of the array of bytes
-
byteToString
Helper function that dump a byte as a double digit value- Parameters:
b- The byte to dump- Returns:
- A string representation of byte as a string
-
dumpByte
Helper function that dump a byte in hex form- Parameters:
octet- The byte to dump- Returns:
- A string representation of the byte
-
dumpHex
public static char dumpHex(byte hex) Helper function that returns a char from an hex- Parameters:
hex- The hex to dump- Returns:
- A char representation of the hex
-
dumpHexPairs
Helper function that dump an array of bytes in hex pair form, without '0x' and space chars- Parameters:
buffer- The bytes array to dump- Returns:
- A string representation of the array of bytes
-
deepTrim
-
deepTrimToLower
This does the same thing as a trim but we also lowercase the string while performing the deep trim within the same buffer. This saves us from having to create multiple String and StringBuilder objects and is much more efficient.- Parameters:
string- The String to modify- Returns:
- The modified String
- See Also:
-
deepTrim
A deep trim of a string remove whitespace from the ends as well as excessive whitespace within the inside of the string between non-whitespace characters. A deep trim reduces internal whitespace down to a single space to preserve the whitespace separated tokenization order of the String.- Parameters:
string- the string to deep trim.- Returns:
- the trimmed string.
-
trimConsecutiveToOne
-
centerTrunc
Truncates large Strings showing a portion of the String's head and tail with the center cut out and replaced with '...'. Also displays the total length of the truncated string so size of '...' can be interpreted. Useful for large strings in UIs or hex dumps to log files.- Parameters:
str- the string to truncatehead- the amount of the head to displaytail- the amount of the tail to display- Returns:
- the center truncated string
-
toHexString
Gets a hex string from byte array.- Parameters:
res- the byte array- Returns:
- the hex string representing the binary values in the array
-
toByteArray
Get byte array from hex string- Parameters:
hexString- the hex string to convert to a byte array- Returns:
- the byte form of the hex string.
-
formatHtml
public static String formatHtml(String source, boolean replaceNl, boolean replaceTag, boolean replaceQuote) This method is used to insert HTML block dynamically- Parameters:
source- the HTML code to be processesreplaceNl- if true '\n' will be replaced by <br>replaceTag- if true '<' will be replaced by < and '>' will be replaced by >replaceQuote- if true '\"' will be replaced by "- Returns:
- the formated html block
-
areEquals
Check if a text is present at the current position in another string.- Parameters:
string- The string which contains the dataindex- Current position in the stringtext- The text we want to check- Returns:
trueif the string contains the text.
-
isCharASCII
public static boolean isCharASCII(byte[] byteArray, int index, char car) Test if the current character is equal to a specific character. This function works only for character between 0 and 127, as it does compare a byte and a char (which is 16 bits wide)- Parameters:
byteArray- The buffer which contains the dataindex- Current position in the buffercar- The character we want to compare with the current buffer position- Returns:
trueif the current character equals the given character.
-
isCharASCII
public static boolean isCharASCII(char[] charArray, int index, char car) Test if the current character is equal to a specific character. This function works only for character between 0 and 127, as it does compare a byte and a char (which is 16 bits wide)- Parameters:
charArray- The buffer which contains the dataindex- Current position in the buffercar- The character we want to compare with the current buffer position- Returns:
trueif the current character equals the given character.
-
isCharASCII
Test if the current character is equal to a specific character.- Parameters:
string- The String which contains the dataindex- Current position in the stringcar- The character we want to compare with the current string position- Returns:
trueif the current character equals the given character.
-
utf8ToString
Return an UTF-8 encoded String- Parameters:
bytes- The byte array to be transformed to a String- Returns:
- A String.
-
utf8ToString
Return an UTF-8 encoded String- Parameters:
bytes- The byte array to be transformed to a Stringlength- The length of the byte array to be converted- Returns:
- A String.
-
utf8ToString
Return an UTF-8 encoded String- Parameters:
bytes- The byte array to be transformed to a Stringstart- the starting position in the byte arraylength- The length of the byte array to be converted- Returns:
- A String.
-
areEquals
Check if a text is present at the current position in a buffer.- Parameters:
bytes- The buffer which contains the dataindex- Current position in the buffertext- The text we want to check- Returns:
- The position after the found text if it's present in the buffer: it's the current position plus the text length.
If the text is not present, then
StringConstants.NOT_EQUALis returned (-1)
-
areEquals
Check if a text is present at the current position in a buffer.- Parameters:
chars- The buffer which contains the dataindex- Current position in the buffertext- The text we want to check- Returns:
- The position after the found text if it's present in the buffer: it's the current position plus the text length.
If the text is not present, then
StringConstants.NOT_EQUALis returned (-1)
-
areEquals
Check if a text is present at the current position in a buffer.- Parameters:
chars- The buffer which contains the dataindex- Current position in the buffertext- The text we want to checkcaseSensitive- If the comparison is case-sensitive- Returns:
- The position after the found text if it's present in the buffer: it's the current position plus the text length.
If the text is not present, then
StringConstants.NOT_EQUALis returned (-1)
-
areEquals
public static int areEquals(char[] chars, int index, char[] chars2) Check if a text is present at the current position in a buffer.- Parameters:
chars- The buffer which contains the dataindex- Current position in the bufferchars2- The text we want to check- Returns:
- The position after the found text if it's present in the buffer: it's the current position plus the text length.
If the text is not present, then
StringConstants.NOT_EQUALis returned (-1)
-
areEquals
public static int areEquals(char[] chars, int index, char[] chars2, boolean caseSensitive) Check if a text is present at the current position in a buffer.- Parameters:
chars- The buffer which contains the dataindex- Current position in the bufferchars2- The text we want to checkcaseSensitive- If the comparison is case-sensitive- Returns:
- The position after the found text if it's present in the buffer: it's the current position plus the text length.
If the text is not present, then
StringConstants.NOT_EQUALis returned (-1)
-
areEquals
public static int areEquals(byte[] bytes, int index, byte[] bytes2) Check if a text is present at the current position in a buffer.- Parameters:
bytes- The buffer which contains the dataindex- Current position in the bufferbytes2- The text we want to check- Returns:
- The position after the found text if it's present in the buffer: it's the current position plus the text length.
If the text is not present, then
StringConstants.NOT_EQUALis returned (-1)
-
isEmpty
Checks if a String is empty ("") or null.
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = falseNOTE: This method changed in Lang version 2.0. It no longer trims the String. That functionality is available in isBlank().
- Parameters:
str- the String to check, may be null- Returns:
trueif the String is empty or null
-
isEmpty
public static boolean isEmpty(byte[] bytes) Checks if a bytes array is empty or null.- Parameters:
bytes- The bytes array to check, may be null- Returns:
trueif the bytes array is empty or null
-
trim
Removes spaces (char <= 32) from both start and ends of this String, handling
Trim removes start and end characters <= 32.nullby returningnull.StringUtils.trim(null) = null StringUtils.trim("") = "" StringUtils.trim(" ") = "" StringUtils.trim("abc") = "abc" StringUtils.trim(" abc ") = "abc"- Parameters:
str- the String to be trimmed, may be null- Returns:
- the trimmed string,
nullif null String input
-
trim
public static byte[] trim(byte[] bytes) Removes spaces (char <= 32) from both start and ends of this bytes array, handling
Trim removes start and end characters <= 32.nullby returningnull.StringUtils.trim(null) = null StringUtils.trim("") = "" StringUtils.trim(" ") = "" StringUtils.trim("abc") = "abc" StringUtils.trim(" abc ") = "abc"- Parameters:
bytes- the byte array to be trimmed, may be null- Returns:
- the trimmed byte array
-
trimLeft
Removes spaces (char <= 32) from start of this String, handling
Trim removes start characters <= 32.nullby returningnull.StringUtils.trimLeft(null) = null StringUtils.trimLeft("") = "" StringUtils.trimLeft(" ") = "" StringUtils.trimLeft("abc") = "abc" StringUtils.trimLeft(" abc ") = "abc "- Parameters:
str- the String to be trimmed, may be null- Returns:
- the trimmed string,
nullif null String input
-
trimLeft
public static int trimLeft(char[] chars, int pos) Removes spaces (char <= 32) from start of this array, handling
Trim removes start characters <= 32.nullby returningnull.StringUtils.trimLeft(null) = null StringUtils.trimLeft("") = "" StringUtils.trimLeft(" ") = "" StringUtils.trimLeft("abc") = "abc" StringUtils.trimLeft(" abc ") = "abc "- Parameters:
chars- the chars array to be trimmed, may be nullpos- The position in the char[]- Returns:
- the position of the first char which is not a space, or the last position of the array.
-
trimLeft
Removes spaces (char <= 32) from a position in this array, handling
Trim removes start characters <= 32.nullby returningnull.StringUtils.trimLeft(null) = null StringUtils.trimLeft("",...) = "" StringUtils.trimLeft(" ",...) = "" StringUtils.trimLeft("abc",...) = "abc" StringUtils.trimLeft(" abc ",...) = "abc "- Parameters:
string- the string to be trimmed, may be nullpos- The position in the String
-
trimLeft
Removes spaces (char <= 32) from a position in this array, handling
Trim removes start characters <= 32.nullby returningnull.StringUtils.trimLeft(null) = null StringUtils.trimLeft("",...) = "" StringUtils.trimLeft(" ",...) = "" StringUtils.trimLeft("abc",...) = "abc" StringUtils.trimLeft(" abc ",...) = "abc "- Parameters:
bytes- the byte array to be trimmed, may be nullpos- The position in the byte[]
-
trimLeft
public static int trimLeft(byte[] bytes, int pos) Removes spaces (char <= 32) from start of this array, handling
Trim removes start characters <= 32.nullby returningnull.StringUtils.trimLeft(null) = null StringUtils.trimLeft("") = "" StringUtils.trimLeft(" ") = "" StringUtils.trimLeft("abc") = "abc" StringUtils.trimLeft(" abc ") = "abc "- Parameters:
bytes- the byte array to be trimmed, may be nullpos- The position in the byte[]- Returns:
- the position of the first byte which is not a space, or the last position of the array.
-
trimRight
Removes spaces (char <= 32) from end of this String, handling
Trim removes start characters <= 32.nullby returningnull.StringUtils.trimRight(null) = null StringUtils.trimRight("") = "" StringUtils.trimRight(" ") = "" StringUtils.trimRight("abc") = "abc" StringUtils.trimRight(" abc ") = " abc"- Parameters:
str- the String to be trimmed, may be null- Returns:
- the trimmed string,
nullif null String input
-
trimRight
Removes spaces (char <= 32) from end of this String, handling
Trim removes start characters <= 32.nullby returningnull.StringUtils.trimRight(null) = null StringUtils.trimRight("") = "" StringUtils.trimRight(" ") = "" StringUtils.trimRight("abc") = "abc" StringUtils.trimRight(" abc ") = " abc"- Parameters:
str- the String to be trimmed, may be nullescapedSpace- The last escaped space, if any- Returns:
- the trimmed string,
nullif null String input
-
trimRight
public static int trimRight(char[] chars, int pos) Removes spaces (char <= 32) from end of this array, handling
Trim removes start characters <= 32.nullby returningnull.StringUtils.trimRight(null) = null StringUtils.trimRight("") = "" StringUtils.trimRight(" ") = "" StringUtils.trimRight("abc") = "abc" StringUtils.trimRight(" abc ") = " abc"- Parameters:
chars- the chars array to be trimmed, may be nullpos- The position in the char[]- Returns:
- the position of the first char which is not a space, or the last position of the array.
-
trimRight
Removes spaces (char <= 32) from end of this string, handling
Trim removes start characters <= 32.nullby returningnull.StringUtils.trimRight(null) = null StringUtils.trimRight("") = "" StringUtils.trimRight(" ") = "" StringUtils.trimRight("abc") = "abc" StringUtils.trimRight(" abc ") = " abc"- Parameters:
string- the string to be trimmed, may be nullpos- The position in the String- Returns:
- the position of the first char which is not a space, or the last position of the string.
-
trimRight
Removes spaces (char <= 32) from end of this string, handling
Trim removes start characters <= 32.nullby returningnull.StringUtils.trimRight(null) = null StringUtils.trimRight("") = "" StringUtils.trimRight(" ") = "" StringUtils.trimRight("abc") = "abc" StringUtils.trimRight(" abc ") = " abc"- Parameters:
bytes- the byte array to be trimmed, may be nullpos- The position in the byte[]- Returns:
- the position of the first char which is not a space, or the last position of the byte array.
-
trimRight
public static int trimRight(byte[] bytes, int pos) Removes spaces (char <= 32) from end of this array, handling
Trim removes start characters <= 32.nullby returningnull.StringUtils.trimRight(null) = null StringUtils.trimRight("") = "" StringUtils.trimRight(" ") = "" StringUtils.trimRight("abc") = "abc" StringUtils.trimRight(" abc ") = " abc"- Parameters:
bytes- the byte array to be trimmed, may be nullpos- The position in the byte[]- Returns:
- the position of the first char which is not a space, or the last position of the array.
-
charAt
Get the character at a given position in a string, checking for limits- Parameters:
string- The string which contains the dataindex- Current position in the string- Returns:
- The character at the given position, or '\0' if something went wrong
-
byteAt
public static byte byteAt(byte[] bytes, int index) Get the byte at a given position in a byte array, checking for limits- Parameters:
bytes- The byte[] which contains the dataindex- Current position in the byte[]- Returns:
- The byte at the given position, or '\0' if something went wrong
-
charAt
public static char charAt(char[] chars, int index) Get the char at a given position in a byte array, checking for limits- Parameters:
chars- The char[] which contains the dataindex- Current position in the char[]- Returns:
- The byte at the given position, or '\0' if something went wrong
-
asciiBytesToString
Transform an array of ASCII bytes to a string. the byte array should contains only values in [0, 127].- Parameters:
bytes- The byte array to transform- Returns:
- The resulting string
-
getBytesUtf8
Return UTF-8 encoded byte[] representation of a String- Parameters:
string- The string to be transformed to a byte array- Returns:
- The transformed byte array
-
getBytesUtf8Ascii
When the string to convert to bytes is pure ascii, this is a faster method than the getBytesUtf8. Otherwise, it's slower.- Parameters:
string- The string to convert to byte[]- Returns:
- The bytes
-
getDefaultCharsetName
-
equals
Compares two Strings, returning
trueif they are equal.nulls are handled without exceptions. Twonullreferences are considered to be equal. The comparison is case sensitive.StringUtils.equals(null, null) = true StringUtils.equals(null, "abc") = false StringUtils.equals("abc", null) = false StringUtils.equals("abc", "abc") = true StringUtils.equals("abc", "ABC") = false- Parameters:
str1- the first String, may be nullstr2- the second String, may be null- Returns:
trueif the Strings are equal, case sensitive, or bothnull- See Also:
-
listToString
-
setToString
-
listToString
-
mapToString
-
mapToString
-
toLowerCase
Deprecated.Rewrote the toLowercase method to improve performances. In Ldap, attributesType are supposed to use ASCII chars : 'a'-'z', 'A'-'Z', '0'-'9', '.' and '-' only.
Deprecated : UsetoLowerCaseAscii(String)- Parameters:
value- The String to lowercase- Returns:
- The lowercase string
-
toLowerCaseAscii
-
toLowerCase
Rewrote the toLowercase method to improve performances. In Ldap, attributesType are supposed to use ASCII chars : 'a'-'z', 'A'-'Z', '0'-'9', '.' and '-' only.- Parameters:
value- The byte[] to lowercase- Returns:
- The lowercase string
-
toUpperCase
Deprecated.Rewrote the toUppercase method to improve performances. In Ldap, attributesType are supposed to use ASCII chars : 'a'-'z', 'A'-'Z', '0'-'9', '.' and '-' only. We also add the '_' char
Deprecated UsetoUpperCaseAscii(String)- Parameters:
value- The String to uppercase- Returns:
- The uppercase string
-
toUpperCaseAscii
-
upperCase
Converts a String to upper case as per
String.toUpperCase(Locale).A
nullinput String returnsnull.StringUtils.upperCase(null) = null StringUtils.upperCase("") = "" StringUtils.upperCase("aBc") = "ABC"- Parameters:
str- the String to upper case, may be null- Returns:
- the upper cased String,
nullif null String input
-
lowerCase
Converts a String to lower case as per
String.toLowerCase().A
nullinput String returnsnull.StringUtils.lowerCase(null) = null StringUtils.lowerCase("") = "" StringUtils.lowerCase("aBc") = "abc"- Parameters:
str- the String to lower case, may be null- Returns:
- the lower cased String,
nullif null String input
-
lowerCaseAscii
Rewrote the toLowercase method to improve performances. In Ldap, attributesType are supposed to use ASCII chars : 'a'-'z', 'A'-'Z', '0'-'9', '.' and '-' only. We will take care of any other chars either.- Parameters:
str- The String to lowercase- Returns:
- The lowercase string
-
isPrintableString
Check that a String is a valid PrintableString. A PrintableString contains only the following set of chars : { ' ', ''', '(', ')', '+', '-', '.', '/', [0-9], ':', '=', '?', [A-Z], [a-z]}- Parameters:
str- The String to check- Returns:
trueif the string is a PrintableString or is empty,falseotherwise
-
isNotEmpty
Checks if a String is not empty ("") and not null.
StringUtils.isNotEmpty(null) = false StringUtils.isNotEmpty("") = false StringUtils.isNotEmpty(" ") = true StringUtils.isNotEmpty("bob") = true StringUtils.isNotEmpty(" bob ") = true- Parameters:
str- the String to check, may be null- Returns:
trueif the String is not empty and not null
-
isIA5String
Check that a String is a valid IA5String. An IA5String contains only char which values is between [0, 7F]- Parameters:
str- The String to check- Returns:
trueif the string is an IA5String or is empty,falseotherwise
-
isValidUuid
Checks to see if a String is a valid UUID.- Parameters:
uuid- the UUID to check for validity- Returns:
- true if the UUID is valid, false otherwise
-
uuidToString
converts the bytes of a UUID to string- Parameters:
bytes- bytes of a UUID- Returns:
- UUID in string format
-
uuidToBytes
converts the string representation of an UUID to bytes- Parameters:
string- the string representation of an UUID- Returns:
- the bytes, null if the the syntax is not valid
-
copy
public static byte[] copy(byte[] value) Copy a byte array into a new byte array- Parameters:
value- the byte array to copy- Returns:
- The copied byte array
-
getString
From commons-httpclients. Converts the byte array of HTTP content characters to a string. If the specified charset is not supported, default system encoding is used.- Parameters:
data- the byte array to be encodedoffset- the index of the first byte to encodelength- the number of bytes to encodecharset- the desired character encoding- Returns:
- The result of the conversion.
- Since:
- 3.0
-
getString
From commons-httpclients. Converts the byte array of HTTP content characters to a string. If the specified charset is not supported, default system encoding is used.- Parameters:
data- the byte array to be encodedoffset- the index of the first byte to encodelength- the number of bytes to encodecharset- the desired character encoding- Returns:
- The result of the conversion.
- Since:
- 3.0
-
getString
From commons-httpclients. Converts the byte array of HTTP content characters to a string. If the specified charset is not supported, default system encoding is used.- Parameters:
data- the byte array to be encodedcharset- the desired character encoding- Returns:
- The result of the conversion.
- Since:
- 3.0
-
getString
From commons-httpclients. Converts the byte array of HTTP content characters to a string. If the specified charset is not supported, default system encoding is used.- Parameters:
data- the byte array to be encodedcharset- the desired character encoding- Returns:
- The result of the conversion.
- Since:
- 3.0
-
getUUID
Create a new UUID using a long as the least significant bits- Parameters:
value- The least significant bits.- Returns:
- The created UUID
-
parseInt
Past an ASCII String to a number- Parameters:
value- The string to parse- Returns:
- the parsed value.
-
compare
public static int compare(byte[] b1, byte[] b2) Compate two byte arrrays- Parameters:
b1- The first byte[] to compareb2- The second byte[] to compare- Returns:
- -1 if the first byte[] is inferior to the second one, 1 if teh first byte[] is superior to the second one, 0 if they are equal.
- See Also:
-
toLowerCaseAscii(String)