Package nl.gx.webmanager.handler.util
Class TextUtil
- java.lang.Object
-
- nl.gx.webmanager.handler.util.TextUtil
-
public class TextUtil extends Object
Various static String manipulation methods.
-
-
Constructor Summary
Constructors Constructor Description TextUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
appendRequestParameter(String baseUrl, String key, String value, String encoding)
static String[]
extractTokens(String source, String startDelimiter, String endDelimiter, boolean ignoreCase)
Extracts all tokens from a source that are enclosed by the specified start and enddelimiter.static String
filter(String source, String startDelimiter, String endDelimiter)
Filters the parts starting with thestartDelimiter
and ending with theendDelimiter
from a string.static String
join(Object[] values, String delimiter)
Concatenates the elements of an array to a String.static String
replace(String original, String token, String replacement)
static String[]
split(String string, char splitter)
Returns A array of the non-empty string tokens in the source.
-
-
-
Method Detail
-
extractTokens
public static String[] extractTokens(String source, String startDelimiter, String endDelimiter, boolean ignoreCase)
Extracts all tokens from a source that are enclosed by the specified start and enddelimiter.$ values = "pom pom <L>Link</L> en <L>link2</l> tralala."; $ $%extractTokens(values, "<L>", "</L>", false)%$ $%extractTokens(values, "<L>", "</L>", true)%$ Output - [Link][Link, link2]
- Parameters:
source
- The source from which the tokens should be extactedstartDelimiter
- The start delimiter for the requested tokensendDelimiter
- The end delimiter for the requested tokensignoreCase
- Indicates whether matching of delimiters should be case sensitive- Returns:
- The array of all tokens that are found between the delimiters in the source
-
filter
public static String filter(String source, String startDelimiter, String endDelimiter)
Filters the parts starting with thestartDelimiter
and ending with theendDelimiter
from a string.- Parameters:
source
- The original stringstartDelimiter
- The start tag of the parts that should be filteredendDelimiter
- The end tag of the parts that be filtered- Returns:
- The original string from which the parts have been removed
-
split
public static String[] split(String string, char splitter)
Returns A array of the non-empty string tokens in the source.- Parameters:
string
- The source that should be splitted into tokenssplitter
- The char that should be used as delimiter- Returns:
- The array of string tokens in the source
-
join
public static String join(Object[] values, String delimiter)
Concatenates the elements of an array to a String.
Example: print(join(elements,"+")); Output - text1+text2+text3+text4- Parameters:
values
- The values that should be joineddelimiter
- The String that is placed between the elements- Returns:
- A string containing all elements separated by the delimter
-
appendRequestParameter
public static String appendRequestParameter(String baseUrl, String key, String value, String encoding) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
-