Package jodd.util
Class CharUtil
java.lang.Object
jodd.util.CharUtil
Various character and character sequence utilities, including
char[] - byte[] conversions.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanequalsOne(char c, char[] match) Match if one character equals to any of the given character.static intfindFirstDiff(char[] source, int index, char match) Finds index of the first character in given array the differs from the given set of characters.static intfindFirstDiff(char[] source, int index, char[] match) Finds index of the first character in given array the differs from the given set of characters.static intfindFirstEqual(char[] source, int index, char match) Finds index of the first character in given array the matches any from the given set of characters.static intfindFirstEqual(char[] source, int index, char[] match) Finds index of the first character in given array the matches any from the given set of characters.static inthex2int(char c) Converts hex char to int value.static charint2hex(int i) Converts integer digit to heck char.static booleanisAlpha(char c) Indicates whether the given character is in theALPHAset.static booleanisAlphaOrDigit(char c) static booleanisDigit(char c) Indicates whether the given character is in theDIGITset.static booleanisGenericDelimiter(int c) Indicates whether the given character is in the gen-delims set.static booleanisHexDigit(char c) Indicates whether the given character is the hexadecimal digit.static booleanisLowercaseAlpha(char c) Returnstrueif specified character is lowercase ASCII.static booleanisPchar(char c) Indicates whether the given character is in the pchar set.static booleanisPropertyNameChar(char c) static booleanisReserved(char c) Indicates whether the given character is in the reserved set.static booleanisSubDelimiter(int c) Indicates whether the given character is in the sub-delims set.static booleanisUnreserved(char c) Indicates whether the given character is in the unreserved set.static booleanisUppercaseAlpha(char c) Returnstrueif specified character is uppercase ASCII.static booleanisWhitespace(char c) Returnstrueif character is a white space (<= ' ').static booleanisWordChar(char c) static inttoAscii(char c) Returns ASCII value of a char.static byte[]toAsciiByteArray(char[] carr) Converts char array intoASCIIarray.static byte[]toAsciiByteArray(CharSequence charSequence) Converts char sequence into ASCII byte array.static byte[]toByteArray(char[] carr) Converts char array to byte array using default Jodd encoding.static byte[]toByteArray(char[] carr, Charset charset) Converts char array to byte array using provided encoding.static chartoChar(byte b) Converts (signed) byte to (unsigned) char.static char[]toCharArray(byte[] barr) Converts byte array of default Jodd encoding to char array.static char[]toCharArray(byte[] barr, Charset charset) Converts byte array of specific encoding to char array.static chartoLowerAscii(char c) Lowers uppercase ASCII char.static byte[]toRawByteArray(char[] carr) Converts char array into byte array by replacing each character with two bytes.static char[]toRawCharArray(byte[] barr) static byte[]toSimpleByteArray(char[] carr) Converts char array into byte array by stripping the high byte of each character.static byte[]toSimpleByteArray(CharSequence charSequence) Converts char sequence into byte array.static char[]toSimpleCharArray(byte[] barr) Converts byte array to char array by simply extending bytes to chars.static chartoUpperAscii(char c) Uppers lowercase ASCII char.
-
Field Details
-
HEX_CHARS
public static final char[] HEX_CHARS
-
-
Constructor Details
-
CharUtil
public CharUtil()
-
-
Method Details
-
toChar
public static char toChar(byte b) Converts (signed) byte to (unsigned) char. -
toSimpleByteArray
public static byte[] toSimpleByteArray(char[] carr) Converts char array into byte array by stripping the high byte of each character. -
toSimpleByteArray
Converts char sequence into byte array.- See Also:
-
toSimpleCharArray
public static char[] toSimpleCharArray(byte[] barr) Converts byte array to char array by simply extending bytes to chars. -
toAscii
public static int toAscii(char c) Returns ASCII value of a char. In case of overload, 0x3F is returned. -
toAsciiByteArray
public static byte[] toAsciiByteArray(char[] carr) Converts char array intoASCIIarray. -
toAsciiByteArray
Converts char sequence into ASCII byte array. -
toRawByteArray
public static byte[] toRawByteArray(char[] carr) Converts char array into byte array by replacing each character with two bytes. -
toRawCharArray
public static char[] toRawCharArray(byte[] barr) -
toByteArray
public static byte[] toByteArray(char[] carr) Converts char array to byte array using default Jodd encoding. -
toByteArray
Converts char array to byte array using provided encoding. -
toCharArray
public static char[] toCharArray(byte[] barr) Converts byte array of default Jodd encoding to char array. -
toCharArray
Converts byte array of specific encoding to char array. -
equalsOne
public static boolean equalsOne(char c, char[] match) Match if one character equals to any of the given character.- Returns:
trueif characters match any character from given array, otherwisefalse
-
findFirstEqual
public static int findFirstEqual(char[] source, int index, char[] match) Finds index of the first character in given array the matches any from the given set of characters.- Returns:
- index of matched character or -1
-
findFirstEqual
public static int findFirstEqual(char[] source, int index, char match) Finds index of the first character in given array the matches any from the given set of characters.- Returns:
- index of matched character or -1
-
findFirstDiff
public static int findFirstDiff(char[] source, int index, char[] match) Finds index of the first character in given array the differs from the given set of characters.- Returns:
- index of matched character or -1
-
findFirstDiff
public static int findFirstDiff(char[] source, int index, char match) Finds index of the first character in given array the differs from the given set of characters.- Returns:
- index of matched character or -1
-
isWhitespace
public static boolean isWhitespace(char c) Returnstrueif character is a white space (<= ' '). White space definition is taken from String class (see:trim()). This method has different results thenCharacter#isWhitespace." -
isLowercaseAlpha
public static boolean isLowercaseAlpha(char c) Returnstrueif specified character is lowercase ASCII. If user uses only ASCIIs, it is much much faster. -
isUppercaseAlpha
public static boolean isUppercaseAlpha(char c) Returnstrueif specified character is uppercase ASCII. If user uses only ASCIIs, it is much much faster. -
isAlphaOrDigit
public static boolean isAlphaOrDigit(char c) -
isWordChar
public static boolean isWordChar(char c) -
isPropertyNameChar
public static boolean isPropertyNameChar(char c) -
isAlpha
public static boolean isAlpha(char c) Indicates whether the given character is in theALPHAset.- See Also:
-
isDigit
public static boolean isDigit(char c) Indicates whether the given character is in theDIGITset.- See Also:
-
isHexDigit
public static boolean isHexDigit(char c) Indicates whether the given character is the hexadecimal digit. -
isGenericDelimiter
public static boolean isGenericDelimiter(int c) Indicates whether the given character is in the gen-delims set.- See Also:
-
isSubDelimiter
public static boolean isSubDelimiter(int c) Indicates whether the given character is in the sub-delims set.- See Also:
-
isReserved
public static boolean isReserved(char c) Indicates whether the given character is in the reserved set.- See Also:
-
isUnreserved
public static boolean isUnreserved(char c) Indicates whether the given character is in the unreserved set.- See Also:
-
isPchar
public static boolean isPchar(char c) Indicates whether the given character is in the pchar set.- See Also:
-
toUpperAscii
public static char toUpperAscii(char c) Uppers lowercase ASCII char. -
toLowerAscii
public static char toLowerAscii(char c) Lowers uppercase ASCII char. -
hex2int
public static int hex2int(char c) Converts hex char to int value. -
int2hex
public static char int2hex(int i) Converts integer digit to heck char.
-