public abstract class AbstractOptionsParser extends Object
AbstractPluginOptions
Modifier and Type | Field and Description |
---|---|
boolean |
apiCall
If true plugin is run from parametrised constructor what usually means API.
|
protected QuimpException.MessageSinkTypes |
errorSink
Indicate that plugin is run as macro from script.
|
protected org.slf4j.Logger |
logger
The Constant logger.
|
protected AbstractPluginOptions |
options |
Modifier | Constructor and Description |
---|---|
protected |
AbstractOptionsParser()
This default constructor must be overridden in concrete class.
|
protected |
AbstractOptionsParser(AbstractPluginOptions options)
Default constructor.
|
protected |
AbstractOptionsParser(String argString,
AbstractPluginOptions options)
Constructor that allows to provide own parameter string.
|
Modifier and Type | Method and Description |
---|---|
AbstractPluginOptions |
getOptions()
Return
options . |
protected boolean |
parseArgumentString(String arg)
Analyse and parse parameter string passed from IJ, macro or API.
|
protected void |
publishMacroString(String commandName)
Helper, show macro parameters string if recorder is active.
|
public boolean apiCall
protected final org.slf4j.Logger logger
protected AbstractPluginOptions options
protected QuimpException.MessageSinkTypes errorSink
Use this variable in child class together with apiCall
to decide whether to show
message in UI or console. the following rules applies:
protected AbstractOptionsParser()
AbstractPluginOptions
class should be
created there and then passed to AbstractOptionsParser(AbstractPluginOptions)
.protected AbstractOptionsParser(AbstractPluginOptions options)
Set apiCall
to false and assign provided options to object.
options
- Reference to plugin configuration container.protected AbstractOptionsParser(String argString, AbstractPluginOptions options) throws QuimpPluginException
Intended to run from API. Set apiCall
to true and errorSink
to
QuimpException.MessageSinkTypes.CONSOLE
.
AbstractPluginOptions
is initialised from specified string and assigned to this
instance.
argString
- parameters string like that passed in macro. If it is empty string or null
constructor exits before deserialisation.options
- Reference to plugin configuration container.QuimpPluginException
- on any error in plugin execution.protected boolean parseArgumentString(String arg) throws QuimpPluginException
If arg is empty or null, parseArgumentString(String)
tries to get it from Macro, if
succeeds it parses it and returns true. Otherwise returns false. If arg is non-empty it assumes
Macro call, sets errorSink
to QuimpException.MessageSinkTypes.IJERROR
and parses arg
returning true. apiCall
is set to false.
If parser succeeded, internal AbstractPluginOptions
object is properly initalised
and deserialised.
arg
- parameter stringQuimpPluginException
- when parsing failedAbstractPluginOptions
,
getOptions()
public AbstractPluginOptions getOptions()
options
.protected void publishMacroString(String commandName)
Perform serialisation of AbstractPluginOptions
object composed with this
class.
commandName
- name of the command to be displayed in IJ. Usually it is string taken from
plugins.confCopyright © 2002–2019 Department of Computer Science, Warwick University. All rights reserved.