public class MapTranslator extends InvalidTokenTranslator
Modifier and Type | Field and Description |
---|---|
protected Map<String,Object> |
map
Map used to perform token translation.
|
behaviour, empty, RETURN_EMPTY_STRING, RETURN_NULL, RETURN_TOKEN_STRING
Constructor and Description |
---|
MapTranslator(Map<String,Object> map)
Constructs a mapped translator that will use the specified map to
translate the tokens into their values.
|
MapTranslator(Map<String,Object> map,
int behaviour)
Constructs a mapped translator that will use the specified map to
translate the tokens into their values and will treat illegal tokens
according to the given behaviour.
|
MapTranslator(Object[] objects)
Constructs a mapped translator that will translate the specified array
into a map, where the value is the object and the key is the string
image of the index at which the object was located in the array.
|
MapTranslator(Object[][] bindings)
Constructs a mapped translator that will translate the specified two
column array as a map, which it will use to translate the tokens into
their values.
|
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
getMap()
Returns the map whose methods the translator invokes.
|
void |
setMap(Map<String,Object> map)
Sets the map whose methods the translator will invoke.
|
String |
translate(String token)
Returns a replacement string for the original token string.
|
getBehaviour, getEmptyString, setBehaviour, setEmptyString, translateInvalidToken
public MapTranslator(Map<String,Object> map)
map
- map of token-to-value bindingspublic MapTranslator(Map<String,Object> map, int behaviour)
map
- map of token-to-value bindingsbehaviour
- behaviour when dealing with invalid tokenspublic MapTranslator(Object[][] bindings)
bindings
- array of token/value bindingspublic MapTranslator(Object[] objects)
objects
- numbered array of valuespublic Map<String,Object> getMap()
public void setMap(Map<String,Object> map)
map
- new map of token/value bindingsCopyright © 2016. All Rights Reserved.