public class ReflectionTranslator extends InvalidTokenTranslator
behaviour, empty, RETURN_EMPTY_STRING, RETURN_NULL, RETURN_TOKEN_STRING
Constructor and Description |
---|
ReflectionTranslator()
Constructs a self-reflecting reflection translator, i.e.
|
ReflectionTranslator(Object object)
Constructs a reflection translator that will operate on the specified
object.
|
ReflectionTranslator(Object object,
int behaviour)
Constructs a reflection translator that will operate on the specified
object and will treat illegal tokens according to the given behaviour.
|
Modifier and Type | Method and Description |
---|---|
protected Method |
getMethod(String name,
Object o)
Returns the named method declared by the class, or any superclasses, of
the current object.
|
Object |
getObject()
Returns the object whose methods the reflection translator invokes.
|
void |
setObject(Object object)
Sets the object whose methods the reflection translator will invoke.
|
String |
translate(String token)
Translates the given token with the value of method invocation, where
the name of the method is the same as the value of the token and the
object on which it is invoked is the object currently set on this
translator.
|
getBehaviour, getEmptyString, setBehaviour, setEmptyString, translateInvalidToken
public ReflectionTranslator()
public ReflectionTranslator(Object object)
object
- context object for reflection-based translationpublic ReflectionTranslator(Object object, int behaviour)
object
- context object for reflection-based translationbehaviour
- behaviour for dealing with invalid valuespublic Object getObject()
public void setObject(Object object)
object
- new context objectpublic String translate(String token)
token
- original token stringCopyright © 2015. All Rights Reserved.