jodd.util
Class CharUtil

java.lang.Object
  extended by jodd.util.CharUtil

public class CharUtil
extends java.lang.Object

Various character and character sequence utilities, including char[] - byte[] conversions.


Constructor Summary
CharUtil()
           
 
Method Summary
static boolean equalsOne(char c, char[] match)
          Match if one character equals to any of the given character.
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.
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.
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.
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.
static boolean isDigit(char c)
           
static boolean isLetter(char c)
           
static boolean isLetterOrDigit(char c)
           
static boolean isLowercaseLetter(char c)
          Returns true if specified character is lowercase ASCII.
static boolean isPropertyNameChar(char c)
           
static boolean isUppercaseLetter(char c)
          Returns true if specified character is uppercase ASCII.
static boolean isWhitespace(char c)
          Returns true if character is a white space (<= ' ').
static boolean isWordChar(char c)
           
static int toAscii(char c)
          Returns ASCII value of a char.
static byte[] toAsciiByteArray(char[] carr)
          Converts char array into ASCII array.
static byte[] toAsciiByteArray(java.lang.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, java.lang.String charset)
          Converts char array to byte array using provided encoding.
static char toChar(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, java.lang.String charset)
          Converts byte array of specific encoding to char array.
static char toLowerAscii(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(java.lang.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 char toUpperAscii(char c)
          Uppers lowercase ASCII char.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CharUtil

public CharUtil()
Method Detail

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

public static byte[] toSimpleByteArray(java.lang.CharSequence charSequence)
Converts char sequence into byte array.

See Also:
toSimpleByteArray(char[])

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 into ASCII array.


toAsciiByteArray

public static byte[] toAsciiByteArray(java.lang.CharSequence charSequence)
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)
                          throws java.io.UnsupportedEncodingException
Converts char array to byte array using default Jodd encoding.

Throws:
java.io.UnsupportedEncodingException

toByteArray

public static byte[] toByteArray(char[] carr,
                                 java.lang.String charset)
                          throws java.io.UnsupportedEncodingException
Converts char array to byte array using provided encoding.

Throws:
java.io.UnsupportedEncodingException

toCharArray

public static char[] toCharArray(byte[] barr)
                          throws java.io.UnsupportedEncodingException
Converts byte array of default Jodd encoding to char array.

Throws:
java.io.UnsupportedEncodingException

toCharArray

public static char[] toCharArray(byte[] barr,
                                 java.lang.String charset)
                          throws java.io.UnsupportedEncodingException
Converts byte array of specific encoding to char array.

Throws:
java.io.UnsupportedEncodingException

equalsOne

public static boolean equalsOne(char c,
                                char[] match)
Match if one character equals to any of the given character.

Returns:
true if characters match any character from given array, otherwise false

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)
Returns true if character is a white space (<= ' '). White space definition is taken from String class (see: trim()).


isLowercaseLetter

public static boolean isLowercaseLetter(char c)
Returns true if specified character is lowercase ASCII. If user uses only ASCIIs, it is much much faster.


isUppercaseLetter

public static boolean isUppercaseLetter(char c)
Returns true if specified character is uppercase ASCII. If user uses only ASCIIs, it is much much faster.


isLetter

public static boolean isLetter(char c)

isDigit

public static boolean isDigit(char c)

isLetterOrDigit

public static boolean isLetterOrDigit(char c)

isWordChar

public static boolean isWordChar(char c)

isPropertyNameChar

public static boolean isPropertyNameChar(char c)

toUpperAscii

public static char toUpperAscii(char c)
Uppers lowercase ASCII char.


toLowerAscii

public static char toLowerAscii(char c)
Lowers uppercase ASCII char.



Copyright © 2003-2012 Jodd Team