|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.quadrique.jbuildingblocks.core.string.JbbString
public class JbbString
This class provides convenience routines to manipulate String instances
| Method Summary | |
|---|---|
int |
compare(String b)
compares this string to b ,assumes null as less than non null value. |
boolean |
containsAtLeastOneDigit()
|
boolean |
containsAtLeastOneDigitAndAtLeastOneLetter()
|
boolean |
containsAtLeastOneLetter()
|
boolean |
containsTokens(String zTokens)
|
void |
convertFirstLetterToUpperCase()
the string with a first letter in upper case |
void |
convertFirstLetterToUpperCaseAndReminderToLowerCase()
the string with a first letter in upper case and the other letters in lower case. |
double |
convertToDouble()
A more robust conversion routine than Double.parseDouble(). |
float |
convertToFloat()
A more robust conversion routine than Float.parseFloat(). |
void |
convertToHtml()
replaces \n to \t to |
int |
convertToInt()
A more robust conversion routine than Integer.parseInt(). |
long |
convertToNumericVersionNumber()
Assumed to be of the form xxx.yyy.zzz where xxx ranges from 0..999, yyy ranges from 0...999 and zzz ranges from 0 to 999 |
void |
convertToPortableFileName()
This method takes an input String and convert it to a portable file name i.e. |
void |
convertToUnicodeBasicLatinAscii(boolean replaceWithClosestAsciiMatchIfAvailable)
This method returns a new String which contains: if replaceWithClosestAsciiMatchIfAvaillable is false, this method returns a new String which only contains the characters in the input string that are in the Unicode range from 0000 to 007F (i.e. |
String |
convertToWwwFormUrlEncoded()
|
void |
convertXmlToPrettyHtml()
|
int |
countNumberOfOccurences(char zChar)
|
boolean |
doesNotContainTokens(String zTokens)
|
void |
extractFromTheLastCharacterOccurenceToTheEnd(char zDelimiterChar,
boolean zRemoveDelimiterChar)
To remove all the characters from the last occurence of the given delimiter to the end of the string For instance, removeFromLastCharacterOccurenceToTheEnd(" this is cool",'i',true) returns " this " For instance, removeFromLastCharacterOccurenceToTheEnd(" this is cool",'c',false) returns " this is c" For instance, removeFromLastCharacterOccurenceToTheEnd(" this is cool",'z',false) returns " this is cool" |
ArrayList<String> |
extractTokens(String zDelimiters)
extract the tokens from the given string. |
ArrayList<String> |
extractTokensIncludingEmptyValues(String zDelimiters)
extract the tokens from the given string. |
String |
getString()
|
boolean |
isAlphaNum()
|
boolean |
isAlphaNumUnderscore()
|
boolean |
isCharacterInCharSet(char zChar,
String zCharSet)
|
boolean |
isCharInCharSet(char zChar,
String zCharSet)
|
boolean |
isFrenchCellPhoneNumber()
phoneNb in the form "06-23-45-67-89" or "0623456789" or "06 23 45 67 89" |
boolean |
isFrenchPhoneNumber()
phoneNb in the form "01-23-45-67-89" or "0123456789" or "01 23 45 67 89" |
boolean |
isNotEmpty()
Makes sure the given string is not null and is not of 0 length |
void |
isNotEmpty(String zValueName)
Makes sure the given string is not null and is not of 0 length |
boolean |
isNotEmptyAndIsNotWhiteSpace()
Makes sure the given string is not null, is not of 0 length and that it contains at least one non white space character |
void |
isNotEmptyAndIsNotWhiteSpace(String zValueName)
Makes sure the given string is not null, is not of 0 length and that it contains at least one non white space character |
boolean |
isNum()
|
boolean |
isStringInCharSet(String zCharSet)
|
boolean |
isStringInStringSet(HashSet<String> zStringSet)
To determine if a given string is part of a given set of strings. |
boolean |
isUsPhoneNumber()
phoneNb in the form "870-345-4567" or "8703454567" or "870 345 4567" |
void |
isValidEmailAddress()
Returns if the email address is valid. |
void |
isValidIpAddress()
Returns if the IP address is in a proper dotted decimal format: X1.X2.X3.X4 where Xi is [0...255] the IP address in dotted decimal format (e.g. |
boolean |
isWhiteSpace()
|
boolean |
matchPattern(String zRegularExpression)
make sure that the given string satisfies the given regular expression |
static JbbString |
newInstance()
|
static JbbString |
newInstance(String str)
|
void |
padBeginning(int zDesiredNbOfChars)
|
void |
padBeginning(int zDesiredNbOfChars,
char zPadChar)
|
void |
padEnding(int zDesiredNbOfChars)
|
void |
padEnding(int zDesiredNbOfChars,
char zPadChar)
|
void |
removeCharacter(char zChar)
To remove the given character from the given string |
void |
removeCharacters(String zCharSet)
To remove the given characters from the given string |
void |
removeCharactersNotInCharset(String zCharSet)
To remove the characters that are no in the given characters set from the given string |
void |
removeFromTheBeginningToTheFirstCharacterOccurence(char zDelimiterChar,
boolean zRemoveDelimiterChar)
To remove all the characters from the beginning of the string to the first occurrence of the given character. |
void |
removeFromTheBeginningToTheFirstStringOccurence(String delimiterString,
boolean removeDelimiterString)
To remove all the characters from the beginning of the string to the first occurrence of the given delimiter string. |
void |
removeFromTheLastCharacterOccurenceToTheEnd(char zDelimiterChar,
boolean zRemoveDelimiterChar)
To remove all the characters from the last occurence of the given delimiter to the end of the string For instance, removeFromLastCharacterOccurenceToTheEnd(" this is cool",'i',true) returns " this " For instance, removeFromLastCharacterOccurenceToTheEnd(" this is cool",'c',false) returns " this is c" For instance, removeFromLastCharacterOccurenceToTheEnd(" this is cool",'z',false) returns " this is cool" |
void |
removeNewLineCharacters()
To remove the end of line/new line characters (\n\r) from the given string |
void |
removeStringFromString(String stringToRemove)
To remove all occurrences of the specified text from the given string. |
void |
replaceAnySingleQuoteByTwoSingleQuotes()
This method is very helpful whenever you are handling SQL statements for a database. |
void |
replaceCharacter(char zOldChar,
char zNewChar)
To replace a given character with another in the given string |
void |
replaceCharacterByString(char charToReplace,
String replacementString)
To replace a given character with another in the given string |
void |
replaceCharacters(String charsToReplace,
char replacementChar)
To replace the given characters in the given string with a new character |
void |
replaceFromTheBeginningToTheFirstStringOccurence(String delimiterString,
boolean removeDelimiterString,
String replacementString)
To replace all the characters from the beginning of the string to the first occurrence of the given delimiter string by a new prefix string. |
String |
toString()
|
void |
trim()
|
void |
trim(int maxSize)
|
void |
trim(String zTrimChars)
|
void |
trimBeginningOnly()
|
void |
trimBeginningOnly(String zTrimChars)
|
void |
trimEndingOnly()
|
void |
trimEndingOnly(String zTrimChars)
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public static JbbString newInstance()
public static JbbString newInstance(String str)
public String getString()
public String toString()
toString in class Objectpublic ArrayList<String> extractTokens(String zDelimiters)
zDelimiters - the characters that are the delimiters for separating tokens
(e.g. " ,")
public ArrayList<String> extractTokensIncludingEmptyValues(String zDelimiters)
throws Exception
zDelimiters - the characters that are the delimiters for separating tokens
(e.g. " ,")
Exception
public boolean isAlphaNum()
throws Exception
Exception
public boolean isNum()
throws Exception
Exception
public boolean isAlphaNumUnderscore()
throws Exception
Exception
public boolean isCharacterInCharSet(char zChar,
String zCharSet)
throws Exception
zChar - the character to testzCharSet - the set of valid characters
Exception
public boolean isStringInCharSet(String zCharSet)
throws Exception
zCharSet - the set of valid characters
Exception
public boolean isWhiteSpace()
throws Exception
Exception
public boolean isCharInCharSet(char zChar,
String zCharSet)
zChar - the input characterzCharSet - the set of valid characters
public boolean isStringInStringSet(HashSet<String> zStringSet)
throws Exception
zStringSet - the set of valid Strings
Exception
public void isValidIpAddress()
throws Exception
Exception - if the IP address is not valid.
public boolean isNotEmpty()
throws Exception
Exception
public void isNotEmpty(String zValueName)
throws Exception
zValueName - the name to use for this string when the exception is launched
("zName..." cannot be null or empty)
Exception
public void isNotEmptyAndIsNotWhiteSpace(String zValueName)
throws Exception
zValueName - the name to use for this string when the exception is launched
("zName..." cannot be null or empty)
Exception
public boolean isNotEmptyAndIsNotWhiteSpace()
throws Exception
Exception
public void isValidEmailAddress()
throws JbbInvalidEmailAddressException
Exception - if the email address is not valid.
JbbInvalidEmailAddressException
public void removeFromTheBeginningToTheFirstCharacterOccurence(char zDelimiterChar,
boolean zRemoveDelimiterChar)
throws Exception
zDelimiterChar - the character that indicates the end of the characters to
removezRemoveDelimiterChar - true if the delimiter character is to be removed as well
Exception
public void removeFromTheLastCharacterOccurenceToTheEnd(char zDelimiterChar,
boolean zRemoveDelimiterChar)
throws Exception
zDelimiterChar - the character that indicates the beginning of the characters
to removezRemoveDelimiterChar - true if the delimiter character is to be removed as well
Exception
public void removeCharacter(char zChar)
throws Exception
zChar - the character to remove
Exception
public void removeCharacters(String zCharSet)
throws Exception
zCharSet - the set of characters that should be removed if they are
present in the input string
Exception
public final void removeCharactersNotInCharset(String zCharSet)
throws Exception
zCharSet - the set of characters that should be kept if they are present
in the input string
Exception
public void removeNewLineCharacters()
throws Exception
Exception
public void replaceCharacter(char zOldChar,
char zNewChar)
throws Exception
zOldChar - the character to replacezNewChar - the character to use as a replacement to zOldChar
Exception
public boolean matchPattern(String zRegularExpression)
throws Exception
zRegularExpression -
Exceptionpublic boolean containsAtLeastOneLetter()
public boolean containsAtLeastOneDigit()
public boolean containsAtLeastOneDigitAndAtLeastOneLetter()
public boolean isFrenchPhoneNumber()
throws Exception
exception
Exception
public boolean isFrenchCellPhoneNumber()
throws Exception
exception
Exception
public boolean isUsPhoneNumber()
throws Exception
exception
Exceptionpublic int countNumberOfOccurences(char zChar)
zChar - the character whose occurrences in this string have to be
counted
public boolean containsTokens(String zTokens)
zTokens - a comma delimited set of tokens (e.g. "token1,token2, token3 ")
public boolean doesNotContainTokens(String zTokens)
zTokens - a comma delimited set of tokens (e.g. "token1,token2, token3 ")
public final long convertToNumericVersionNumber()
throws Exception
Exceptionpublic void trim(String zTrimChars)
zTrimChars - the character to trim from the input string (e.g. " ")public void trim()
public void trimBeginningOnly(String zTrimChars)
zTrimChars - the characters to trim from the input string (e.g. " ")public void trimBeginningOnly()
public void trimEndingOnly(String zTrimChars)
zTrimChars - the character(s) to trim from the end of the input string
(e.g. " *")public void trimEndingOnly()
public void padBeginning(int zDesiredNbOfChars,
char zPadChar)
throws Exception
zDesiredNbOfChars - zPadChar - the character to pad
Exception
public void padBeginning(int zDesiredNbOfChars)
throws Exception
zDesiredNbOfChars -
Exception
public void padEnding(int zDesiredNbOfChars,
char zPadChar)
throws Exception
zDesiredNbOfChars - zPadChar - the padding character (e.g. ' ')
Exception
public void padEnding(int zDesiredNbOfChars)
throws Exception
zDesiredNbOfChars -
Exceptionpublic final void convertXmlToPrettyHtml()
public final void convertToHtml()
public void replaceAnySingleQuoteByTwoSingleQuotes()
throws Exception
Exceptionpublic void trim(int maxSize)
maxSize -
public void replaceCharacters(String charsToReplace,
char replacementChar)
throws Exception
charsToReplace - the set of characters (e.g. " '") that should be replaced if
they are present in the input stringreplacementChar - the replacment character
Exception
public final int convertToInt()
throws Exception
Exception
public final float convertToFloat()
throws Exception
Exception
public final double convertToDouble()
throws Exception
Exception
public final void convertToUnicodeBasicLatinAscii(boolean replaceWithClosestAsciiMatchIfAvailable)
throws Exception
replaceWithClosestAsciiMatchIfAvailable -
Exception
public final void convertToPortableFileName()
throws Exception
Exception
public void extractFromTheLastCharacterOccurenceToTheEnd(char zDelimiterChar,
boolean zRemoveDelimiterChar)
throws Exception
zDelimiterChar - the character that indicates the beginning of the characters
to removezRemoveDelimiterChar - true if the delimiter character is to be removed as well
Exception
public void convertFirstLetterToUpperCaseAndReminderToLowerCase()
throws Exception
Exception
public void convertFirstLetterToUpperCase()
throws Exception
Exception
public void removeStringFromString(String stringToRemove)
throws Exception
stringToRemove - the text to be removed
Exception
public void replaceCharacterByString(char charToReplace,
String replacementString)
throws Exception
charToReplace - the character to replacereplacementString - the character to use as a replacement to zOldChar
Exceptionpublic int compare(String b)
b -
public void removeFromTheBeginningToTheFirstStringOccurence(String delimiterString,
boolean removeDelimiterString)
throws Exception
delimiterString - the String that indicates the end of the characters to
removeremoveDelimiterString - true if the delimiter character is to be removed as well
Exception
public void replaceFromTheBeginningToTheFirstStringOccurence(String delimiterString,
boolean removeDelimiterString,
String replacementString)
throws Exception
delimiterString - the String that indicates the end of the characters to
removeremoveDelimiterString - true if the delimiter string is to be removed as wellreplacementString -
Exception
public final String convertToWwwFormUrlEncoded()
throws Exception
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||