| java.lang.Object com.metaboss.util.StringUtils
StringUtils | public class StringUtils (Code) | | Set of useful utilites to do with string manipulations
|
Method Summary | |
public static String | combine(String[] pSource, String pFiller) | public static String | combine(String[] pSource, String pFiller, int beginIndex, int endIndex) Combine specified number of elements into the string
using specified token separator. | public static int | countDigits(String in) | public static int | countLetters(String in) | public static String | fill(String pToken, String pPrefix, String pSuffix, String pSeparator, int pTokenRepeatCount) | public static String | getIndent(int lStepSize, int lRequiredNumberOfSteps) Returns string with certain number of spaces.
Parameters: lStepSize - - the size of each step in indentation (e.g. | public static String | getToken(String str, String delim, int count) | public static boolean | isBlank(String str) | public static String | leftJustify(int fieldWidth, String fieldValue, String fillerElement) Returns string with value left justified, padded with spaces. | public static String | readTextStreamFully(InputStream str) | public static String | replace(String pInput, char pFind, String pReplace) | public static String | replace(String pInput, String pFind, String pReplace) | public static String | rightJustify(int fieldWidth, String fieldValue, String fillerElement) Returns string with value right justified, padded with spaces. | public static String[] | split(String val, String split) Split a string into tokens. | public static String | suggestConstantIdentifier(String pText) This utility analyses given text and suggests derived name, which can be used as java constant identifier
(e.g. | public static String | suggestJavaIdentifier(String pText) | public static String | suggestJavaStringConstant(String pString) Returns string which can be specified as String constant in order to represent given string. | public static String | suggestMessageFormatPatternString(String pMessageString) This utility analyses given message string and suggests derived string, which
should be used as pattern argument in the java.text.MessageFormat. | public static String | suggestName(String pText, boolean pCapitaliseFirst, boolean pDecapitaliseOther) Shrinks text to one word, which than can be used as a name etc. | public static String | suggestTruncatedOutput(String pText, int pRequiredVisibleLength) This utility analyses given text and suggests derived string, which is very convenient to
output for log. | public static String | toLowerCaseFirstCharacter(String pSourceString) | public static String | toUpperCaseFirstCharacter(String pSourceString) |
combine | public static String combine(String[] pSource, String pFiller)(Code) | | Combine specified number of elements into the single string
filling the filler string in between tokens
|
combine | public static String combine(String[] pSource, String pFiller, int beginIndex, int endIndex)(Code) | | Combine specified number of elements into the string
using specified token separator. All elements starting from the beginIndex (inclusive) and up to
(but not including) the endIndex will be used.
throws: ArrayIndexOutOfBoundsException - when specified indexes are out of bounds |
countDigits | public static int countDigits(String in)(Code) | | Counts digits (Character.isDigit() == true) in the string
|
countLetters | public static int countLetters(String in)(Code) | | Counts letters (Character.isLetter() == true) in the string
|
fill | public static String fill(String pToken, String pPrefix, String pSuffix, String pSeparator, int pTokenRepeatCount)(Code) | | Builds the string consisting of Token string concatenated TokenRepeatCount number of times
with specified prefix, suffix and separator strings
|
getIndent | public static String getIndent(int lStepSize, int lRequiredNumberOfSteps)(Code) | | Returns string with certain number of spaces.
Parameters: lStepSize - - the size of each step in indentation (e.g. 4 spaces per tab) Parameters: lRequiredNumberOfSteps - - the number of steps required string filled with blanks to required length |
leftJustify | public static String leftJustify(int fieldWidth, String fieldValue, String fillerElement)(Code) | | Returns string with value left justified, padded with spaces.
If ield value is wider - field value only is returned
Parameters: fillerElement - - most often single space, but can be " " for html |
replace | public static String replace(String pInput, char pFind, String pReplace)(Code) | | Returns string with every occurrence of the character specified in pFind replaced
with the string specified in pReplace
|
replace | public static String replace(String pInput, String pFind, String pReplace)(Code) | | Returns string with every occurrence of the string specified in pFind replaced
with the string specified in pReplace
|
rightJustify | public static String rightJustify(int fieldWidth, String fieldValue, String fillerElement)(Code) | | Returns string with value right justified, padded with spaces.
If ield value is wider - field value only is returned
Parameters: fillerElement - - most often single space, but can be " " for html |
split | public static String[] split(String val, String split)(Code) | | Split a string into tokens. Note that this predates the split facility
available since JDK 1.4. The JDK facility should be used in preference to this
|
suggestConstantIdentifier | public static String suggestConstantIdentifier(String pText)(Code) | | This utility analyses given text and suggests derived name, which can be used as java constant identifier
(e.g. Heart Beat Rate becomes HEART_BEAT_RATE). It will ignore all not java identifier characters
prepend all upper case characters with '_' (unless there was '_' already) and uppercase them
null if it can not suggest anything useful |
suggestJavaIdentifier | public static String suggestJavaIdentifier(String pText)(Code) | | This utility analyses given text and suggests derived name, which can be used as java identifier
it will skip all not java identifier characters and replace all space characters with '_'
null if it can not suggest anything useful |
suggestJavaStringConstant | public static String suggestJavaStringConstant(String pString)(Code) | | Returns string which can be specified as String constant in order to represent given string.
Mainly it means that the escape characters '\' are prepended with the other '\' in order for string constant to be correctly
interpreted by Java compiler
|
suggestMessageFormatPatternString | public static String suggestMessageFormatPatternString(String pMessageString)(Code) | | This utility analyses given message string and suggests derived string, which
should be used as pattern argument in the java.text.MessageFormat.
Basically this utility takes care of the string constants and the escape characters.
Parameters: pMessageString - - the text for which we need to format using java.text.MessageFormat suggestion String to be used in the pattern in the java.text.MessageFormat class |
suggestName | public static String suggestName(String pText, boolean pCapitaliseFirst, boolean pDecapitaliseOther)(Code) | | Shrinks text to one word, which than can be used as a name etc.
This is achieved by getting rid of whiltespace and optional capitallisation of each first letter
and optional decapitalisation of the other letters.
For example 'text to name' with as delimiters becomes 'TextToName'
|
suggestTruncatedOutput | public static String suggestTruncatedOutput(String pText, int pRequiredVisibleLength)(Code) | | This utility analyses given text and suggests derived string, which is very convenient to
output for log. If given string length is more than required visible length
the string is truncated and suffixed with "...(nnnn more)..." suffix. If however
actual string is only a little more than required visible length and printing out the whole string
will in fact take less space than trunctated string plus suffix - the entire string will be returned
Parameters: pText - - the text for which we need to suggest the output Parameters: pRequiredVisibleLength - - the minimum length required to be visible suggestion on how to display the text |
toLowerCaseFirstCharacter | public static String toLowerCaseFirstCharacter(String pSourceString)(Code) | | Converts string to the same string which starts from the lower case letter
|
toUpperCaseFirstCharacter | public static String toUpperCaseFirstCharacter(String pSourceString)(Code) | | Converts string to the same string which starts from the upper case letter
|
|
|