de.tomshut.util.text
Class CharSequenceUtil

java.lang.Object
  extended by de.tomshut.util.text.CharSequenceUtil

public class CharSequenceUtil
extends java.lang.Object


Field Summary
static char[] PSEUDO_BETA_CODE
           
 
Method Summary
static java.lang.CharSequence duration(long millis, boolean writeMillis)
           
static boolean isBasicLatinUppercase(java.lang.CharSequence seq)
          Checks if a char sequence contains only characters between 0x0020 (space) and 0x007E (~)
static boolean isDigits(java.lang.CharSequence str)
          Checks if all characters in the string are digits
static boolean isHex(java.lang.CharSequence str)
          Checks if all characters in the string may represent a hexadecimal literal
static boolean isLatin(java.lang.CharSequence seq)
          Checks if a char sequence contains only characters between 0x0020 (space) and 0x007E (~) as well as characters between 0x00A0 and 0x00FF
static boolean isLetters(java.lang.CharSequence str)
          Checks if all characters in the string are letters
static boolean isLettersOrDigits(java.lang.CharSequence str)
          Checks if all characters in the string are letters or digits
static java.lang.CharSequence makeLatin(java.lang.CharSequence seq)
          This method maps all characters which are not between 0x0020 (space) and 0x007E or between 0x00A0 and 0x00FF to values between 0x0020 and 0x007E by crude and/or bit operations.
static java.lang.CharSequence replaceJavaEscapeChars(java.lang.CharSequence str)
          Replaces java style escape characters in the string
static java.lang.CharSequence toBasicLatinUpperCase(java.lang.CharSequence seq)
          This method converts the given CharSequence to upper case and replaces supplement characters by their corresponding base characters.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PSEUDO_BETA_CODE

public static final char[] PSEUDO_BETA_CODE
Method Detail

isDigits

public static boolean isDigits(java.lang.CharSequence str)
Checks if all characters in the string are digits

Parameters:
str - the string to check
Returns:
true if all chars are digits, false otherwise
See Also:
CharacterUtil.isDigit(char)

isLetters

public static boolean isLetters(java.lang.CharSequence str)
Checks if all characters in the string are letters

Parameters:
str - the string to check
Returns:
true if all chars are letters, false otherwise
See Also:
CharacterUtil.isLetter(char)

isLettersOrDigits

public static boolean isLettersOrDigits(java.lang.CharSequence str)
Checks if all characters in the string are letters or digits

Parameters:
str - the string to check
Returns:
true if all chars are letters or digits, false otherwise
See Also:
CharacterUtil.isLetterOrDigit(char)

isLatin

public static boolean isLatin(java.lang.CharSequence seq)
Checks if a char sequence contains only characters between 0x0020 (space) and 0x007E (~) as well as characters between 0x00A0 and 0x00FF

Parameters:
seq - the sequence to check
Returns:
true if the sequence contains only characters between 0x0020 (space) and 0x007E (~) as well as characters between 0x00A0 and 0x00FF. false otherwise.

isBasicLatinUppercase

public static boolean isBasicLatinUppercase(java.lang.CharSequence seq)
Checks if a char sequence contains only characters between 0x0020 (space) and 0x007E (~)

Parameters:
seq - the sequence to check
Returns:
true if the sequence contains only characters between 0x0020 (space) and 0x007E (~). false otherwise.

isHex

public static boolean isHex(java.lang.CharSequence str)
Checks if all characters in the string may represent a hexadecimal literal

Parameters:
str - the string to check
Returns:
true if all chars are a-f, A-F, or digits, false otherwise
See Also:
CharacterUtil.isHexDigit(char)

replaceJavaEscapeChars

public static java.lang.CharSequence replaceJavaEscapeChars(java.lang.CharSequence str)
Replaces java style escape characters in the string

Parameters:
str - the string which may contain escaped characters
Returns:
the string with the replaced characters

makeLatin

public static java.lang.CharSequence makeLatin(java.lang.CharSequence seq)
This method maps all characters which are not between 0x0020 (space) and 0x007E or between 0x00A0 and 0x00FF to values between 0x0020 and 0x007E by crude and/or bit operations.

Only exceptions are Greek characters, which are converted using something similar to the Beta Code (using upper and lower case characters instead of upper case characters with optional stars and numbers...).

Parameters:
seq - the character sequence to make latin
Returns:
a character sequence containing only latin characters

toBasicLatinUpperCase

public static java.lang.CharSequence toBasicLatinUpperCase(java.lang.CharSequence seq)
This method converts the given CharSequence to upper case and replaces supplement characters by their corresponding base characters. It is defined for CharSequences containing characters between 0x0020 (space) and 0x007E (~) as well as characters between 0x00A0 and 0x00FF.

The method converts the characters in the given CharSequence by

All characters in the returned CharSequence are in the range 0x0020 to 0x005F.

Parameters:
seq - the string to be converted. Characters must be from 0x0020 to 0x007E and/or 0x00A0 to 0x00FF
Returns:
a CharSequence containing only characters from 0x0020 to 0x005F. If no conversion is necessary, the original String is returned

duration

public static java.lang.CharSequence duration(long millis,
                                              boolean writeMillis)