|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ls.util.text.StringTools
This class contains several implementations to manipulate Strings.
Usage example:
Map replacements = new HashMap(); replacements.put("a1", "value for 'a'"); replacements.put("a2", "value for 'a2'"); replacements.put("b1", "unused value for 'b'"); StringTools.replace(sourcString, replacements); System.out.println(replacementMap.replace("This String contains text like a1 and a2"));The output of this example would be
this String contains the variables value for 'a' and value for 'a2' and
Constructor Summary | |
StringTools()
|
Method Summary | |
static String |
removePattern(String encodedString,
String removement)
Remove a patterns from the sourceString |
static String |
removePatterns(String encodedString,
List replacementList)
Remove all patterns in the replacementList from the sourceString and return it |
static String |
removePatterns(String encodedString,
String[] replacementList)
Remove all patterns in the replacementList from the sourceString and return it |
static String |
replacePattern(String encodedString,
String pattern,
char replacement)
Decodes the pattern with the replacement in the source string and returns the decoded string. |
static String |
replacePattern(String encodedString,
String pattern,
String replacement)
Decodes the pattern with the replacement in the source string and returns the decoded string. |
static String |
replacePatterns(String encodedString,
Map replacementMap)
Decodes all variables defined in this ReplacementMap in the given argument. If the encodedString or the replacementMap is null the encodedString will be returned unencoded like it got passed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StringTools()
Method Detail |
public static String removePatterns(String encodedString, String[] replacementList)
encodedString
- string to decodereplacementList
- A list of patterns that should be removed from the source String.public static String removePatterns(String encodedString, List replacementList)
encodedString
- string to decodereplacementList
- A list of patterns that should be removed from the source String.public static String removePattern(String encodedString, String removement)
encodedString
- string to decoderemovement
- The String that should be removed from the source Stringpublic static String replacePatterns(String encodedString, Map replacementMap)
If the encodedString or the replacementMap is null the encodedString will be returned unencoded like it got passed.
encodedString
- string to decodereplacementMap
- The map with the source Strings (keys)
and the target Strings (values)public static String replacePattern(String encodedString, String pattern, String replacement)
encodedString
- string to decodepattern
- The pattern that should be replaced by the replacementreplacement
- The replacement of the search patternpublic static String replacePattern(String encodedString, String pattern, char replacement)
encodedString
- string to decodepattern
- The pattern that should be replaced by the replacementreplacement
- the replace ment charecter
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |