net.simplace.core.service.StringHelper
public final class StringHelper {
// Public Constructors
public StringHelper();
// Class Methods public static List
arrayToList(Object[] aArray);
Turns an array into a (Array-)list.
returns a (Array-)list
public static String
convertLineBreak(String aValue);
Replaces the extensive line break with the simple one.
returns converted String
public static String
convertEncoding(String aContent, String aInputEncoding,
String aOutputEncoding) throws UnsupportedEncodingException;
Gets String with one encoding and returns one with another encoding.
Input and/or OutputEncoding can be left empty or null for no changes.
- aContent
- aInputEncoding
- aOutputEncoding
returns String with another encoding
public static boolean
containsAnyCharacter(String aStringToCheck, String
aCharactersToLookFor);
Checks, whether any of the characters in aCharactersContained occurs in aStringToCheck. Note that
this method returns true, if ANY single character in aCharactersContained is contained in
aStringToCheck.
- aStringToCheck - String to be searched
- aCharactersToLookFor - String containing the characters to look for in aStringToCheck
returns true, if any of the characters in aCharactersContained is contained in aStringToCheck
public static String
extractDigitsFromString(String aString);
discards every non digit from the passed string
returns NULL on error
public static String
filterLineFeed(String aString);
Replaces line feed characters with whitespaces.
returns converted String
public static String
getAfterDivider(String aString, String aDivider);
Returns the part of aString after aDivider.
returns the part of aString after aDivider
public static String
getAfterFirstDivider(String aString, String aDivider);
Returns the part of aString after aDivider.
returns the part of aString after aDivider
public static String
getBeforeDivider(String aString, String aDivider);
Returns the part of aString before aDivider.
returns value before divider
public static String
getBeforeLastDivider(String aString, String aDivider);
Returns the part of aString before the last Divider.
returns the part of aString before the last Divider
public static final String
getHead(String aString, int aCount);
Returns a string containing the first aCharCount characters of aString.
if the string is smaller the whole string is returned.
returns a string containing the first aCharCount characters of aString
public static final String
replacePlaceholder(String aDocument, String
aPlaceholder, String aValue);
Replaces a String ($Example$) in a document by taking the Value.
- aDocument
- aPlaceholder
- aValue
returns converted String
public static final StringBuffer
replacePlaceholderAsBuffer(String aDocument,
String aPlaceholder, String aValue);
Replaces a StringBuffer ($Example$) in a document by taking the Value.
- aDocument
- aPlaceholder
- aValue
returns StringBuffer
public static final String
getInternationalisedString(String aInputString);
Replaces a old value with a new value in the given String
returns converted String
public static String
getLabelText(String aText);
Value of the label.
returns Value of the label
public static String
getLabelText(String aText, boolean aAlwaysHTML);
Returning a formated value for a label or tooltiptext, replacing all linebreaks and special
chars.
returns a formated value for a label or tooltiptext
public static String
getLabelText(String aText, Font aFont, String
aAdditionalStyle, boolean aAlwaysHTML);
Returning a formated value for a label or tooltiptext, replacing all linebreaks and special
chars.
- aText
- aFont
- aAdditionalStyle
- aAlwaysHTML
returns a formated value for a label or tooltiptext
public static LinkedList
getListFromString(String aString, String aDivider);
returns List formed from String
public static LinkedList
getListFromString(String aString, String aDivider,
boolean doLeaveEmptyStringsOut, boolean doTrim);
- aString
- aDivider
- doLeaveEmptyStringsOut
- doTrim
returns List formed from String
public static Map
getMapFromString(String aString, String aMapDivider,
String aValueDevider);
- aString
- aMapDivider
- aValueDevider
returns Map formed from String
public static Long
getLong(String aString);
Returns the part of aString that is made of numbers.
returns the part of aString that is made of numbers
public static ArrayList
getMatchesFromString(String aString, String aPattern);
- aString
- aPattern
- aTargetDir
returns List of matches from String
public static final DecimalFormat
getNumberFormat(String aNumberString, int
aLenthOfStirng);
getting number format from a given String. returning null if value is no number. pls make sure
that . is used for separator of values.
length is used for setting the right number of ### Strings
- aNumberString
- aLenthOfStirng
returns number format from a given String
public static final String
getTail(String aString, int aCount);
Returns a string containing the first aCharCount characters of aString.
if the string is smaller the whole string is returned.
returns the tail of the string
public static String
getTimeString(Long aTime);
Returns the time in string format.
returns a string containing the first aCharCount characters of aString
public static String
getTimeText(long aTime);
Returns a text for the given time. (08:25:14)
returns a text for the given time
public static String
insertLineBreaks(String aString, String aLineBreak, int
aMaxLength, boolean aCountSpaces);
- aString - the String in which the line breaks should be inserted
- aLineBreak - a String that contains the LineBreak-characters like "
" or "\n"
- aMaxLength - the count of characters of each line
- aCountSpaces - false = reset the character count on each empty space
returns String with inserted line breaks
public static boolean
isEmpty(Object aValue);
returns true, if String is null or ""
public static boolean
isNumber(String aString);
Returns the part of aString that is made of numbers.
returns the part of aString that is made of numbers
public static String
outputToString(Map aMap);
Returns a formatted String form the given Map.
returns a formatted String form the given Map
public static String
pad(int aStringLength, char aFiller, String aHead,
String aTail);
This method fills a given string with a specified char until the specified length is achieved.
Example: pad(6, '0', null, "14") will result in the result string: "000014"
- aStringLength The length of the result string that has to be padded.
- aFiller The character with which the string should be filled.
- aHead A string representing the head of the result string. The filling character
is filled after the head. If null, the head is ignored.
- aTail A string representing the tail of the result string. The filling character
is filled after the tail. If null, the tail is ignored.
returns converted String
public static boolean
parseBoolean(Object aString);
Tries to figure out the boolean value of the given String or returns false if it can't.
returns success
public static LocalDateTime
parseDate(Object aParameterFromMap,
LocalDateTime aDefaultValue);
Tries to figure out the date value of the given String or returns a default value if it can't.
- aParameterFromMap
- aDefaultValue
returns the date value of the given String or a default value
public static Boolean
parseBoolean(Object aObject, boolean aDefaultValue);
Tries to figure out the boolean value of the given String or returns a default value if it can't.
returns the boolean value of the given String or returns a default value
public static List
parseParameters(String aInterceptorString, String
aParameterDivider, String aBeginListDivider, String aEndListDivider);
Parses the parameter given in a string an returns a list of them.
- aInterceptorString
- aParameterDivider
- aBeginListDivider
- aEndListDivider
returns List of parameters
public static ArrayList
parseSeparatedListDouble(String aString, String
aDivider);
Returns a list with the elements that are divided by divider in a String.
returns a list with the elements that are divided by divider in a String
public static String
removeCharacter(String aString, char aChar);
Replaces line feed characters with whitespaces.
returns converted String
public static boolean
containsSpecialCharacters(String aStringToCheck);
Searches the given String for special characters. Returns true, if other characters than
0-9 a-z A-Z - _ are found in the string.
- aStringToCheck - String to be searched for special characters
returns true, if the string contains special characters
public static boolean
containsProblematicCharacters(String aStringToCheck);
returns true if a given String contains problematic characters
public static boolean
containsProblematicCharacters(String aStringToCheck,
boolean aAlsoCheckForHTMLEntity);
Searches the given String for any of the special characters < > $ " ' \ # %
Returns true, if one of these is found.
- aStringToCheck - String to be searched for special characters
- aAlsoCheckForHTMLEntity - If true, HTML-Entities are checked for also, e. g. < for <
returns true, if the string contains special characters
public static boolean
containsWebEuroSign(String aStringToCheck);
Searches the given String for the EURO sign as it is transmitted via the browser. Returns true,
if it is found.
- aStringToCheck - String to be searched for special characters
returns true, if the string contains the euro sign
public static boolean
containsWebEuroSign(String aStringToCheck, boolean
aAlsoCheckForHTMLEntity);
Searches the given String for the EURO sign as it is transmitted via the browser. Returns true,
if it is found.
- aStringToCheck - String to be searched for special characters
- aAlsoCheckForHTMLEntity
returns true, if the string contains the euro sign
public static String
cutString(String aString, int aMaxLength);
Cuts the tail of the given string if it exceeds a given length (minimum 3).
returns converted String
public static Iterable
findMatches(String pattern, CharSequence s);
returns Iterable
public static String
replaceNullWithEmptyString(String aString);
replaces Null with empty String.
returns empty String
public static List
parseSeparatedListString(String aString, String aDivider);
Returns a list with the elements that are divided by divider in a String.
returns a List of Strings
public static ArrayList
parseSeparatedListInteger(String aString, String
aDivider);
Returns a list with the elements that are divided by divider in a String.
returns a list with the elements that are divided by divider in a String
public static String
unParseParameters(Collection aElementCollection, String
aParameterDivider);
Parses the parameter given in a string an returns a list of them.
- aElementCollection
- aParameterDivider
returns list of parameters
public static String
replaceHTMLEntities(String aHTML);
Changes the given code to html.
returns converted String
public static String
replaceHTMLEntities(String aHTML, boolean
aReplaceHTMLChars);
Changes the given code to html.
returns converted String
public static String
replaceAll(String aString, Map aSubstitutionMap);
Replaces all entries from the map.
returns resulting String
public static Object
transformDataType(String aString,
FWSimVariable aVariable);
returns Object
public static Integer[]
toIntArray(String aString);
returns Array of Integers
public static Integer[]
toIntArray(String[] aArray);
returns Array of Integers
public static Integer[]
toIntArray(int[] aArray);
returns Array of Integers
public static Double[]
toDoubleArray(String aString);
returns Array of Doubles
public static LocalDateTime[]
toDateArray(String aValueText);
returns public static LocalDateTime[]
toDateArray(String[] aValueText);
returns public static Double[][]
toDoubleMatrix(String aValueText);
returns public static Double[]
toDoubleArray(String[] aArray);
returns Array of Doubles
public static Double[]
toDoubleArray(int[] aArray);
returns Array of Doubles
public static Double[]
toDoubleArray(double[] aArray);
returns Array of Doubles
public static Double[][]
toDoubleMatrix(String[][] aObject);
returns public static String[]
toStringArray(String aString);
returns Array of Strings
public static final String
returnValidString(String aUncheckedString);
Replaces all letters that are maybe not supported by system for using in
filename. You should only give the filename without path!!!
If add/remove characters also change
isValidFilename/getInvalidFilenameCharacters
returns valid file name
public static String
toStringForm(Double[] value);
returns String
public static String
toStringForm(Double[][] matrix);
returns String
public static String
toStringForm(Integer[] value);
returns String
public static String
toStringForm(String[] value);
returns String
public static String
fullTrim(String aBeforePart);
returns the full trimmed String
public static String[]
splitBySize(String aStringToSplit, int i);
returns String, split by size
public static Integer
parseIntegerPart(String aLineString);
returns Integer part of a given String
public static Float
parseFloatPart(String aLineString);
returns Float part of a given String
public static Integer[]
parseIntegerToArray(String aIndexString, boolean
aConvertIndizes0To1);
- aIndexString
- aConvertIndizes0To1
returns Array of Integers
public static String
fitString(String aUserName, int aLength);
Fits the length of a String with spaces to the given length
returns the fitted String
public static double
round(double aValue, int aPlaces);
round the double to a "halfUp" value
returns the rounded double
public static String
arrayToString(String[] aSplit, String aSeparator);
returns public static String[][] convertLinesToStringarray(Vector aLinesVector,
String aDivider);
// Inner Classes
public static final class StringHelper.UNICODE
}