Package com.thortech.xl.util.adapters
Class tcUtilStringOperations
java.lang.Object
com.thortech.xl.util.adapters.tcUtilStringOperations
This class that has basic string operations utility methods. Author: Solomon
Niyazov January 7, 2002.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
containsAlpha
(String value) Checks if the String contains any alphabets in a stringstatic boolean
containsAlphaNum
(String value) Checks if the String contains any alphabets/numbers in a stringstatic boolean
containsNumber
(String value) Checks if the string contains any numberstatic String
convertToString
(Object poValue) method that returns String representation of Object.static String
getRandomString
(int len) method that returns a random string of the specified length.static int
getStringLength
(String psValue) method that returns length of the string passed it.static int
getTrimmedStringLength
(String psValue) method that returns trimmed length of the string passed it.static int
getUniqueCharactersCount
(String inputString) operation that does validation for unique characters count.static String
method that holds the value passed to it and returns it back This is usefull for entity adapters to map Xellerate data from User management form etc to process data.static String
insertWhiteSpace
(String psInput, int pnOffset, int pnNumSpaces) method that insert whitespace character(s) into the specified stringstatic boolean
isInputWithRepeatedConsecutiveCharacters
(String inputString) operation that does validation for repeatable consecutive characters.static boolean
isInvalidCharacter
(String psValue, char charToCheck) method that checks if the character exist in the string.static void
Main Methodstatic int
numberOfAlphaInString
(String value) Numbers of alphabets in a stringstatic int
numberOfAlphaNumInString
(String value) this method returns the numbers of alphabets + number of numbers in a stringstatic int
numberOfNumbersInString
(String value) Returns the number of numbers in the stringstatic int
returns the number of special characters in a stringstatic String
performConcat
(String value1, String value2) method that performs concatenation of two strings.static String
performConcatWithSpace
(String value1, String value2) method that performs concatenation of two strings with a space in betweenstatic boolean
performLowerCaseCheck
(String value) Returns true if there is atleast one lowercasestatic boolean
performSpecialCharCheck
(String value) Checks if the string has any special character in it.static String
performSubstring
(String value, int beginPos) method that performs substring function based on specified begin position.static String
performSubstring
(String value, int beginPos, int endPos) method that performs substring function based on specified begin and end positions.static String
performSubstring
(String value, Integer beginPos) method that performs substring function based on specified begin position.static String
performSubstring
(String value, Integer beginPos, Integer endPos) method that performs substring function based on specified begin and end positions.static String
performSubstringLess
(String value, int beginPos, int endPos) method that performs substring function based on specified begin and end positions.static String
performSubstringLess
(String value, Integer beginPos, Integer endPos) method that performs substring function based on specified begin and end positions.static String
performToLowerCase
(String value) method that converts string to Lower case.static String
performToUpperCase
(String value) method that converts string to Upper case.static String
replaceWithWhitespace
(String psInput, char pcOldChar) method that replaces the specified character of a string with a whitespace character.
-
Method Details
-
getRandomString
method that returns a random string of the specified length.- Parameters:
len
- len.- Returns:
- String.
-
replaceWithWhitespace
method that replaces the specified character of a string with a whitespace character.- Parameters:
psInput
- string on which this operation is performed.pcOldChar
- character to be replaced by the whitespace character.- Returns:
- string with whitespace character(s) in place of pcOldChar.
-
insertWhiteSpace
method that insert whitespace character(s) into the specified string- Parameters:
psInput
- string on which this operation is performed.pnOffset
- beginning position of whitespace insertion.pnNumSpaces
- number of whitespace characters to be inserted- Returns:
- string with whitespace character(s) inserted.
-
holdData
method that holds the value passed to it and returns it back This is usefull for entity adapters to map Xellerate data from User management form etc to process data.- Parameters:
data
- data.- Returns:
- String data.
-
performConcat
method that performs concatenation of two strings.- Parameters:
value1
- value1.value2
- value2.- Returns:
- String value1+value2.
-
performConcatWithSpace
method that performs concatenation of two strings with a space in between- Parameters:
value1
- value1.value2
- value2.- Returns:
- String value1+value2.
-
performSubstringLess
method that performs substring function based on specified begin and end positions. This method accomodates the string has less number of charaters than endPos value.- Parameters:
value
- String to be checked.beginPos
- begining Position.endPos
- end Position.- Returns:
- String substring
- Throws:
Exception
-
performSubstring
method that performs substring function based on specified begin and end positions.- Parameters:
value
- String to be checkedbeginPos
- begining Position.endPos
- end Position.- Returns:
- String Substring
- Throws:
Exception
-
performSubstring
method that performs substring function based on specified begin position.- Parameters:
value
- String to be checkedbeginPos
- begining Position.- Returns:
- String Substring
- Throws:
Exception
-
performSubstring
public static String performSubstring(String value, Integer beginPos, Integer endPos) throws Exception method that performs substring function based on specified begin and end positions.- Parameters:
value
- String to be checkedbeginPos
- begining Position.endPos
- end Position.- Returns:
- String substring
- Throws:
Exception
-
performSubstringLess
public static String performSubstringLess(String value, Integer beginPos, Integer endPos) throws Exception method that performs substring function based on specified begin and end positions. This method accomodates the string has less number of charaters than endPos value.- Parameters:
value
- String to be checkedbeginPos
- begining Position.endPos
- end Position.- Returns:
- String SubString .
- Throws:
Exception
-
performSubstring
method that performs substring function based on specified begin position.- Parameters:
value
- String to be checkedbeginPos
- begining Position.- Returns:
- String Substring
- Throws:
Exception
-
performToUpperCase
method that converts string to Upper case.- Parameters:
value
- value.- Returns:
- String value.
-
performToLowerCase
method that converts string to Lower case.- Parameters:
value
- String to be checked- Returns:
- String in lower case
-
numberOfNumbersInString
Returns the number of numbers in the string- Parameters:
value
- String to be checked- Returns:
- Number of Numbers
-
containsNumber
Checks if the string contains any number- Parameters:
value
- String to be checked- Returns:
- boolean True, if String has numbers, else False
- Throws:
Exception
-
numberOfAlphaInString
Numbers of alphabets in a string- Parameters:
value
- String to be checked- Returns:
- number of alphabets in a string
- Throws:
Exception
-
containsAlpha
Checks if the String contains any alphabets in a string- Parameters:
value
- String to be checked- Returns:
- boolean True, if String has alphabets , else False
- Throws:
Exception
-
containsAlphaNum
Checks if the String contains any alphabets/numbers in a string- Parameters:
value
- String to be checked- Returns:
- boolean True, if String has alphabets/numbers , else False
- Throws:
Exception
-
numberOfAlphaNumInString
this method returns the numbers of alphabets + number of numbers in a string- Parameters:
value
- String to be checked- Returns:
- int numbers of alphabets + number
- Throws:
Exception
-
performSpecialCharCheck
Checks if the string has any special character in it. The list of special characters include "`,~,!,@,#,$,%,^,&,*,(,),-,_,=,+,[,{,],},|,;,:,\,",,>,<,.,?"- Parameters:
value
- String to be checked- Returns:
- boolean True, if String has special characters, else False
- Throws:
Exception
-
numberOfSpecialCharInString
returns the number of special characters in a string- Parameters:
value
- String to be checked- Returns:
- int Number of Special Characters
- Throws:
Exception
-
performLowerCaseCheck
Returns true if there is atleast one lowercase- Parameters:
string
- to be checked- Returns:
- boolean true is the String has a lower case letter, else false
- Throws:
Exception
-
getStringLength
method that returns length of the string passed it.- Parameters:
psValue
- String .- Returns:
- int length of the String passed .
-
getTrimmedStringLength
method that returns trimmed length of the string passed it.- Parameters:
psValue
- Value to be trimmed .- Returns:
- int length of the Trimmed String passed .
-
convertToString
method that returns String representation of Object.- Parameters:
poValue
- Object to be converted to the String .- Returns:
- String Value of the object as String .
-
isInvalidCharacter
method that checks if the character exist in the string.- Parameters:
psValue
- psValue string to check.charToCheck
-- Returns:
- char charToCheck character to check for.
-
isInputWithRepeatedConsecutiveCharacters
operation that does validation for repeatable consecutive characters.- Parameters:
inputString
- inputString string to be tested.- Returns:
- boolean true if present false if no repeatable consecutive characters.
-
getUniqueCharactersCount
operation that does validation for unique characters count.- Parameters:
inputString
- inputString string to be tested.- Returns:
- integer, which gives the count of unique characters.
-
main
Main Method- Parameters:
arg
-
-