Package de.xima.fc.helper
Class PlaceholderStringTokenizer
java.lang.Object
de.xima.fc.helper.PlaceholderStringTokenizer
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 ClassesModifier and TypeClassDescriptionstatic final class
Represents a non-placeholder part of a string.static final class
Represents a placeholder part of a string.static class
Represents either a literal (non-placeholder) or placeholder part of a string. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final String
Takes a list of parts produced bytokenize(String)
and converts it back into a string.static final List<PlaceholderStringTokenizer.PlaceholderStringToken>
Takes a string that may contain placeholders and splits it into the literal (non-placeholder) parts and the placeholder parts.
-
Constructor Details
-
PlaceholderStringTokenizer
public PlaceholderStringTokenizer()
-
-
Method Details
-
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
Takes a string that may contain placeholders and splits it into the literal (non-placeholder) parts and the placeholder parts. For example,hello [%tf1%] world
would 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.PlaceholderStringLiteralToken
orPlaceholderStringTokenizer.PlaceholderStringPlaceholderToken
.
-