|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.directory.shared.ldap.util.StringTools
public class StringTools
Various string manipulation methods that are more efficient then chaining string operations: all is done in the same buffer without creating a bunch of string objects.
| Field Summary | |
|---|---|
static boolean[] |
ALPHA
<alpha> ::= [0x41-0x5A] | [0x61-0x7A] |
static boolean[] |
ALPHA_DIGIT
<alpha-digit> | <digit> |
static boolean[] |
ALPHA_LOWER_CASE
<alpha-lower-case> ::= [0x61-0x7A] |
static boolean[] |
ALPHA_UPPER_CASE
<alpha-upper-case> ::= [0x41-0x5A] |
static boolean[] |
CHAR
<alpha> | <digit> | '-' |
static String |
EMPTY
The empty String "". |
static byte[] |
EMPTY_BYTES
The empty byte[] |
static String[] |
EMPTY_STRINGS
The empty String[] |
static int |
NOT_EQUAL
|
| Constructor Summary | |
|---|---|
StringTools()
|
|
| Method Summary | |
|---|---|
static int |
areEquals(byte[] bytes,
int index,
byte[] bytes2)
Check if a text is present at the current position in a buffer. |
static int |
areEquals(byte[] bytes,
int index,
String text)
Check if a text is present at the current position in a buffer. |
static int |
areEquals(char[] chars,
int index,
char[] chars2)
Check if a text is present at the current position in a buffer. |
static int |
areEquals(char[] chars,
int index,
String text)
Check if a text is present at the current position in a buffer. |
static boolean |
areEquals(String string,
int index,
String text)
Check if a text is present at the current position in another string. |
static String |
asciiBytesToString(byte[] bytes)
Thansform an array of ASCII bytes to a string. |
static char |
bytesToChar(byte[] bytes)
Return the Unicode char which is coded in the bytes at position 0. |
static char |
bytesToChar(byte[] bytes,
int pos)
Return the Unicode char which is coded in the bytes at the given position. |
static String |
centerTrunc(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 char |
charAt(String string,
int index)
Get the character at a given position in a string, checking fo limits |
static byte[] |
charToBytes(char car)
Return the Unicode char which is coded in the bytes at the given position. |
static int |
collectEscapedHexBytes(ByteBuffer bb,
String str,
int index)
Collects an hex sequence from a string, and returns the value as an integer, after having modified the initial value (the escaped hex value is transsformed to the byte it represents). |
static byte[] |
convertEscapedHex(String str)
Convert an escaoed list of bytes to a byte[] |
static int |
countBytes(char[] chars)
Count the number of bytes included in the given char[]. |
static int |
countBytesPerChar(byte[] bytes,
int pos)
Count the number of bytes needed to return an Unicode char. |
static int |
countChars(byte[] bytes)
Count the number of chars included in the given byte[]. |
static int |
countNbBytesPerChar(char car)
Return the number of bytes that hold an Unicode char. |
static String |
decodeEscapedHex(String str)
Decodes sequences of escaped hex within an attribute's value into a UTF-8 String. |
static String |
decodeHexString(String str)
Decodes values of attributes in the DN encoded in hex into a UTF-8 String. |
static String |
deepTrim(String string)
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. |
static String |
deepTrim(String str,
boolean toLowerCase)
Put common code to deepTrim(String) and deepTrimToLower here. |
static String |
deepTrimToLower(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 String |
dumpByte(byte octet)
Helper function that dump a byte in hex form |
static String |
dumpBytes(byte[] buffer)
Helper function that dump an array of bytes in hex form |
static char |
dumpHex(byte hex)
Helper function that returns a char from an hex |
static String |
dumpHexPairs(byte[] buffer)
Helper function that dump an array of bytes in hex pair form, without '0x' and space chars |
static String |
dumpObject(Object object)
Helper method to render an object which can be a String or a byte[] |
static boolean |
equals(String str1,
String str2)
Compares two Strings, returning true if they are equal. |
static String |
formatHtml(String source,
boolean replaceNl,
boolean replaceTag,
boolean replaceQuote)
This method is used to insert HTML block dynamically |
static byte[] |
getBytesUtf8(String string)
Return UTF-8 encoded byte[] representation of a String |
static String |
getDefaultCharsetName()
Get the default charset |
static byte |
getHexValue(byte high,
byte low)
Translate two bytes to an hex value. |
static byte |
getHexValue(char c)
Return an hex value from a sinle char The char must be in [0-9a-fA-F] |
static byte |
getHexValue(char high,
char low)
Translate two chars to an hex value. |
static List<String> |
getPaths(String paths,
FileFilter filter)
Splits apart a OS separator delimited set of paths in a string into multiple Strings. |
static Pattern |
getRegex(String ldapRegex)
Generates a regular expression from an LDAP substring match expression by parsing out the supplied string argument. |
static Pattern |
getRegex(String initialPattern,
String[] anyPattern,
String finalPattern)
Creates a regular expression from an LDAP substring assertion filter specification. |
static String |
getType(byte[] bytes)
Build an AttributeType froma byte array. |
static boolean |
isAlpha(byte c)
Test if the current byte is an Alpha character : <alpha> ::= [0x41-0x5A] | [0x61-0x7A] |
static boolean |
isAlpha(char c)
Test if the current character is an Alpha character : <alpha> ::= [0x41-0x5A] | [0x61-0x7A] |
static boolean |
isAlphaASCII(byte[] bytes,
int index)
Test if the current character is an Alpha character : <alpha> ::= [0x41-0x5A] | [0x61-0x7A] |
static boolean |
isAlphaASCII(char[] chars,
int index)
Test if the current character is an Alpha character : <alpha> ::= [0x41-0x5A] | [0x61-0x7A] |
static boolean |
isAlphaASCII(String string,
int index)
Test if the current character is an Alpha character : <alpha> ::= [0x41-0x5A] | [0x61-0x7A] |
static boolean |
isAlphaDigit(String string,
int index)
Check if the current character is an 7 bits ASCII CHAR (between 0 and 127). |
static boolean |
isAlphaDigitMinus(byte[] bytes,
int index)
Check if the current character is an 7 bits ASCII CHAR (between 0 and 127). |
static boolean |
isAlphaDigitMinus(char[] chars,
int index)
Check if the current character is an 7 bits ASCII CHAR (between 0 and 127). |
static boolean |
isAlphaDigitMinus(String string,
int index)
Check if the current character is an 7 bits ASCII CHAR (between 0 and 127). |
static boolean |
isAlphaLowercaseASCII(String string,
int index)
Test if the current character is a lowercased Alpha character : <alpha> ::= [0x61-0x7A] |
static boolean |
isAlphaUppercaseASCII(String string,
int index)
Test if the current character is a uppercased Alpha character : <alpha> ::= [0x61-0x7A] |
static boolean |
isBit(String string,
int index)
Test if the current character is a bit, ie 0 or 1. |
static boolean |
isCharASCII(byte[] byteArray,
int index,
char car)
Test if the current character is equal to a specific character. |
static boolean |
isCharASCII(char[] chars,
int index,
char car)
Test if the current character is equal to a specific character. |
static boolean |
isCharASCII(String string,
int index,
char car)
Test if the current character is equal to a specific character. |
static boolean |
isDigit(byte[] bytes)
Test if the current character is a digit <digit> ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
static boolean |
isDigit(byte[] bytes,
int index)
Test if the current character is a digit <digit> ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
static boolean |
isDigit(char car)
Test if the current character is a digit <digit> ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
static boolean |
isDigit(char[] chars)
Test if the current character is a digit <digit> ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
static boolean |
isDigit(char[] chars,
int index)
Test if the current character is a digit <digit> ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
static boolean |
isDigit(String string,
int index)
Test if the current character is a digit <digit> ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
static boolean |
isEmpty(byte[] bytes)
Checks if a bytes array is empty or null. |
static boolean |
isEmpty(String str)
Checks if a String is empty ("") or null. |
static boolean |
isHex(byte[] bytes,
int index)
Check if the current character is an Hex Char <hex> ::= [0x30-0x39] | [0x41-0x46] | [0x61-0x66] |
static boolean |
isHex(char[] chars,
int index)
Check if the current character is an Hex Char <hex> ::= [0x30-0x39] | [0x41-0x46] | [0x61-0x66] |
static boolean |
isHex(String string,
int index)
Check if the current character is an Hex Char <hex> ::= [0x30-0x39] | [0x41-0x46] | [0x61-0x66] |
static boolean |
isIA5String(String str)
Check that a String is a valid IA5String. |
static boolean |
isICharASCII(byte[] bytes,
int index,
char car)
Test if the current character is equal to a specific character. |
static boolean |
isICharASCII(String string,
int index,
char car)
Test if the current character is equal to a specific character. |
static boolean |
isNotEmpty(String str)
Checks if a String is not empty ("") and not null. |
static boolean |
isPrintableString(String str)
Check that a String is a valid PrintableString. |
static boolean |
isUnicodeSubset(char c)
Check if the current char is in the unicodeSubset : all chars but '\0', '(', ')', '*' and '\' |
static boolean |
isUnicodeSubset(String str,
int pos)
Check if the current char is in the unicodeSubset : all chars but '\0', '(', ')', '*' and '\' |
static String |
listToString(List<?> list)
Utility method that return a String representation of a list |
static String |
listToString(List<?> list,
String tabs)
Utility method that return a String representation of a list |
static String |
lowerCase(String str)
Converts a String to lower case as per String.toLowerCase(). |
static String |
lowerCaseAscii(String str)
Rewrote the toLowercase method to improve performances. |
static String |
mapToString(Map<?,?> map)
Utility method that return a String representation of a map. |
static String |
mapToString(Map<?,?> map,
String tabs)
Utility method that return a String representation of a map. |
static String |
setToString(Set<?> set)
Utility method that return a String representation of a set |
static byte[] |
toByteArray(String hexString)
Get byte array from hex string |
static String |
toHexString(byte[] res)
Gets a hex string from byte array. |
static String |
toLowerCase(String value)
Rewrote the toLowercase method to improve performances. |
static String |
toUpperCase(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, handling null by returning null. |
static String |
trim(String str)
Removes spaces (char <= 32) from both start and ends of this String, handling null by returning null. |
static String |
trimConsecutiveToOne(String str,
char ch)
Trims several consecutive characters into one. |
static int |
trimLeft(byte[] bytes,
int pos)
Removes spaces (char <= 32) from start of this array, handling null by returning null. |
static void |
trimLeft(byte[] bytes,
Position pos)
Removes spaces (char <= 32) from a position in this array, handling null by returning null. |
static int |
trimLeft(char[] chars,
int pos)
Removes spaces (char <= 32) from start of this array, handling null by returning null. |
static String |
trimLeft(String str)
Removes spaces (char <= 32) from start of this String, handling null by returning null. |
static void |
trimLeft(String string,
Position pos)
Removes spaces (char <= 32) from a position in this array, handling null by returning null. |
static int |
trimRight(byte[] bytes,
int pos)
Removes spaces (char <= 32) from end of this array, handling null by returning null. |
static String |
trimRight(byte[] bytes,
Position pos)
Removes spaces (char <= 32) from end of this string, handling null by returning null. |
static int |
trimRight(char[] chars,
int pos)
Removes spaces (char <= 32) from end of this array, handling null by returning null. |
static String |
trimRight(String str)
Removes spaces (char <= 32) from end of this String, handling null by returning null. |
static String |
trimRight(String str,
int escapedSpace)
Removes spaces (char <= 32) from end of this String, handling null by returning null. |
static String |
trimRight(String string,
Position pos)
Removes spaces (char <= 32) from end of this string, handling null by returning null. |
static String |
upperCase(String str)
Converts a String to upper case as per String.toUpperCase(). |
static String |
utf8ToString(byte[] bytes)
Return an UTF-8 encoded String |
static String |
utf8ToString(byte[] bytes,
int length)
Return an UTF-8 encoded String |
static String |
utf8ToString(byte[] bytes,
int start,
int length)
Return an UTF-8 encoded String |
static byte[] |
uuidToBytes(String string)
converts the string representation of an UUID to bytes |
static String |
uuidToString(byte[] bytes)
converts the bytes of a UUID to string |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final boolean[] ALPHA
public static final boolean[] ALPHA_LOWER_CASE
public static final boolean[] ALPHA_UPPER_CASE
public static final boolean[] ALPHA_DIGIT
public static final boolean[] CHAR
public static final int NOT_EQUAL
public static final String EMPTY
"".
public static final byte[] EMPTY_BYTES
public static final String[] EMPTY_STRINGS
| Constructor Detail |
|---|
public StringTools()
| Method Detail |
|---|
public static final String trimConsecutiveToOne(String str,
char ch)
str - the string to trim consecutive characters ofch - the character to trim down
public static final String deepTrim(String string)
string - the string to deep trim.
public static final String deepTrimToLower(String string)
deepTrim( String )
public static final String deepTrim(String str,
boolean toLowerCase)
str - the string to deep trimtoLowerCase - how to normalize for case: upper or lower
TODO Replace the toCharArray() by substring manipulations
public static final String centerTrunc(String str,
int head,
int tail)
str - the string to truncatehead - the amount of the head to displaytail - the amount of the tail to display
public static final String toHexString(byte[] res)
res - the byte array
public static final String toLowerCase(String value)
value - The String to lowercase
public static final String toUpperCase(String value)
value - The String to uppercase
public static final byte[] toByteArray(String hexString)
hexString - the hex string to convert to a byte array
public static final String formatHtml(String source,
boolean replaceNl,
boolean replaceTag,
boolean replaceQuote)
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 "
public static final Pattern getRegex(String initialPattern,
String[] anyPattern,
String finalPattern)
throws PatternSyntaxException
initialPattern - the initial fragment before wildcardsanyPattern - fragments surrounded by wildcards if anyfinalPattern - the final fragment after last wildcard if any
PatternSyntaxException - if a syntactically correct regular expression cannot be
compiled
public static final Pattern getRegex(String ldapRegex)
throws PatternSyntaxException
ldapRegex - the substring match expression
PatternSyntaxException - if a syntactically correct regular expression cannot be
compiled
public static final List<String> getPaths(String paths,
FileFilter filter)
paths - a set of paths delimited using the OS path separatorfilter - a FileFilter used to filter the return set
public static final String dumpByte(byte octet)
octet - The byte to dump
public static final char dumpHex(byte hex)
hex - The hex to dump
public static final String dumpBytes(byte[] buffer)
buffer - The bytes array to dump
public static String dumpObject(Object object)
public static final String dumpHexPairs(byte[] buffer)
buffer - The bytes array to dump
public static final char bytesToChar(byte[] bytes)
bytes - The byte[] represntation of an Unicode string.
public static final int countBytesPerChar(byte[] bytes,
int pos)
bytes - The bytes to readpos - Position to start counting. It must be a valid start of a
encoded char !
public static final int countNbBytesPerChar(char car)
car - The character to be decoded
public static final int countBytes(char[] chars)
chars - The char array to decode
public static final char bytesToChar(byte[] bytes,
int pos)
bytes - The byte[] represntation of an Unicode string.pos - The current position to start decoding the char
public static final byte[] charToBytes(char car)
car - The character to be transformed to an array of bytes
public static final int countChars(byte[] bytes)
bytes - The byte array to decode
public static final int areEquals(byte[] bytes,
int index,
String text)
bytes - The buffer which contains the dataindex - Current position in the buffertext - The text we want to check
true if the buffer contains the text.
public static final int areEquals(char[] chars,
int index,
String text)
chars - The buffer which contains the dataindex - Current position in the buffertext - The text we want to check
true if the buffer contains the text.
public static final int areEquals(char[] chars,
int index,
char[] chars2)
chars - The buffer which contains the dataindex - Current position in the bufferchars2 - The text we want to check
true if the buffer contains the text.
public static final boolean areEquals(String string,
int index,
String text)
string - The string which contains the dataindex - Current position in the stringtext - The text we want to check
true if the string contains the text.
public static final int areEquals(byte[] bytes,
int index,
byte[] bytes2)
bytes - The buffer which contains the dataindex - Current position in the bufferbytes2 - The text we want to check
true if the buffer contains the text.
public static final boolean isCharASCII(byte[] byteArray,
int index,
char car)
byteArray - The buffer which contains the dataindex - Current position in the buffercar - The character we want to compare with the current buffer
position
true if the current character equals the given
character.
public static final boolean isCharASCII(char[] chars,
int index,
char car)
chars - The buffer which contains the dataindex - Current position in the buffercar - The character we want to compare with the current buffer
position
true if the current character equals the given
character.
public static final boolean isCharASCII(String string,
int index,
char car)
string - The String which contains the dataindex - Current position in the stringcar - The character we want to compare with the current string
position
true if the current character equals the given
character.
public static final boolean isICharASCII(String string,
int index,
char car)
string - The String which contains the dataindex - Current position in the stringcar - The character we want to compare with the current string
position
true if the current character equals the given
character.
public static final boolean isICharASCII(byte[] bytes,
int index,
char car)
string - The String which contains the dataindex - Current position in the stringcar - The character we want to compare with the current string
position
true if the current character equals the given
character.
public static final boolean isBit(String string,
int index)
string - The String which contains the dataindex - Current position in the string
true if the current character is a bit (0 or 1)
public static final char charAt(String string,
int index)
string - The string which contains the dataindex - Current position in the string
public static byte getHexValue(char high,
char low)
high - The high valuelow - The low value
public static byte getHexValue(byte high,
byte low)
high - The high valuelow - The low value
public static byte getHexValue(char c)
c - The char we want to convert
public static final boolean isHex(byte[] bytes,
int index)
bytes - The buffer which contains the dataindex - Current position in the buffer
true if the current character is a Hex Char
public static final boolean isHex(char[] chars,
int index)
chars - The buffer which contains the dataindex - Current position in the buffer
true if the current character is a Hex Char
public static final boolean isHex(String string,
int index)
string - The string which contains the dataindex - Current position in the string
true if the current character is a Hex Charpublic static final boolean isDigit(byte[] bytes)
bytes - The buffer which contains the data
true if the current character is a Digitpublic static final boolean isDigit(char car)
car - the character to test
true if the character is a Digitpublic static final boolean isAlpha(byte c)
c - The byte to test
true if the byte is an Alpha
characterpublic static final boolean isAlpha(char c)
c - The char to test
true if the character is an Alpha
character
public static final boolean isAlphaASCII(byte[] bytes,
int index)
bytes - The buffer which contains the dataindex - Current position in the buffer
true if the current character is an Alpha
character
public static final boolean isAlphaASCII(char[] chars,
int index)
chars - The buffer which contains the dataindex - Current position in the buffer
true if the current character is an Alpha
character
public static final boolean isAlphaASCII(String string,
int index)
string - The string which contains the dataindex - Current position in the string
true if the current character is an Alpha
character
public static final boolean isAlphaLowercaseASCII(String string,
int index)
string - The string which contains the dataindex - Current position in the string
true if the current character is a lower Alpha
character
public static final boolean isAlphaUppercaseASCII(String string,
int index)
string - The string which contains the dataindex - Current position in the string
true if the current character is a lower Alpha
character
public static final boolean isDigit(byte[] bytes,
int index)
bytes - The buffer which contains the dataindex - Current position in the buffer
true if the current character is a Digit
public static final boolean isDigit(char[] chars,
int index)
chars - The buffer which contains the dataindex - Current position in the buffer
true if the current character is a Digit
public static final boolean isDigit(String string,
int index)
string - The string which contains the dataindex - Current position in the string
true if the current character is a Digitpublic static final boolean isDigit(char[] chars)
chars - The buffer which contains the data
true if the current character is a Digit
public static final boolean isAlphaDigit(String string,
int index)
string - The string which contains the dataindex - Current position in the string
public static final boolean isAlphaDigitMinus(byte[] bytes,
int index)
bytes - The buffer which contains the dataindex - Current position in the buffer
public static final boolean isAlphaDigitMinus(char[] chars,
int index)
chars - The buffer which contains the dataindex - Current position in the buffer
public static final boolean isAlphaDigitMinus(String string,
int index)
string - The string which contains the dataindex - Current position in the string
public static final boolean isEmpty(String str)
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 ") = false
NOTE: This method changed in Lang version 2.0. It no longer trims the String. That functionality is available in isBlank().
str - the String to check, may be null
true if the String is empty or nullpublic static final boolean isEmpty(byte[] bytes)
bytes - The bytes array to check, may be null
true if the bytes array is empty or nullpublic static final boolean isNotEmpty(String str)
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
str - the String to check, may be null
true if the String is not empty and not nullpublic static final String trim(String str)
Removes spaces (char <= 32) from both start and ends of this String,
handling null by returning null.
StringUtils.trim(null) = null
StringUtils.trim("") = ""
StringUtils.trim(" ") = ""
StringUtils.trim("abc") = "abc"
StringUtils.trim(" abc ") = "abc"
str - the String to be trimmed, may be null
null if null String inputpublic static final byte[] trim(byte[] bytes)
Removes spaces (char <= 32) from both start and ends of this bytes
array, handling null by returning null.
StringUtils.trim(null) = null
StringUtils.trim("") = ""
StringUtils.trim(" ") = ""
StringUtils.trim("abc") = "abc"
StringUtils.trim(" abc ") = "abc"
bytes - the byte array to be trimmed, may be null
public static final String trimLeft(String str)
Removes spaces (char <= 32) from start of this String, handling
null by returning null.
StringUtils.trimLeft(null) = null
StringUtils.trimLeft("") = ""
StringUtils.trimLeft(" ") = ""
StringUtils.trimLeft("abc") = "abc"
StringUtils.trimLeft(" abc ") = "abc "
str - the String to be trimmed, may be null
null if null String input
public static final int trimLeft(char[] chars,
int pos)
Removes spaces (char <= 32) from start of this array, handling
null by returning null.
StringUtils.trimLeft(null) = null
StringUtils.trimLeft("") = ""
StringUtils.trimLeft(" ") = ""
StringUtils.trimLeft("abc") = "abc"
StringUtils.trimLeft(" abc ") = "abc "
chars - the chars array to be trimmed, may be null
public static final void trimLeft(String string,
Position pos)
Removes spaces (char <= 32) from a position in this array, handling
null by returning null.
StringUtils.trimLeft(null) = null
StringUtils.trimLeft("",...) = ""
StringUtils.trimLeft(" ",...) = ""
StringUtils.trimLeft("abc",...) = "abc"
StringUtils.trimLeft(" abc ",...) = "abc "
string - the string to be trimmed, may be nullpos - The starting position
public static final void trimLeft(byte[] bytes,
Position pos)
Removes spaces (char <= 32) from a position in this array, handling
null by returning null.
StringUtils.trimLeft(null) = null
StringUtils.trimLeft("",...) = ""
StringUtils.trimLeft(" ",...) = ""
StringUtils.trimLeft("abc",...) = "abc"
StringUtils.trimLeft(" abc ",...) = "abc "
bytes - the byte array to be trimmed, may be nullpos - The starting position
public static final int trimLeft(byte[] bytes,
int pos)
Removes spaces (char <= 32) from start of this array, handling
null by returning null.
StringUtils.trimLeft(null) = null
StringUtils.trimLeft("") = ""
StringUtils.trimLeft(" ") = ""
StringUtils.trimLeft("abc") = "abc"
StringUtils.trimLeft(" abc ") = "abc "
bytes - the byte array to be trimmed, may be null
public static final String trimRight(String str)
Removes spaces (char <= 32) from end of this String, handling
null by returning null.
StringUtils.trimRight(null) = null
StringUtils.trimRight("") = ""
StringUtils.trimRight(" ") = ""
StringUtils.trimRight("abc") = "abc"
StringUtils.trimRight(" abc ") = " abc"
str - the String to be trimmed, may be null
null if null String input
public static final String trimRight(String str,
int escapedSpace)
Removes spaces (char <= 32) from end of this String, handling
null by returning null.
StringUtils.trimRight(null) = null
StringUtils.trimRight("") = ""
StringUtils.trimRight(" ") = ""
StringUtils.trimRight("abc") = "abc"
StringUtils.trimRight(" abc ") = " abc"
str - the String to be trimmed, may be nullescapedSpace - The last escaped space, if any
null if null String input
public static final int trimRight(char[] chars,
int pos)
Removes spaces (char <= 32) from end of this array, handling
null by returning null.
StringUtils.trimRight(null) = null
StringUtils.trimRight("") = ""
StringUtils.trimRight(" ") = ""
StringUtils.trimRight("abc") = "abc"
StringUtils.trimRight(" abc ") = " abc"
chars - the chars array to be trimmed, may be null
public static final String trimRight(String string,
Position pos)
Removes spaces (char <= 32) from end of this string, handling
null by returning null.
StringUtils.trimRight(null) = null
StringUtils.trimRight("") = ""
StringUtils.trimRight(" ") = ""
StringUtils.trimRight("abc") = "abc"
StringUtils.trimRight(" abc ") = " abc"
string - the string to be trimmed, may be null
public static final String trimRight(byte[] bytes,
Position pos)
Removes spaces (char <= 32) from end of this string, handling
null by returning null.
StringUtils.trimRight(null) = null
StringUtils.trimRight("") = ""
StringUtils.trimRight(" ") = ""
StringUtils.trimRight("abc") = "abc"
StringUtils.trimRight(" abc ") = " abc"
bytes - the byte array to be trimmed, may be null
public static final int trimRight(byte[] bytes,
int pos)
Removes spaces (char <= 32) from end of this array, handling
null by returning null.
StringUtils.trimRight(null) = null
StringUtils.trimRight("") = ""
StringUtils.trimRight(" ") = ""
StringUtils.trimRight("abc") = "abc"
StringUtils.trimRight(" abc ") = " abc"
bytes - the byte array to be trimmed, may be null
public static final String upperCase(String str)
Converts a String to upper case as per String.toUpperCase().
A null input String returns null.
StringUtils.upperCase(null) = null
StringUtils.upperCase("") = ""
StringUtils.upperCase("aBc") = "ABC"
str - the String to upper case, may be null
null if null String inputpublic static final String lowerCase(String str)
Converts a String to lower case as per String.toLowerCase().
A null input String returns null.
StringUtils.lowerCase(null) = null
StringUtils.lowerCase("") = ""
StringUtils.lowerCase("aBc") = "abc"
str - the String to lower case, may be null
null if null String inputpublic static final String lowerCaseAscii(String str)
str - The String to lowercase
public static final boolean equals(String str1,
String str2)
Compares two Strings, returning true if they are equal.
nulls are handled without exceptions. Two
null references 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
str1 - the first String, may be nullstr2 - the second String, may be null
true if the Strings are equal, case sensitive, or
both nullString.equals(Object)public static final String utf8ToString(byte[] bytes)
bytes - The byte array to be transformed to a String
public static final String utf8ToString(byte[] bytes,
int length)
bytes - The byte array to be transformed to a Stringlength - The length of the byte array to be converted
public static final String utf8ToString(byte[] bytes,
int start,
int length)
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
public static final byte[] getBytesUtf8(String string)
string - The string to be transformed to a byte array
public static final String listToString(List<?> list)
list - The list to transform to a string
public static final String setToString(Set<?> set)
set - The set to transform to a string
public static final String listToString(List<?> list,
String tabs)
list - The list to transform to a stringtabs - The tabs to add in ffront of the elements
public static final String mapToString(Map<?,?> map)
map - The map to transform to a string
public static final String mapToString(Map<?,?> map,
String tabs)
map - The map to transform to a stringtabs - The tabs to add in ffront of the elements
public static final String getDefaultCharsetName()
public static final String decodeHexString(String str)
throws InvalidNameException
str - the string to decode
InvalidNameException
public static final String decodeEscapedHex(String str)
throws InvalidNameException
str - the string containing hex escapes
InvalidNameException
public static final byte[] convertEscapedHex(String str)
throws InvalidNameException
str - the string containing hex escapes
InvalidNameException
public static int collectEscapedHexBytes(ByteBuffer bb,
String str,
int index)
bb - the buffer which will contain the unescaped bytestr - the initial string with ecaped charsindex - the position in the string of the escaped data
public static String asciiBytesToString(byte[] bytes)
bytes - The byte array to transform
public static String getType(byte[] bytes)
bytes - The bytes containing the AttributeType
public static boolean isIA5String(String str)
str - The String to check
true if the string is an IA5String or is empty,
false otherwisepublic static boolean isPrintableString(String str)
str - The String to check
true if the string is a PrintableString or is empty,
false otherwise
public static boolean isUnicodeSubset(String str,
int pos)
str - The string to checkpos - Position of the current char
public static boolean isUnicodeSubset(char c)
c - The char to check
public static String uuidToString(byte[] bytes)
bytes - bytes of a UUID
public static byte[] uuidToBytes(String string)
string - the string representation of an UUID
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||