Package de.xima.fc.helper
Class PlaceholderStringTokenizer
- java.lang.Object
-
- de.xima.fc.helper.PlaceholderStringTokenizer
-
public final class PlaceholderStringTokenizer extends Object
Helper for splitting strings containing placeholders into the surrounding text and the placeholders.- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPlaceholderStringTokenizer.PlaceholderStringLiteralTokenRepresents a non-placeholder part of a string.static classPlaceholderStringTokenizer.PlaceholderStringPlaceholderTokenRepresents a placeholder part of a string.static classPlaceholderStringTokenizer.PlaceholderStringTokenRepresents either a literal (non-placeholder) or placeholder part of a string.
-
Constructor Summary
Constructors Constructor Description PlaceholderStringTokenizer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringstringify(Iterable<PlaceholderStringTokenizer.PlaceholderStringToken> tokens)Takes a list of parts produced bytokenize(String)and converts it back into a string.static List<PlaceholderStringTokenizer.PlaceholderStringToken>tokenize(String value)Takes a string that may contain placeholders and splits it into the literal (non-placeholder) parts and the placeholder parts.
-
-
-
Method Detail
-
stringify
public static final String stringify(Iterable<PlaceholderStringTokenizer.PlaceholderStringToken> tokens)
Takes a list of parts produced bytokenize(String)and converts it back into a string.- Parameters:
tokens- Tokens to convert back into a string.- Returns:
- The string that represents the tokens.
-
tokenize
public static final List<PlaceholderStringTokenizer.PlaceholderStringToken> tokenize(String value)
Takes a string that may contain placeholders and splits it into the literal (non-placeholder) parts and the placeholder parts. For example,hello [%tf1%] worldwould be split into the literal<hello >, the placeholder<tf1>, and the literal< world>.- Parameters:
value- A string to split that may contain placeholders.- Returns:
- The parts of the string, each element is either a
PlaceholderStringTokenizer.PlaceholderStringLiteralTokenorPlaceholderStringTokenizer.PlaceholderStringPlaceholderToken.
-
-