| java.lang.Object com.jcorporate.expresso.core.misc.StringUtil
StringUtil | final public class StringUtil (Code) | | This is class that consists of static methods, utilities for
manipulations of java.lang.String s.
author: Michael Nash, Peter Pilgrim, Henri Yves AMAIZO |
Method Summary | |
final public static void | assertBoolean(String theString, String theMessage) Throws an exception if theString can't be mapped to a boolean value. | final public static void | assertNotBlank(String theString, String theMessage) Make sure a string is not null. | public static String | centerPad(String str, int n) enclosed the string with padding character. | public static String | centerPad(String str, int n, String delim) | public static Hashtable | characterMap() Map accent characters with equivalent without accent. | public static int | compareDecimals(String decim1, String decim2) | public static int | compareIntegers(String int1, String int2) Compare 2 integers string. | public static String | convertCommaToDot(String str) | public static String | convertDotToComma(String str) | public 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. | public 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) | public static String | getStackTraceAsString(Throwable t) | public static boolean | isAlphaNumeric(String s) Check if string is alphanumeric or not.
author Henri Yves AMAIZO
Parameters: s - String to check. | public static boolean | isAlphaNumeric(String str, String otherChars) Check if string is alphanumeric with addons chararcters or not. | public static boolean | isBlankOrNull(String str) Check if an input string is an empty string, just contains
whitespace characters, or is null . | public static boolean | isDecimal(String s) Check if decimal number
author Henri Yves AMAIZO
Parameters: s - string to check. | public static int | isEmail(String email) | public static boolean | isInteger(String str) | public static boolean | isNumber(String str) | public static boolean | isSiren(String siren) Check French company siren number. | public static boolean | isSiret(String siret) | public static String | join(String[] input) | public static String | join(String[] input, String delimiter) | public static String | leftPad(String str, int n) | public static String | leftPad(String str, int n, String delim) | public static void | main(String args) | final public static String | notNull(String theString) Make sure a string is not null. | public static String | notNull(SerializableString theString) | public static String | nullToEmpty(String s) | public 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. | public static String | omitPackages(Object obj) | public static String | omitPackages(Class theclass) | protected static FastStringBuffer | printEscaped(char ch, FastStringBuffer fsb) Formats a particular character to something workable in xml Helper to xmlEscape()
Parameters: ch - the character to print. Parameters: fsb - The FastStringBuffer to add this to. | public static String | random(int count) Create a random string
author Henri Yves AMAIZO
Parameters: count - size of string. | public 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. | public 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. | public 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.
author Henri Yves AMAIZO
Parameters: count - the size of the string Parameters: start - int minimum 'value' of the character Parameters: end - maximum 'value' of the character Parameters: letters - true if you want letters included Parameters: numbers - true if you want numbers included Parameters: set - the set of possible characters that you're willing to letthe string contain. | public static String | random(int count, String set) | public static String | random(int count, char[] set) | public static String | randomAlphabetic(int count) | public static String | randomAlphanumeric(int count) | public static String | randomAscii(int count) | public static String | randomNumeric(int count) | public static String | reformatDecimalString(String str) | public static String | removeAccents(String s) | public static String | repeatString(String str, int n) Repeat str n time to format another string. | public static String | replace(String s, String sub, String with) replace substrings within string. | public static String | replaceAll(String text, String key, String value) Replace all occurences of key by value in text. | public static String | replaceString(String text, String str1, String str2) | public static String | replaceString(String text, String str1, String str2, int max) Replace n occurences of str1 in text by str2. | public static String | replaceStringOnce(String text, String str1, String str2) | public static String | reverseString(String str) Reverse the String.
Parameters: str - the String to reverse. | public static String | rightPad(String str, int n, String delim) | public static String | rightPad(String str, int n) | public static boolean | startsAndEnds(String s, String search) | public static List | string2List(String s) | public static List | string2List(String s, String sep) | public static List | string2List(String s, String sep, int maxSize) | public static String | substring(String str, int lg) | public static String | substring(String str, int start, int end) | public static String | swapCase(String str) | final public static boolean | toBoolean(String theString) | public 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
Parameters: str - The string to process Parameters: len - The maximum length to process the string to. | public static String | unUpperFirstChar(String str) | public static String | unquote(String s) | public static String | upperFirstChar(String str) convert the first character of the string upper case
author Henri Yves AMAIZO
Parameters: str - String to make the first character upper. | public static String | xmlEscape(String s) Formats the string to an XML/XHTML escaped character. |
ELLIPSES | final public static String ELLIPSES(Code) | | HTML code for ellipses (3 dots, like '...' as one character)
used for appending to a truncate() line if necessary
|
assertBoolean | final public static void assertBoolean(String theString, String theMessage)(Code) | | Throws an exception if theString can't be mapped to a boolean value.
Parameters: theString - the string to check Parameters: theMessage - the message to have in the IllegalArgumentExceptionif the conditions aren't met. |
assertNotBlank | final public static void assertNotBlank(String theString, String theMessage)(Code) | | Make sure a string is not null. This is a convenience method, but it
is not necessarily recommended if you do a lot of processing for theMessage
parameter. It is recommended that you assertNotBlank, catch IllegalArgumentException
and then throw an appropriate exception with your message.
Parameters: theString - Any string, possibly null Parameters: theMessage - The error message to use if the argument is not null. |
centerPad | public static String centerPad(String str, int n)(Code) | | enclosed the string with padding character.
Space is padding character
author Henri Yves AMAIZO
Parameters: str - String str string to center padding Parameters: n - int n size of the new string String Result |
centerPad | public static String centerPad(String str, int n, String delim)(Code) | | Enclosed the string with padding character
author Henri Yves AMAIZO
Parameters: str - String str string to pad with Parameters: n - int n size of the final string Parameters: delim - String delim padding character String result of the center padding |
characterMap | public static Hashtable characterMap()(Code) | | Map accent characters with equivalent without accent.
author Henri Yves AMAIZO
Hashtable Character mapping table. |
compareDecimals | public static int compareDecimals(String decim1, String decim2)(Code) | | Compare 2 decimals string
author Henri Yves AMAIZO
Parameters: decim1 - First string to compare Parameters: decim2 - Second string to compare int return 1 if decim1 > decim2 retourne 0 if decim1 == decim2 return -1 if decim1 < decim2 |
compareIntegers | public static int compareIntegers(String int1, String int2)(Code) | | Compare 2 integers string.
author Henri Yves AMAIZO
Parameters: int1 - first string to compare Parameters: int2 - second string to compare int return 1 if decim1 > decim2 return 0 if decim1 == decim2 return -1 if decim1 < decim2 |
convertCommaToDot | public static String convertCommaToDot(String str)(Code) | | Replace all comma by dot
author Henri Yves AMAIZO
Parameters: str - String to change String The result of substitution |
convertDotToComma | public static String convertDotToComma(String str)(Code) | | Replace all dots byt comma
author Henri Yves AMAIZO
Parameters: str - string to change String reformatted |
createWordWrappedString | public static String createWordWrappedString(String input)(Code) | | 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. This static call has parameters set up for
electronic mail standards.
Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004
Parameters: input - the input string wrapped broken string See Also: StringUtil.createWordWrappedString(String input,int fixedLength,String delimiter) |
createWordWrappedString | public static String createWordWrappedString(String input, int fixedLength, String delimiter)(Code) | | 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.
Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004
Parameters: input - the input string Parameters: fixedLength - the maximum fixed length Parameters: delimiter - the delimiter wrapped broken string |
getEntityRef | protected static String getEntityRef(int ch)(Code) | | Helper to xmlEscape()
Parameters: ch - the character to escape A modified string representing the tanlation of the characteror null if there is no translation for it. |
getStackTraceAsString | public static String getStackTraceAsString(Throwable t)(Code) | | A utility method to return an exception stacktrace as a String
Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004
|
isAlphaNumeric | public static boolean isAlphaNumeric(String s)(Code) | | Check if string is alphanumeric or not.
author Henri Yves AMAIZO
Parameters: s - String to check. boolean true if alphanumeric, false if not. |
isAlphaNumeric | public static boolean isAlphaNumeric(String str, String otherChars)(Code) | | Check if string is alphanumeric with addons chararcters or not.
author Henri Yves AMAIZO
Parameters: str - string to check Parameters: otherChars - extra characters to check with boolean true if parameter string contains only alpha numerics, plus addons characters and false if not. |
isBlankOrNull | public static boolean isBlankOrNull(String str)(Code) | | Check if an input string is an empty string, just contains
whitespace characters, or is null . If it is then
return true
Parameters: str - the input string boolean true if the string is blank or null |
isDecimal | public static boolean isDecimal(String s)(Code) | | Check if decimal number
author Henri Yves AMAIZO
Parameters: s - string to check. boolean true if the value is decimal number false if not |
isEmail | public static int isEmail(String email)(Code) | | Check if string pass is a vlaid email address
author Henri Yves AMAIZO
Parameters: email - string to check int 0 if valid address, 1 more than 2 tokens (".", "@") and 2 if the second token is not "." . |
isInteger | public static boolean isInteger(String str)(Code) | | Check if integer string
author Henri Yves AMAIZO
Parameters: str - string to check boolean true if all characters is digit |
isNumber | public static boolean isNumber(String str)(Code) | | Check if number
author Henri Yves AMAIZO
Parameters: str - to check boolean |
isSiren | public static boolean isSiren(String siren)(Code) | | Check French company siren number.
author Henri Yves AMAIZO
Parameters: siren - the company number boolean true if ok. |
isSiret | public static boolean isSiret(String siret)(Code) | | Check French company siret number
author Henri Yves AMAIZO
Parameters: siret - The siret number boolean true if equivalent to siret number false if not. |
join | public static String join(String[] input)(Code) | | Concatenate array of string into one string with constant delimiter ", "
Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004
Parameters: input - the input array string the joined string |
join | public static String join(String[] input, String delimiter)(Code) | | Concatenate array of string into one string with delimiter
Written by Peter Pilgrim Mon Mar 15 23:12:15 GMT 2004
Parameters: input - the input array string Parameters: delimiter - the delimiter the joined string |
leftPad | public static String leftPad(String str, int n)(Code) | | Left padding
padding character is space
author Henri Yves AMAIZO
Parameters: str - String Parameters: n - int size of the new string String |
leftPad | public static String leftPad(String str, int n, String delim)(Code) | | Left padding
author Henri Yves AMAIZO
Parameters: str - String Parameters: n - int size of the new string Parameters: delim - padding character String result |
notNull | final public static String notNull(String theString)(Code) | | Make sure a string is not null.
Parameters: theString - Any string, possibly null An empty string if the original was null, else the original |
notNull | public static String notNull(SerializableString theString)(Code) | | Same thing but using a serializable string as the parameter instead
Parameters: theString - The string to check against null theString or an empty string if it is null |
nullToEmpty | public static String nullToEmpty(String s)(Code) | | Return empty string if parameter is null
author Henri Yves AMAIZO
Parameters: s - the parameter to check String return the parameter if empty or if the string == null |
numberToLetter | public static String numberToLetter(int number, boolean upperCaseFlag) throws IllegalArgumentException(Code) | | 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.
Valid numbers are from 1 to 26, corresponding to the 26 letters of the alphabet.
By default, the letter is returned as a lowercase, but if the boolean
upperCaseFlag is true, the letter will be returned as an uppercase.
Creation date: (5/11/00 12:52:23 PM)
author: Adam Rossi
Parameters: number - The number to convert Parameters: upperCaseFlag - True if you want the final data to be uppercase java.lang.String |
omitPackages | public static String omitPackages(Object obj)(Code) | | utility to get just name of class
Parameters: obj - the object of the given class, the name of which will be returned name of class, less any package prefix |
omitPackages | public static String omitPackages(Class theclass)(Code) | | utility to get just name of class
Parameters: theclass - the given class, the name of which will be returned name of class, less any package prefix |
printEscaped | protected static FastStringBuffer printEscaped(char ch, FastStringBuffer fsb)(Code) | | Formats a particular character to something workable in xml Helper to xmlEscape()
Parameters: ch - the character to print. Parameters: fsb - The FastStringBuffer to add this to. a FastStringBuffer that is modified |
random | public static String random(int count)(Code) | | Create a random string
author Henri Yves AMAIZO
Parameters: count - size of string. randomly generated string of size count |
random | public static String random(int count, boolean letters, boolean numbers)(Code) | | Create a random numeric string where you have control over size, and
whether you want letters, numbers, or both.
author Henri Yves AMAIZO
Parameters: count - the size of the string Parameters: letters - true if you want letters included Parameters: numbers - true if you want numbers included randomly generated string of size count |
random | public static String random(int count, int start, int end, boolean letters, boolean numbers)(Code) | | 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.
author Henri Yves AMAIZO
Parameters: count - the size of the string Parameters: start - int minimum 'value' of the character Parameters: end - maximum 'value' of the character Parameters: letters - true if you want letters included Parameters: numbers - true if you want numbers included randomly generated string of size count |
random | public static String random(int count, int start, int end, boolean letters, boolean numbers, char[] set)(Code) | | 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.
author Henri Yves AMAIZO
Parameters: count - the size of the string Parameters: start - int minimum 'value' of the character Parameters: end - maximum 'value' of the character Parameters: letters - true if you want letters included Parameters: numbers - true if you want numbers included Parameters: set - the set of possible characters that you're willing to letthe string contain. may be null if all values are open. randomly generated string of size count |
random | public static String random(int count, String set)(Code) | | Create a random string
author Henri Yves AMAIZO
Parameters: count - the size of the string Parameters: set - the set of characters that are allowed randomly generated string of size count |
random | public static String random(int count, char[] set)(Code) | | Create a random string
author Henri Yves AMAIZO
Parameters: count - the size of the string Parameters: set - the set of characters that are allowed randomly generated string of size count |
randomAlphabetic | public static String randomAlphabetic(int count)(Code) | | Create a random character only string
author Henri Yves AMAIZO
Parameters: count - size of string randomly generated string of size count |
randomAlphanumeric | public static String randomAlphanumeric(int count)(Code) | | Create a random alpha numeric string
author Henri Yves AMAIZO
Parameters: count - the size of the string randomly generated string of size count |
randomAscii | public static String randomAscii(int count)(Code) | | Create a random Ascii String
author Henri Yves AMAIZO
Parameters: count - the size of the string randomly generated string of size count |
randomNumeric | public static String randomNumeric(int count)(Code) | | Create a random numeric string
author Henri Yves AMAIZO
Parameters: count - the size of the final string randomly generated string of size count |
reformatDecimalString | public static String reformatDecimalString(String str)(Code) | | Reformat string by converting "," by "."
author Henri Yves AMAIZO
Parameters: str - string to reformat String return reformatted string. |
removeAccents | public static String removeAccents(String s)(Code) | | Remove from the parameter the accent characters and
return the remain string or null if empty
author Henri Yves AMAIZO
Parameters: s - the string to remove the accent characters String |
repeatString | public static String repeatString(String str, int n)(Code) | | Repeat str n time to format another string.
author Henri Yves AMAIZO
Parameters: str - String to repeat Parameters: n - int n repeat String |
replace | public static String replace(String s, String sub, String with)(Code) | | replace substrings within string.
Parameters: s - The string to work with Parameters: sub - The string to substitude the occurances of Parameters: with - The string to replace with A processed java.util.String |
replaceAll | public static String replaceAll(String text, String key, String value)(Code) | | Replace all occurences of key by value in text.
author Henri Yves AMAIZO
Parameters: text - string in Parameters: key - occurence to replace Parameters: value - string to use String with the replace value |
replaceString | public static String replaceString(String text, String str1, String str2)(Code) | | Substituate all occurence of str1 by str2 in text
author Henri Yves AMAIZO
Parameters: text - search and replace in Parameters: str1 - search for Parameters: str2 - replace with String with all values replaced |
replaceString | public static String replaceString(String text, String str1, String str2, int max)(Code) | | Replace n occurences of str1 in text by str2.
if n = -1 all occurrences are replaced
author Henri Yves AMAIZO
Parameters: text - search and replace in Parameters: str1 - search for Parameters: str2 - replace with Parameters: max - int values of occrrences to replace String replaced |
replaceStringOnce | public static String replaceStringOnce(String text, String str1, String str2)(Code) | | Substituate once str1 by str2 in text
Commentaire Anglais
author Henri Yves AMAIZO
Parameters: text - search and replace in Parameters: str1 - to search for Parameters: str2 - to replace with String replaced |
reverseString | public static String reverseString(String str)(Code) | | Reverse the String.
Parameters: str - the String to reverse. a reversed string |
rightPad | public static String rightPad(String str, int n, String delim)(Code) | | Right padding with delimiter
author Henri Yves AMAIZO
Parameters: str - String Parameters: n - int size of the final string Parameters: delim - padding character String padding string |
rightPad | public static String rightPad(String str, int n)(Code) | | Right padding
delimiter is space
author Henri Yves AMAIZO
Parameters: str - String Parameters: n - int size of the new string String |
startsAndEnds | public static boolean startsAndEnds(String s, String search)(Code) | | determine whether a string both starts and ends with the given substring
Parameters: s - string to look at Parameters: search - substring to search for true if string is surrounded by search string |
string2List | public static List string2List(String s)(Code) | | Convert string to list
author Henri Yves AMAIZO
Parameters: s - String comma delimited string to format List |
string2List | public static List string2List(String s, String sep)(Code) | | Convert string to list using sep separator to divide
author Henri Yves AMAIZO
Parameters: s - String comma delimited string to format Parameters: sep - a string containing the seprator characters List |
string2List | public static List string2List(String s, String sep, int maxSize)(Code) | | Convert string to list using sep separator to divide
author Henri Yves AMAIZO
Parameters: s - String comma delimited string to format Parameters: sep - a string containing the seprator characters Parameters: maxSize - the maximum size of the list List |
substring | public static String substring(String str, int lg)(Code) | | return empty string the string is null
author Henri Yves AMAIZO
Parameters: str - The string to split String Parameters: lg - the length to subgstring a substring of parameter str. |
substring | public static String substring(String str, int start, int end)(Code) | | return empty string the string is null
author Henri Yves AMAIZO
Parameters: str - The string to split String Parameters: start - the location to start Parameters: end - the end location of the substring a substring of parameter str. |
swapCase | public static String swapCase(String str)(Code) | | Reverse the character case in the string
author Henri Yves AMAIZO
Parameters: str - String String |
toBoolean | final public static boolean toBoolean(String theString)(Code) | | parse a boolean value
Parameters: theString - the string to parse a boolean value parse from input; if input cannot be parsed, return false |
truncate | public static String truncate(String str, int len)(Code) | | 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
Parameters: str - The string to process Parameters: len - The maximum length to process the string to. the appropriately trimmed string. |
unUpperFirstChar | public static String unUpperFirstChar(String str)(Code) | | convert the first character of string in lower case
author Henri Yves AMAIZO
Parameters: str - String to un-upper case the first character String |
unquote | public static String unquote(String s)(Code) | | remove surrounding quote marks (either "" or ''), only if quotes are at both the beginning and end of the string
Parameters: s - string for testing string which has surrounding quotes, if any, removed |
upperFirstChar | public static String upperFirstChar(String str)(Code) | | convert the first character of the string upper case
author Henri Yves AMAIZO
Parameters: str - String to make the first character upper. String |
xmlEscape | public static String xmlEscape(String s)(Code) | | Formats the string to an XML/XHTML escaped character. Useful for &'s, etc
Parameters: s - the String to format The escaped formatted String. See Also: org.apache.xml.serialize.BaseMarkupSerializer See Also: for example of original See Also: code. |
|
|