|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jcorporate.expresso.core.misc.StringUtil
This is class that consists of static methods, utilities for
manipulations of java.lang.Strings.
| Field Summary | |
static String |
ELLIPSES
HTML code for ellipses (3 dots, like '...' as one character) used for appending to a truncate() line if necessary |
static String |
EMPTY_STRING
|
| Constructor Summary | |
StringUtil()
|
|
| Method Summary | |
static void |
assertBoolean(String theString,
String theMessage)
Throws an exception if theString can't be mapped to a boolean value. |
static void |
assertNotBlank(String theString,
String theMessage)
Make sure a string is not null. |
static String |
centerPad(String str,
int n)
enclosed the string with padding character. |
static String |
centerPad(String str,
int n,
String delim)
Enclosed the string with padding character author Henri Yves AMAIZO |
static Hashtable |
characterMap()
Map accent characters with equivalent without accent. |
static int |
compareDecimals(String decim1,
String decim2)
Compare 2 decimals string author Henri Yves AMAIZO |
static int |
compareIntegers(String int1,
String int2)
Compare 2 integers string. |
static String |
convertCommaToDot(String str)
Replace all comma by dot author Henri Yves AMAIZO |
static String |
convertDotToComma(String str)
Replace all dots byt comma author Henri Yves AMAIZO |
static String |
createWordWrappedString(String input)
Take an input string S, break the string into parts of N up to 72 characters long which word wrapped with respective to blank space characters and separated with the newline characters. |
static String |
createWordWrappedString(String input,
int fixedLength,
String delimiter)
Take an input string S, break the string into parts of N up to F characters long which word wrapped with respective to blank space characters and separated with the supplied delimiter D. |
protected static String |
getEntityRef(int ch)
Helper to xmlEscape() |
static String |
getStackTraceAsString(Throwable t)
A utility method to return an exception stacktrace as a String Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004 |
static boolean |
isAlphaNumeric(String s)
Check if string is alphanumeric or not. |
static boolean |
isAlphaNumeric(String str,
String otherChars)
Check if string is alphanumeric with addons chararcters or not. |
static boolean |
isBlankOrNull(String str)
Check if an input string is an empty string, just contains whitespace characters, or is null. |
static boolean |
isDecimal(String s)
Check if decimal number author Henri Yves AMAIZO |
static int |
isEmail(String email)
Check if string pass is a vlaid email address author Henri Yves AMAIZO |
static boolean |
isInteger(String str)
Check if integer string author Henri Yves AMAIZO |
static boolean |
isNumber(String str)
Check if number author Henri Yves AMAIZO |
static boolean |
isSiren(String siren)
Check French company siren number. |
static boolean |
isSiret(String siret)
Check French company siret number author Henri Yves AMAIZO |
static String |
join(String[] input)
Concatenate array of string into one string with constant delimiter ", "
Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004 |
static String |
join(String[] input,
String delimiter)
Concatenate array of string into one string with delimiter Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004 |
static String |
leftPad(String str,
int n)
Left padding padding character is space author Henri Yves AMAIZO |
static String |
leftPad(String str,
int n,
String delim)
Left padding author Henri Yves AMAIZO |
static void |
main(String[] args)
|
static String |
notNull(SerializableString theString)
Same thing but using a serializable string as the parameter instead |
static String |
notNull(String theString)
Make sure a string is not null. |
static String |
nullToEmpty(String s)
Return empty string if parameter is null author Henri Yves AMAIZO |
static String |
numberToLetter(int number,
boolean upperCaseFlag)
This method is useful for creating lists that use letters instead of numbers, such as a, b, c, d...instead of 1, 2, 3, 4. |
static String |
omitPackages(Class theclass)
utility to get just name of class |
static String |
omitPackages(Object obj)
utility to get just name of class |
protected static FastStringBuffer |
printEscaped(char ch,
FastStringBuffer fsb)
Formats a particular character to something workable in xml Helper to xmlEscape() |
static String |
random(int count)
Create a random string author Henri Yves AMAIZO |
static String |
random(int count,
boolean letters,
boolean numbers)
Create a random numeric string where you have control over size, and whether you want letters, numbers, or both. |
static String |
random(int count,
char[] set)
Create a random string author Henri Yves AMAIZO |
static String |
random(int count,
int start,
int end,
boolean letters,
boolean numbers)
Create a random numeric string where you have control over size, and whether you want letters, numbers, as well as ANSI minimum and maximum values of the characters. |
static String |
random(int count,
int start,
int end,
boolean letters,
boolean numbers,
char[] set)
Create a random numeric string where you have control over size, and whether you want letters, numbers, as well as ANSI minimum and maximum values of the characters. |
static String |
random(int count,
String set)
Create a random string author Henri Yves AMAIZO |
static String |
randomAlphabetic(int count)
Create a random character only string author Henri Yves AMAIZO |
static String |
randomAlphanumeric(int count)
Create a random alpha numeric string author Henri Yves AMAIZO |
static String |
randomAscii(int count)
Create a random Ascii String author Henri Yves AMAIZO |
static String |
randomNumeric(int count)
Create a random numeric string author Henri Yves AMAIZO |
static String |
reformatDecimalString(String str)
Reformat string by converting "," by "." |
static String |
removeAccents(String s)
Remove from the parameter the accent characters and return the remain string or null if empty author Henri Yves AMAIZO |
static String |
repeatString(String str,
int n)
Repeat str n time to format another string. |
static String |
replace(String s,
String sub,
String with)
replace substrings within string. |
static String |
replaceAll(String text,
String key,
String value)
Replace all occurences of key by value in text. |
static String |
replaceString(String text,
String str1,
String str2)
Substituate all occurence of str1 by str2 in text author Henri Yves AMAIZO |
static String |
replaceString(String text,
String str1,
String str2,
int max)
Replace n occurences of str1 in text by str2. |
static String |
replaceStringOnce(String text,
String str1,
String str2)
Substituate once str1 by str2 in text Commentaire Anglais author Henri Yves AMAIZO |
static String |
reverseString(String str)
Reverse the String. |
static String |
rightPad(String str,
int n)
Right padding delimiter is space author Henri Yves AMAIZO |
static String |
rightPad(String str,
int n,
String delim)
Right padding with delimiter author Henri Yves AMAIZO |
static boolean |
startsAndEnds(String s,
String search)
determine whether a string both starts and ends with the given substring |
static List |
string2List(String s)
Convert string to list author Henri Yves AMAIZO |
static List |
string2List(String s,
String sep)
Convert string to list using sep separator to divide author Henri Yves AMAIZO |
static List |
string2List(String s,
String sep,
int maxSize)
Convert string to list using sep separator to divide author Henri Yves AMAIZO |
static String |
substring(String str,
int lg)
return empty string the string is null author Henri Yves AMAIZO |
static String |
substring(String str,
int start,
int end)
return empty string the string is null author Henri Yves AMAIZO |
static String |
swapCase(String str)
Reverse the character case in the string author Henri Yves AMAIZO |
static boolean |
toBoolean(String theString)
parse a boolean value |
static String |
truncate(String str,
int len)
truncate a string at the given length if necessary, adding an ellipses at the end if truncation occurred; uses ELLIPSES static String from this class |
static String |
unquote(String s)
remove surrounding quote marks (either "" or ''), only if quotes are at both the beginning and end of the string |
static String |
unUpperFirstChar(String str)
convert the first character of string in lower case author Henri Yves AMAIZO |
static String |
upperFirstChar(String str)
convert the first character of the string upper case author Henri Yves AMAIZO |
static String |
xmlEscape(String s)
Formats the string to an XML/XHTML escaped character. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String EMPTY_STRING
public static final String ELLIPSES
| Constructor Detail |
public StringUtil()
| Method Detail |
public static final void assertNotBlank(String theString,
String theMessage)
theString - Any string, possibly nulltheMessage - The error message to use if the argument is not null.public static final String notNull(String theString)
theString - Any string, possibly null
public static final void assertBoolean(String theString,
String theMessage)
theString - the string to checktheMessage - the message to have in the IllegalArgumentException
if the conditions aren't met.public static final boolean toBoolean(String theString)
theString - the string to parse
public static String notNull(SerializableString theString)
theString - The string to check against null
public static String numberToLetter(int number,
boolean upperCaseFlag)
throws IllegalArgumentException
number - The number to convertupperCaseFlag - True if you want the final data to be uppercase
IllegalArgumentException
public static String replace(String s,
String sub,
String with)
s - The string to work withsub - The string to substitude the occurances ofwith - The string to replace with
public static String xmlEscape(String s)
s - the String to format
for example of original
code.
protected static FastStringBuffer printEscaped(char ch,
FastStringBuffer fsb)
ch - the character to print.fsb - The FastStringBuffer to add this to.
protected static String getEntityRef(int ch)
ch - the character to escape
public static String truncate(String str,
int len)
str - The string to processlen - The maximum length to process the string to.
public static Hashtable characterMap()
public static String removeAccents(String s)
s - the string to remove the accent characters
public static String convertCommaToDot(String str)
str - String to change
public static int compareDecimals(String decim1,
String decim2)
decim1 - First string to comparedecim2 - Second string to compare
public static int compareIntegers(String int1,
String int2)
int1 - first string to compareint2 - second string to compare
public static boolean isAlphaNumeric(String s)
s - String to check.
public static boolean isAlphaNumeric(String str,
String otherChars)
str - string to checkotherChars - extra characters to check with
public static boolean isBlankOrNull(String str)
null. If it is then
return true
str - the input string
public static boolean isDecimal(String s)
s - string to check.
public static int isEmail(String email)
email - string to check
public static boolean isInteger(String str)
str - string to check
public static boolean isNumber(String str)
str - to check
public static boolean isSiren(String siren)
siren - the company number
public static boolean isSiret(String siret)
siret - The siret number
public static String nullToEmpty(String s)
s - the parameter to check
public static String reformatDecimalString(String str)
str - string to reformat
public static String convertDotToComma(String str)
str - string to change
public static String replaceAll(String text,
String key,
String value)
text - string inkey - occurence to replacevalue - string to use
public static String replaceStringOnce(String text,
String str1,
String str2)
text - search and replace instr1 - to search forstr2 - to replace with
public static String replaceString(String text,
String str1,
String str2)
text - search and replace instr1 - search forstr2 - replace with
public static String replaceString(String text,
String str1,
String str2,
int max)
text - search and replace instr1 - search forstr2 - replace withmax - int values of occrrences to replace
public static List string2List(String s)
s - String comma delimited string to format
public static List string2List(String s,
String sep)
s - String comma delimited string to formatsep - a string containing the seprator characters
public static List string2List(String s,
String sep,
int maxSize)
s - String comma delimited string to formatsep - a string containing the seprator charactersmaxSize - the maximum size of the list
public static String unUpperFirstChar(String str)
str - String to un-upper case the first character
public static String upperFirstChar(String str)
str - String to make the first character upper.
public static String repeatString(String str,
int n)
str - String to repeatn - int n repeat
public static String centerPad(String str,
int n)
str - String str string to center paddingn - int n size of the new string
public static String centerPad(String str,
int n,
String delim)
str - String str string to pad withn - int n size of the final stringdelim - String delim padding character
public static String rightPad(String str,
int n,
String delim)
str - Stringn - int size of the final stringdelim - padding character
public static String rightPad(String str,
int n)
str - Stringn - int size of the new string
public static String leftPad(String str,
int n)
str - Stringn - int size of the new string
public static String leftPad(String str,
int n,
String delim)
str - Stringn - int size of the new stringdelim - padding character
public static String reverseString(String str)
str - the String to reverse.
public static String swapCase(String str)
str - String
public static String random(int count)
count - size of string.
public static String randomAscii(int count)
count - the size of the string
public static String randomAlphabetic(int count)
count - size of string
public static String randomAlphanumeric(int count)
count - the size of the string
public static String randomNumeric(int count)
count - the size of the final string
public static String random(int count,
boolean letters,
boolean numbers)
count - the size of the stringletters - true if you want letters includednumbers - true if you want numbers included
public static String random(int count,
int start,
int end,
boolean letters,
boolean numbers)
count - the size of the stringstart - int minimum 'value' of the characterend - maximum 'value' of the characterletters - true if you want letters includednumbers - true if you want numbers included
public static String random(int count,
int start,
int end,
boolean letters,
boolean numbers,
char[] set)
count - the size of the stringstart - int minimum 'value' of the characterend - maximum 'value' of the characterletters - true if you want letters includednumbers - true if you want numbers includedset - the set of possible characters that you're willing to let
the string contain. may be null if all values are open.
public static String random(int count,
String set)
count - the size of the stringset - the set of characters that are allowed
public static String random(int count,
char[] set)
count - the size of the stringset - the set of characters that are allowed
public static String substring(String str,
int lg)
str - The string to split Stringlg - the length to subgstring
public static String substring(String str,
int start,
int end)
str - The string to split Stringstart - the location to startend - the end location of the substring
public static String omitPackages(Object obj)
obj - the object of the given class, the name of which will be returned
public static String omitPackages(Class theclass)
theclass - the given class, the name of which will be returned
public static String getStackTraceAsString(Throwable t)
Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004
public static String join(String[] input)
", "
Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004
input - the input array string
public static String join(String[] input,
String delimiter)
Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004
input - the input array stringdelimiter - the delimiter
public static String createWordWrappedString(String input)
Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004
input - the input string
createWordWrappedString( String input, int fixedLength, String delimiter )
public static String createWordWrappedString(String input,
int fixedLength,
String delimiter)
Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004
input - the input stringfixedLength - the maximum fixed lengthdelimiter - the delimiter
public static void main(String[] args)
public static String unquote(String s)
s - string for testing
public static boolean startsAndEnds(String s,
String search)
s - string to look atsearch - substring to search for
|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||