public class PluginSentence extends AbstractPluginScoped
after=true.
When the method call return is a boolean the method is considered a assertion
and the result should be true, otherwise an error is launched. When the
result type is different of a boolean it can be stored in a scoped variable
using 'name' attribute.| Modifier and Type | Field and Description |
|---|---|
protected Boolean |
after
Flag to enable lookup method after arguments conversion.
|
protected static ICache<Class<?>,List<Method>> |
cacheMethods
Cache of type to methods annotated with sentence.
|
protected static ICache<String,Pattern> |
cachePatterns
Cache of patterns.
|
protected String |
method
Method to call.
|
protected ActionType |
type
The plugin type.
|
scopenameFEATURE_CONDITION, FEATURE_NORMALIZED, FEATURE_NORMALIZER, FEATURE_SLEEP, FEATURE_THREADSAFE, FEATURE_TIMEOUT, FEATURE_WAITparameters| Constructor and Description |
|---|
PluginSentence() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterInvoke(Method method,
IContext context,
Object returnedObject)
Perform something after method invocation.
|
void |
doEnd(IContext context,
IResultSet result)
The end action.
|
protected void |
extractMethodNameArguments(IContext context,
Object target,
StringBuilder methodName,
List<Object> arguments)
Extract text and arguments.
|
protected boolean |
fromAnnotations(String value,
Object target,
StringBuilder text,
List<Object> args)
Perform method search from annotations.
|
ActionType |
getActionType()
Get the plugin type.
|
Boolean |
getAfter()
The flag status.
|
String |
getMethod()
Get method name.
|
protected Method |
getMethodAfter(Object target,
String method,
List<Object> args)
Get object method.
|
protected Method |
getMethodBefore(Object target,
String method,
List<Object> args)
Get object method.
|
protected Object |
getObject(IContext context)
Get the object instance to be used by plugin actions.
|
protected void |
onlyArgs(IContext context,
nu.xom.Node node,
StringBuilder text,
List<Object> args)
Extract arguments from nodes.
|
protected void |
onlyText(String text,
StringBuilder methodName,
List<Object> arguments)
Extract parameters from text.
|
protected void |
prepareArgumentsAfter(IContext context,
Method method,
List<Object> arguments)
Prepare argument list, based on parameter types.
|
protected void |
prepareArgumentsBefore(IContext context,
Method method,
List<Object> arguments)
Prepare argument list, based on parameter types.
|
protected String |
removePlaceholders(Method method,
String str)
Remove place holders registered in
Placeholders. |
void |
setAfter(Boolean after)
The flag to perform method lookup after arguments conversion.
|
void |
setMethod(String method)
The method to call to this sentence.
|
getScope, saveGlobal, saveLocal, saveStrict, setScopegetName, setNamecopy, doStart, getCondition, getConditionModel, getNormalized, getNormalized, getNormalizer, getParent, getSleep, getSleepModel, getThreadsafe, getTimeout, getTimeoutModel, getWait, getWaitModel, initialize, setCondition, setConditionModel, setNormalized, setNormalizer, setParent, setSleep, setSleepModel, setThreadsafe, setTimeout, setTimeoutModel, setWait, setWaitModel, toStringgetParameters, setParametersclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetParameters, setParametersprotected ActionType type
protected String method
protected Boolean after
protected static ICache<Class<?>,List<Method>> cacheMethods
public ActionType getActionType()
IActionTypepublic String getMethod()
public void setMethod(String method)
method - The method name.public Boolean getAfter()
public void setAfter(Boolean after)
after - true, to lookup method after arguments conversion, false,
otherwise.public void doEnd(IContext context, IResultSet result) throws PluginException
IPlugindoEnd in interface IPlugindoEnd in class AbstractPlugincontext - The context.result - The result set.PluginException - On execution errors.protected Object getObject(IContext context)
context - The context.protected void extractMethodNameArguments(IContext context, Object target, StringBuilder methodName, List<Object> arguments) throws PluginException
context - The context.target - The target object.methodName - The text part.arguments - The argument objects.PluginException - On errors.protected boolean fromAnnotations(String value, Object target, StringBuilder text, List<Object> args) throws PluginException
value - The node text value.target - The target object.text - The text.args - The arguments.PluginException - On invalid placeholder replacement.protected String removePlaceholders(Method method, String str) throws PluginException
Placeholders. i.e. $int
will be replaced to '(\\d+)'.method - The method.str - The string to be replaced.PluginException - On invalid placeholder replacement.protected void onlyText(String text, StringBuilder methodName, List<Object> arguments)
text - The text.methodName - The method name.arguments - The arguments.protected void onlyArgs(IContext context, nu.xom.Node node, StringBuilder text, List<Object> args) throws PluginException
context - The context.node - The node.text - The text.args - The arguments.PluginException - On errors.protected Method getMethodBefore(Object target, String method, List<Object> args) throws PluginException
target - The object target.method - The method name.args - Possible arguments.PluginException - On method lookup errors.protected void prepareArgumentsBefore(IContext context, Method method, List<Object> arguments) throws PluginException
context - The context.method - The method.arguments - The arguments.PluginException - On preparation errors.protected Method getMethodAfter(Object target, String method, List<Object> args) throws PluginException
target - The object target.method - The method name.args - Possible arguments.PluginException - On method lookup errors.protected void prepareArgumentsAfter(IContext context, Method method, List<Object> arguments) throws PluginException
context - The context.method - The method.arguments - The arguments.PluginException - On preparation errors.protected void afterInvoke(Method method, IContext context, Object returnedObject) throws PluginException
method - Method call.context - Test context.returnedObject - Object returned by method call.PluginException - On errors.Copyright © 2016. All rights reserved.