org.cruxframework.crux.core.client.utils
Class StringUtils

java.lang.Object
  extended by org.cruxframework.crux.core.client.utils.StringUtils

public class StringUtils
extends Object

Author:
Gesse S. F. Dafe, Thiago da Rosa de Bustamante, Samuel Almeida Cardoso (samuel@cruxframework.org)

Nested Class Summary
static interface StringUtils.Collator
           
static class StringUtils.CollatorFFandIE
           
static class StringUtils.CollatorSafari
           
 
Constructor Summary
StringUtils()
           
 
Method Summary
static int charCodeAt(String str, int i)
           
static boolean containsValue(String multiValuedProperty, String value)
           
static boolean equals(String a, String b)
          This method generates a faster string comparison than String.equals() for web mode code.
static int getLevenshteinDistance(String s, String t)
          Find the Levenshtein distance between two Strings.
static boolean isEmpty(String value)
           
static boolean isNumeric(String str)
           
static boolean isWhitespace(char c)
           
static int localeCompare(String source, String target)
           
static int localeCompare(String source, String target, boolean caseSensitive)
           
static String lpad(String src, int length, char padding)
           
static String removeAccents(String value)
           
static String replace(String text, String searchString, String replacement)
           
static String replace(String text, String searchString, String replacement, int max)
           
static String rpad(String src, int length, char padding)
           
static String rTrim(String value)
           
static double safeParseDouble(String value)
           
static String toHEXString(String input)
          Convert a raw UTF-8 string to a hex string.
static String toUpperCaseFirstChar(String text)
          Transforms "some text" into "Some text"
static String toUTF8(String utf16String)
          Encode an UTF-16 string (Unicode) to UTF-8.
static boolean unsafeEquals(String a, String b)
          This method generate a faster string comparison than String.equals() for web mode code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUtils

public StringUtils()
Method Detail

localeCompare

public static int localeCompare(String source,
                                String target)

localeCompare

public static int localeCompare(String source,
                                String target,
                                boolean caseSensitive)

removeAccents

public static String removeAccents(String value)

lpad

public static String lpad(String src,
                          int length,
                          char padding)
Parameters:
src -
length -
padding -
Returns:

rpad

public static String rpad(String src,
                          int length,
                          char padding)
Parameters:
src -
length -
padding -
Returns:

isEmpty

public static boolean isEmpty(String value)
Parameters:
value -
Returns:

replace

public static String replace(String text,
                             String searchString,
                             String replacement)
Parameters:
text -
searchString -
replacement -
Returns:

replace

public static String replace(String text,
                             String searchString,
                             String replacement,
                             int max)
Parameters:
text -
searchString -
replacement -
max -
Returns:

toUpperCaseFirstChar

public static String toUpperCaseFirstChar(String text)
Transforms "some text" into "Some text"

Parameters:
text -
Returns:

equals

public static boolean equals(String a,
                             String b)
This method generates a faster string comparison than String.equals() for web mode code. The GWT generated String.equals() method makes a check in its parameter's type in runtime. That method makes that assertion on compilation time (once its parameters are both Strings).

Parameters:
a -
b -
Returns:

unsafeEquals

public static boolean unsafeEquals(String a,
                                   String b)
This method generate a faster string comparison than String.equals() for web mode code. It is similar to StringUtils.equals() method. The only difference is that this one does not check for null parameters.

Parameters:
a -
b -
Returns:

safeParseDouble

public static double safeParseDouble(String value)
Parameters:
value -
Returns:

containsValue

public static boolean containsValue(String multiValuedProperty,
                                    String value)
Parameters:
multiValuedProperty -
value -
Returns:

rTrim

public static String rTrim(String value)

isWhitespace

public static boolean isWhitespace(char c)

getLevenshteinDistance

public static int getLevenshteinDistance(String s,
                                         String t)

Find the Levenshtein distance between two Strings.

 StringUtils.getLevenshteinDistance(null, *)             = IllegalArgumentException
 StringUtils.getLevenshteinDistance(*, null)             = IllegalArgumentException
 StringUtils.getLevenshteinDistance("","")               = 0
 StringUtils.getLevenshteinDistance("","a")              = 1
 StringUtils.getLevenshteinDistance("aaapppp", "")       = 7
 StringUtils.getLevenshteinDistance("frog", "fog")       = 1
 StringUtils.getLevenshteinDistance("fly", "ant")        = 3
 StringUtils.getLevenshteinDistance("elephant", "hippo") = 7
 StringUtils.getLevenshteinDistance("hippo", "elephant") = 7
 StringUtils.getLevenshteinDistance("hippo", "zzzzzzzz") = 8
 StringUtils.getLevenshteinDistance("hello", "hallo")    = 1
 

Parameters:
s - the first String, must not be null
t - the second String, must not be null
Returns:
result distance
Throws:
IllegalArgumentException - if either String input null

isNumeric

public static boolean isNumeric(String str)

charCodeAt

public static int charCodeAt(String str,
                             int i)

toUTF8

public static String toUTF8(String utf16String)
Encode an UTF-16 string (Unicode) to UTF-8. DOM Strings are UTF-16 by default

Parameters:
utf16String -
Returns:
utf-8 encoded string

toHEXString

public static String toHEXString(String input)
Convert a raw UTF-8 string to a hex string.

Parameters:
input -
Returns:


Copyright © 2014. All rights reserved.