Package net.simplace.core.service
Klasse StringHelper
java.lang.Object
net.simplace.core.service.StringHelper
- Autor:
- Andreas Enders
-
Verschachtelte Klassen - Übersicht
Verschachtelte Klassen -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungarrayToList(Object[] aArray) Turns an array into a (Array-)list.static StringarrayToString(String[] aSplit, String aSeparator) static <T> StringarrayToString(T[][] aSumOfCutValues, String aSeperator) static booleancontainsAnyCharacter(String aStringToCheck, String aCharactersToLookFor) Checks, whether any of the characters in aCharactersContained occurs in aStringToCheck.static booleancontainsProblematicCharacters(String aStringToCheck) static booleancontainsProblematicCharacters(String aStringToCheck, boolean aAlsoCheckForHTMLEntity) Searches the given String for any of the special characters Ungültige Eingabe: "<" > $ " ' \ # % Returns true, if one of these is found.static booleancontainsSpecialCharacters(String aStringToCheck) Searches the given String for special characters.static booleancontainsWebEuroSign(String aStringToCheck) Searches the given String for the EURO sign as it is transmitted via the browser.static booleancontainsWebEuroSign(String aStringToCheck, boolean aAlsoCheckForHTMLEntity) Searches the given String for the EURO sign as it is transmitted via the browser.static StringconvertEncoding(String aContent, String aInputEncoding, String aOutputEncoding) Gets String with one encoding and returns one with another encoding.static StringconvertLineBreak(String aValue) Replaces the extensive line break with the simple one.static String[][]convertLinesToStringarray(Vector<String> aLinesVector, String aDivider) convertStringToLines(String aString, Integer[] aLinesToRead) static StringCuts the tail of the given string if it exceeds a given length (minimum 3).static StringextractDigitsFromString(String aString) discards every non digit from the passed stringstatic StringfilterLineFeed(String aString) Replaces line feed characters with whitespaces.static StringfilterWhiteSpacesAndTabs(String aString) Replaces several white spaces characters with one.static Iterable<MatchResult> findMatches(String pattern, CharSequence s) static StringFits the length of a String with spaces to the given lengthstatic Stringstatic StringgetAfterDivider(String aString, String aDivider) Returns the part of aString after aDivider.static StringgetAfterFirstDivider(String aString, String aDivider) Returns the part of aString after aDivider.static StringgetBeforeDivider(String aString, String aDivider) Returns the part of aString before aDivider.static StringgetBeforeLastDivider(String aString, String aDivider) Returns the part of aString before the last Divider.static final StringReturns a string containing the first aCharCount characters of aString.static final StringgetInternationalisedString(String aInputString) Replaces a old value with a new value in the given Stringstatic StringgetLabelText(String aText) Value of the label.static StringgetLabelText(String aText, boolean aAlwaysHTML) Returning a formated value for a label or tooltiptext, replacing all linebreaks and special chars.static StringgetLabelText(String aText, Font aFont, String aAdditionalStyle, boolean aAlwaysHTML) Returning a formated value for a label or tooltiptext, replacing all linebreaks and special chars.static LinkedList<String> getListFromString(String aString, String aDivider) static LinkedList<String> getListFromString(String aString, String aDivider, boolean doLeaveEmptyStringsOut, boolean doTrim) static LongReturns the part of aString that is made of numbers.getMapFromString(String aString, String aMapDivider, String aValueDevider) getMatchesFromString(String aString, String aPattern) static final DecimalFormatgetNumberFormat(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.static final StringReturns a string containing the first aCharCount characters of aString.static StringgetTimeString(Long aTime) Returns the time in string format.static StringgetTimeText(long aTime) Returns a text for the given time. (08:25:14)static StringinsertLineBreaks(String aString, String aLineBreak, int aMaxLength, boolean aCountSpaces) static booleanstatic booleanReturns the part of aString that is made of numbers.static Stringstatic StringoutputToString(Map<String, ?> aMap) Returns a formatted String form the given Map.static StringThis method fills a given string with a specified char until the specified length is achieved.static booleanparseBoolean(Object aString) Tries to figure out the boolean value of the given String or returns false if it can't.static BooleanparseBoolean(Object aObject, boolean aDefaultValue) Tries to figure out the boolean value of the given String or returns a default value if it can't.static LocalDateTimeparseDate(Object aParameterFromMap, LocalDateTime aDefaultValue) Tries to figure out the date value of the given String or returns a default value if it can't.static FloatparseFloatPart(String aLineString) static IntegerparseIntegerPart(String aLineString) static Integer[]parseIntegerToArray(String aIndexString, boolean aConvertIndizes0To1) parseParameters(String aInterceptorString, String aParameterDivider, String aBeginListDivider, String aEndListDivider) Parses the parameter given in a string an returns a list of them.parseSeparatedListDouble(String aString, String aDivider) Returns a list with the elements that are divided by divider in a String.parseSeparatedListInteger(String aString, String aDivider) Returns a list with the elements that are divided by divider in a String.parseSeparatedListString(String aString, String aDivider) Returns a list with the elements that are divided by divider in a String.static StringremoveCharacter(String aString, char aChar) Replaces line feed characters with whitespaces.static StringreplaceAll(String aString, Map aSubstitutionMap) Replaces all entries from the map.static StringreplaceHTMLEntities(String aHTML) Changes the given code to html.static StringreplaceHTMLEntities(String aHTML, boolean aReplaceHTMLChars) Changes the given code to html.static StringreplaceNullWithEmptyString(String aString) replaces Null with empty String.static final StringreplacePlaceholder(String aDocument, String aPlaceholder, String aValue) Replaces a String ($Example$) in a document by taking the Value.static final StringBufferreplacePlaceholderAsBuffer(String aDocument, String aPlaceholder, String aValue) Replaces a StringBuffer ($Example$) in a document by taking the Value.static final StringreturnValidString(String aUncheckedString) Replaces all letters that are maybe not supported by system for using in filename.static doubleround(double aValue, int aPlaces) round the double to a "halfUp" valuestatic String[]splitBySize(String aStringToSplit, int i) static LocalDateTime[]toDateArray(String aValueText) static LocalDateTime[]toDateArray(String[] aValueText) static Double[]toDoubleArray(double[] aArray) static Double[]toDoubleArray(int[] aArray) static Double[]toDoubleArray(String aString) static Double[]toDoubleArray(String[] aArray) static Double[][]toDoubleMatrix(String aValueText) static Double[][]toDoubleMatrix(String[][] aObject) static Integer[]toIntArray(int[] aArray) static Integer[]toIntArray(String aString) static Integer[]toIntArray(String[] aArray) static String[]toStringArray(String aString) static StringtoStringForm(Double[] value) static StringtoStringForm(Double[][] matrix) static StringtoStringForm(Integer[] value) static StringtoStringForm(String[] value) static ObjecttransformDataType(String aString, FWSimVariable<?> aVariable) static StringunParseParameters(Collection<?> aElementCollection, String aParameterDivider) Parses the parameter given in a string an returns a list of them.
-
Konstruktordetails
-
StringHelper
public StringHelper()
-
-
Methodendetails
-
arrayToList
Turns an array into a (Array-)list.- Parameter:
aArray-- Gibt zurück:
- a (Array-)list
-
convertLineBreak
Replaces the extensive line break with the simple one.- Parameter:
aValue-- Gibt zurück:
- converted String
-
convertEncoding
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.- Parameter:
aContent-aInputEncoding-aOutputEncoding-- Gibt zurück:
- String with another encoding
- Löst aus:
UnsupportedEncodingException
-
containsAnyCharacter
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.- Parameter:
aStringToCheck- - String to be searchedaCharactersToLookFor- - String containing the characters to look for in aStringToCheck- Gibt zurück:
- true, if any of the characters in aCharactersContained is contained in aStringToCheck
-
extractDigitsFromString
discards every non digit from the passed string- Parameter:
aString-- Gibt zurück:
- NULL on error
-
filterLineFeed
Replaces line feed characters with whitespaces.- Parameter:
aString-- Gibt zurück:
- converted String
-
filterWhiteSpacesAndTabs
Replaces several white spaces characters with one.- Parameter:
aString-- Gibt zurück:
- converted String
-
getAfterDivider
Returns the part of aString after aDivider.- Parameter:
aString-aDivider-- Gibt zurück:
- the part of aString after aDivider
-
getAfterFirstDivider
Returns the part of aString after aDivider.- Parameter:
aString-aDivider-- Gibt zurück:
- the part of aString after aDivider
-
getBeforeDivider
Returns the part of aString before aDivider.- Parameter:
aString-aDivider-- Gibt zurück:
- value before divider
-
getBeforeLastDivider
Returns the part of aString before the last Divider.- Parameter:
aString-aDivider-- Gibt zurück:
- the part of aString before the last Divider
-
getHead
Returns a string containing the first aCharCount characters of aString. if the string is smaller the whole string is returned.- Parameter:
aString-aCount-- Gibt zurück:
- a string containing the first aCharCount characters of aString
-
replacePlaceholder
Replaces a String ($Example$) in a document by taking the Value.- Parameter:
aDocument-aPlaceholder-aValue-- Gibt zurück:
- converted String
-
replacePlaceholderAsBuffer
public static final StringBuffer replacePlaceholderAsBuffer(String aDocument, String aPlaceholder, String aValue) Replaces a StringBuffer ($Example$) in a document by taking the Value.- Parameter:
aDocument-aPlaceholder-aValue-- Gibt zurück:
- StringBuffer
-
getInternationalisedString
Replaces a old value with a new value in the given String- Parameter:
aInputString-- Gibt zurück:
- converted String
-
getLabelText
Value of the label.- Parameter:
aText-- Gibt zurück:
- Value of the label
-
getLabelText
Returning a formated value for a label or tooltiptext, replacing all linebreaks and special chars.- Parameter:
aText-aAlwaysHTML-- Gibt zurück:
- a formated value for a label or tooltiptext
-
getLabelText
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.- Parameter:
aText-aFont-aAdditionalStyle-aAlwaysHTML-- Gibt zurück:
- a formated value for a label or tooltiptext
-
getListFromString
- Parameter:
aString-aDivider-- Gibt zurück:
- List formed from String
-
getListFromString
public static LinkedList<String> getListFromString(String aString, String aDivider, boolean doLeaveEmptyStringsOut, boolean doTrim) - Parameter:
aString-aDivider-doLeaveEmptyStringsOut-doTrim-- Gibt zurück:
- List formed from String
-
getMapFromString
public static Map<String,String> getMapFromString(String aString, String aMapDivider, String aValueDevider) - Parameter:
aString-aMapDivider-aValueDevider-- Gibt zurück:
- Map formed from String
-
getLong
Returns the part of aString that is made of numbers.- Parameter:
aString-- Gibt zurück:
- the part of aString that is made of numbers
-
getMatchesFromString
- Parameter:
aString-aPattern-aTargetDir-- Gibt zurück:
- List of matches from String
-
getNumberFormat
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- Parameter:
aNumberString-aLenthOfStirng-- Gibt zurück:
- number format from a given String
-
getTail
Returns a string containing the first aCharCount characters of aString. if the string is smaller the whole string is returned.- Parameter:
aString-aCount-- Gibt zurück:
- the tail of the string
-
getTimeString
Returns the time in string format.- Parameter:
aTime-- Gibt zurück:
- a string containing the first aCharCount characters of aString
-
getTimeText
Returns a text for the given time. (08:25:14)- Parameter:
aTime-- Gibt zurück:
- a text for the given time
-
insertLineBreaks
public static String insertLineBreaks(String aString, String aLineBreak, int aMaxLength, boolean aCountSpaces) - Parameter:
aString- - the String in which the line breaks should be insertedaLineBreak- - a String that contains the LineBreak-characters like "
" or "\n"aMaxLength- - the count of characters of each lineaCountSpaces- - false = reset the character count on each empty space- Gibt zurück:
- String with inserted line breaks
-
isEmpty
- Parameter:
aValue-aIconID-- Gibt zurück:
- true, if String is null or ""
-
isNumber
Returns the part of aString that is made of numbers.- Parameter:
aString-- Gibt zurück:
- the part of aString that is made of numbers
-
outputToString
Returns a formatted String form the given Map.- Parameter:
aMap-- Gibt zurück:
- a formatted String form the given Map
-
pad
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"- Parameter:
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.- Gibt zurück:
- converted String
- Löst aus:
IllegalArgumentException- if the sum of lengths of the given strings is longer than the requested result string.
-
parseBoolean
Tries to figure out the boolean value of the given String or returns false if it can't.- Parameter:
aString-- Gibt zurück:
- success
-
parseDate
Tries to figure out the date value of the given String or returns a default value if it can't.- Parameter:
aParameterFromMap-aDefaultValue-- Gibt zurück:
- the date value of the given String or a default value
-
parseBoolean
Tries to figure out the boolean value of the given String or returns a default value if it can't.- Parameter:
aObject-aDefaultValue-- Gibt zurück:
- the boolean value of the given String or returns a default value
-
parseParameters
public static List<String> parseParameters(String aInterceptorString, String aParameterDivider, String aBeginListDivider, String aEndListDivider) Parses the parameter given in a string an returns a list of them.- Parameter:
aInterceptorString-aParameterDivider-aBeginListDivider-aEndListDivider-- Gibt zurück:
- List of parameters
-
parseSeparatedListDouble
Returns a list with the elements that are divided by divider in a String.- Parameter:
aString-aDivider-- Gibt zurück:
- a list with the elements that are divided by divider in a String
-
removeCharacter
Replaces line feed characters with whitespaces.- Parameter:
aString-aChar-- Gibt zurück:
- converted String
-
containsSpecialCharacters
Searches the given String for special characters. Returns true, if other characters than 0-9 a-z A-Z - _ are found in the string.- Parameter:
aStringToCheck- - String to be searched for special characters- Gibt zurück:
- true, if the string contains special characters
-
containsProblematicCharacters
- Parameter:
aStringToCheck-- Gibt zurück:
- true if a given String contains problematic characters
-
containsProblematicCharacters
public static boolean containsProblematicCharacters(String aStringToCheck, boolean aAlsoCheckForHTMLEntity) Searches the given String for any of the special characters Ungültige Eingabe: "<" > $ " ' \ # % Returns true, if one of these is found.- Parameter:
aStringToCheck- - String to be searched for special charactersaAlsoCheckForHTMLEntity- - If true, HTML-Entities are checked for also, e. g. < for Ungültige Eingabe: "<"- Gibt zurück:
- true, if the string contains special characters
-
containsWebEuroSign
Searches the given String for the EURO sign as it is transmitted via the browser. Returns true, if it is found.- Parameter:
aStringToCheck- - String to be searched for special characters- Gibt zurück:
- true, if the string contains the euro sign
-
containsWebEuroSign
Searches the given String for the EURO sign as it is transmitted via the browser. Returns true, if it is found.- Parameter:
aStringToCheck- - String to be searched for special charactersaAlsoCheckForHTMLEntity-- Gibt zurück:
- true, if the string contains the euro sign
-
cutString
Cuts the tail of the given string if it exceeds a given length (minimum 3).- Parameter:
aString-aMaxLength-- Gibt zurück:
- converted String
-
findMatches
- Parameter:
pattern-s-- Gibt zurück:
- Iterable
-
replaceNullWithEmptyString
replaces Null with empty String.- Parameter:
aString-- Gibt zurück:
- empty String
-
parseSeparatedListString
Returns a list with the elements that are divided by divider in a String.- Parameter:
aString-aDivider-- Gibt zurück:
- a List of Strings
-
parseSeparatedListInteger
Returns a list with the elements that are divided by divider in a String.- Parameter:
aString-aDivider-- Gibt zurück:
- a list with the elements that are divided by divider in a String
-
unParseParameters
Parses the parameter given in a string an returns a list of them.- Parameter:
aElementCollection-aParameterDivider-- Gibt zurück:
- list of parameters
-
replaceHTMLEntities
Changes the given code to html.- Parameter:
aHTML-- Gibt zurück:
- converted String
-
replaceHTMLEntities
Changes the given code to html.- Parameter:
aHTML-aReplaceHTMLChars-- Gibt zurück:
- converted String
-
replaceAll
Replaces all entries from the map.- Parameter:
aString-aSubstitutionMap-- Gibt zurück:
- resulting String
-
transformDataType
- Parameter:
aString-aVariable-- Gibt zurück:
- Object
-
toIntArray
- Parameter:
aString-- Gibt zurück:
- Array of Integers
-
toIntArray
- Parameter:
aArray-- Gibt zurück:
- Array of Integers
-
toIntArray
- Parameter:
aArray-- Gibt zurück:
- Array of Integers
-
toDoubleArray
- Parameter:
aString-- Gibt zurück:
- Array of Doubles
-
toDateArray
- Parameter:
aValueText-- Gibt zurück:
-
toDateArray
- Parameter:
aValueText-- Gibt zurück:
-
toDoubleMatrix
- Parameter:
aValueText-- Gibt zurück:
-
toDoubleArray
- Parameter:
aArray-- Gibt zurück:
- Array of Doubles
-
toDoubleArray
- Parameter:
aArray-- Gibt zurück:
- Array of Doubles
-
toDoubleArray
- Parameter:
aArray-- Gibt zurück:
- Array of Doubles
-
toDoubleMatrix
- Parameter:
aObject-- Gibt zurück:
-
toStringArray
- Parameter:
aString-- Gibt zurück:
- Array of Strings
-
returnValidString
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- Parameter:
aUncheckedString-- Gibt zurück:
- valid file name
-
toStringForm
- Parameter:
value-- Gibt zurück:
- String
-
toStringForm
- Parameter:
matrix-- Gibt zurück:
- String
-
toStringForm
- Parameter:
value-- Gibt zurück:
- String
-
toStringForm
- Parameter:
value-- Gibt zurück:
- String
-
fullTrim
- Parameter:
aBeforePart-- Gibt zurück:
- the full trimmed String
-
splitBySize
- Parameter:
aStringToSplit-i-- Gibt zurück:
- String, split by size
-
parseIntegerPart
- Parameter:
aLineString-- Gibt zurück:
- Integer part of a given String
-
parseFloatPart
- Parameter:
aLineString-- Gibt zurück:
- Float part of a given String
-
parseIntegerToArray
- Parameter:
aIndexString-aConvertIndizes0To1-- Gibt zurück:
- Array of Integers
-
fitString
Fits the length of a String with spaces to the given length- Parameter:
aUserName-aLength-- Gibt zurück:
- the fitted String
-
round
public static double round(double aValue, int aPlaces) round the double to a "halfUp" value- Parameter:
aValue-aPlaces-- Gibt zurück:
- the rounded double
-
arrayToString
- Typparameter:
T-- Parameter:
aSumOfCutValues-aSeperator-aFile-- Löst aus:
IOException
-
arrayToString
- Parameter:
aSplit-aSeparator-- Gibt zurück:
-
convertStringToLines
-
convertLinesToStringarray
-
logFormat
-