| java.lang.Object nl.hippo.cms.spellchecking.StringUtils
StringUtils | public class StringUtils (Code) | | A collection of String handling utility methods.
Some of the methods available in this class have equivalents in the
java.lang.String class. However, the implementations
provided here are a lot faster, since they do not deal with character
internationalization issues.
author: Bruno Martins |
Method Summary | |
public static String | capitalizate(String str) Capitalizates a given String.
Parameters: str - A String. | public static String | capitalizate(String str, boolean accents) Capitalizates a given String.
Parameters: str - A String. | public static String | capitalizate(String str, boolean accents, boolean abbreviations) Trims and capitalizates a given String, with specific rules for
Portuguese words.
Parameters: str - A String. | public static int | count(String str, char c) Counts the occurrence of the given char in a String.
Parameters: str - The string to be tested. Parameters: c - the char to be counted. | public static StringUtils | getInstance() Return the single instance of this class. | public static char[] | getSpecialChars() Return an array with all the valid accented characters. | public static String | invertString(String s) Reverse a given String.
Parameters: s - The String to reverse. | public static boolean | isAccent(char chr) Checks if a given character has diacritics. | public static boolean | isAlphaNumeric(char c) Tests whether a given character is alphabetic, numeric or the
hyphen character.
Parameters: c - The character to be tested. | public static boolean | isCapitalizated(String str) Checks if a given String is capitalizated.
Parameters: str - A String. | public static boolean | isUpperCase(char chr) Checks if a given character is uppercase. | final public static boolean | isVowel(String in, int at) Checks if the character at a given position of a given string is a vowel.
The Y character is also considered.
TODO: Should portuguese accented characters be considered vowels?
Parameters: in - A String. Parameters: at - The position in the String. | public static boolean | isVowel(String in, int at, int length) Checks if the character at a given position of a given string is a vowel
The Y character is also considered.
TODO: Should portuguese accented characters be considered vowels?
Parameters: in - A String. Parameters: at - The position in the String. Parameters: length - The maximum lengh of the String to check. | public static int | matchStrings(String a, String b) Matches two strings.
Parameters: a - The first string. Parameters: b - The second string. | public static String | replace(String source, String search, String replace) Returns a new string resulting from replacing all occurrences of the
String search in the String source, with the string replace. | public static char | replaceAccent(char chr) Replaces accented characters with their variations without
the diacritics.
TODO: add more non-Portuguese diacritic characters. | public static String | separateNumberWithDots(String n) Takes a numeric string and separates groups of 3 characters
with a '.' character. | public static String | separateNumberWithDots(String n, int s) Takes a numeric string and separates groups of "n" characters
with a '.' character. | public static String | toLowerCase(String str, boolean accents) Converts all of the characters in a given String to lower case. |
capitalizate | public static String capitalizate(String str)(Code) | | Capitalizates a given String.
Parameters: str - A String. The capitalizated String. |
capitalizate | public static String capitalizate(String str, boolean accents)(Code) | | Capitalizates a given String.
Parameters: str - A String. The capitalizated String. |
capitalizate | public static String capitalizate(String str, boolean accents, boolean abbreviations)(Code) | | Trims and capitalizates a given String, with specific rules for
Portuguese words.
Parameters: str - A String. The capitalizated String. |
count | public static int count(String str, char c)(Code) | | Counts the occurrence of the given char in a String.
Parameters: str - The string to be tested. Parameters: c - the char to be counted. the frequency of occurrence for the character in the String. |
getInstance | public static StringUtils getInstance()(Code) | | Return the single instance of this class.
An instance of StringUtils . |
getSpecialChars | public static char[] getSpecialChars()(Code) | | Return an array with all the valid accented characters.
TODO: add more non-Portuguese diacritic characters.
An array with all the valid accented characters. |
invertString | public static String invertString(String s)(Code) | | Reverse a given String.
Parameters: s - The String to reverse. The reversed string. |
isAccent | public static boolean isAccent(char chr)(Code) | | Checks if a given character has diacritics. For instance,
isAccent('a') would return false, whereas isAccent('รก') would return true.
Parameters: chr - the char to check. true if the character has a diacritic and false otherwise. |
isAlphaNumeric | public static boolean isAlphaNumeric(char c)(Code) | | Tests whether a given character is alphabetic, numeric or the
hyphen character.
Parameters: c - The character to be tested. whether the given character is alphameric or not. |
isCapitalizated | public static boolean isCapitalizated(String str)(Code) | | Checks if a given String is capitalizated.
Parameters: str - A String. true if the given String is capitalizated and false otherwise. |
isUpperCase | public static boolean isUpperCase(char chr)(Code) | | Checks if a given character is uppercase. For instance,
isUpperCase('a') would return false, whereas isUpperCase('A') would return true.
Parameters: chr - the char to check. true if the character is uppercase and false otherwise. |
isVowel | final public static boolean isVowel(String in, int at)(Code) | | Checks if the character at a given position of a given string is a vowel.
The Y character is also considered.
TODO: Should portuguese accented characters be considered vowels?
Parameters: in - A String. Parameters: at - The position in the String. true if the the character at position at of the string in is a voweland false otherwise. |
isVowel | public static boolean isVowel(String in, int at, int length)(Code) | | Checks if the character at a given position of a given string is a vowel
The Y character is also considered.
TODO: Should portuguese accented characters be considered vowels?
Parameters: in - A String. Parameters: at - The position in the String. Parameters: length - The maximum lengh of the String to check. true if the the character at position at of the string in is a voweland false otherwise. |
matchStrings | public static int matchStrings(String a, String b)(Code) | | Matches two strings.
Parameters: a - The first string. Parameters: b - The second string. the index where the two strings stop matching starting from 0. |
replace | public static String replace(String source, String search, String replace)(Code) | | Returns a new string resulting from replacing all occurrences of the
String search in the String source, with the string replace.
Parameters: source - The original String. Parameters: search - The string to be replaces. Parameters: replace - The replacement String. The resulting String. |
replaceAccent | public static char replaceAccent(char chr)(Code) | | Replaces accented characters with their variations without
the diacritics.
TODO: add more non-Portuguese diacritic characters.
Parameters: chr - the character to check. The character without the diacritic. |
separateNumberWithDots | public static String separateNumberWithDots(String n)(Code) | | Takes a numeric string and separates groups of 3 characters
with a '.' character. For instance separateNumberWithDots(n)
would return "1.000".
Parameters: n - A numeric String. The resulting String. |
separateNumberWithDots | public static String separateNumberWithDots(String n, int s)(Code) | | Takes a numeric string and separates groups of "n" characters
with a '.' character. For instance separateNumberWithDots(n,3)
would return "1.000"
Parameters: n - A numeric String. Parameters: s - The number of characters to group. The resulting String. |
toLowerCase | public static String toLowerCase(String str, boolean accents)(Code) | | Converts all of the characters in a given String to lower case.
Parameters: str - A String. Parameters: accents - if true, then besides converting the string to lower caseaccented characters are also replaces with their versions without the diacritics. The resulting String. |
|
|