public class Tokenator extends Object
A arbitrary metadata object ("info") can be associated with each token.
Modifier and Type | Class and Description |
---|---|
static interface |
Tokenator.Resolver
Resolves a token to its literal value.
|
static class |
Tokenator.ValueAndInfo
Return values for
getOrderedValues(String) . |
Constructor and Description |
---|
Tokenator() |
Modifier and Type | Method and Description |
---|---|
String |
detokenate(String betokened)
Given a string filled with tokens created by
nextToken(Object, String) , returns it with the tokens replaced by
the original strings. |
static String |
detokenate(String betokened,
Tokenator.Resolver resolver) |
List<Tokenator.ValueAndInfo> |
getOrderedValues(String betokened)
Returns a list of the values represented by tokens in the given string, and
the info objects corresponding to them.
|
static boolean |
hasToken(String s) |
String |
nextToken(Object info,
String resolved)
Returns a token that can be used to replace the given String, to be
restored by a later call to
detokenate(String) . |
String |
nextToken(String resolved)
Like
nextToken(String) with no info. |
public static String detokenate(String betokened, Tokenator.Resolver resolver)
public static boolean hasToken(String s)
public String detokenate(String betokened)
nextToken(Object, String)
, returns it with the tokens replaced by
the original strings.public List<Tokenator.ValueAndInfo> getOrderedValues(String betokened)
public String nextToken(Object info, String resolved)
detokenate(String)
. Associates
the token with the given info object.info
- An arbitrary object to associate with this token. Mmm, metadataresolved
- The value to replace this token with in later calls to
detokenate(String)
public String nextToken(String resolved)
nextToken(String)
with no info.Copyright © 2016. All rights reserved.