Package chemaxon.standardizer.runner
Class BasicStandardizerRunner
- java.lang.Object
-
- chemaxon.standardizer.runner.BasicStandardizerRunner
-
- All Implemented Interfaces:
StandardizerActionRunner
,Cloneable
@PublicAPI public class BasicStandardizerRunner extends Object implements StandardizerActionRunner
This is the default implementation ofStandardizerActionRunner
interface.
If the provided molecule is null or contains errors
IllegalArgumentException
should be thrown during the standardization procedure.
Logs are generated to a
Logger
, that can be collected by usingStandardizerLogger.getLogger()
method.- Since:
- 5.11
-
-
Field Summary
Fields Modifier and Type Field Description protected Thread
backgroundThread
protected Molecule
molecule
TheMolecule
instance to standardize
-
Constructor Summary
Constructors Constructor Description BasicStandardizerRunner(StandardizerConfigurationReader configurationReader)
Initialize aBasicStandardizerRunner
instance with theStandardizerConfiguration
read from the provided configuration reader.BasicStandardizerRunner(StandardizerConfiguration configuration)
Initialize aBasicStandardizerRunner
instance with specifiedStandardizerConfiguration
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPropertyChangeListener(PropertyChangeListener changeListener)
Adds aPropertyChangeListener
that will receive all thePropertyChangeEvent
fired by this classvoid
addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
Adds aPropertyChangeListener
that will receive thePropertyChangeEvent
fired when the property with the given name is changedvoid
cancel()
Stops the background threadBasicStandardizerRunner
clone()
List<StandardizerAction>
getAppliedActions()
Gets the list of actions applied in the configuration at the last executionList<Changes>
getChanges()
Gets the list of changes applied on the molecule.protected PropertyChangeSupport
getChangeSupport()
Returns the changeSupportStandardizerConfiguration
getConfiguration()
Gets the configuration of the runnerint
getCurrent()
Gets the current progress percentString
getCurrentActionName()
Gets whichStandardizerAction
instance run currentlyprotected int
getIndex()
Returns the index of the actual action of the configurationMolecule
getMolecule()
Returns the target moleculeint
getProgessLength()
Gets the length of the standardization processprotected Runnable
getStrategy()
Returns the strategy to use.String[]
getTargetGroups()
Gets the target action groups of the standardizerprotected boolean
isCanceled()
Returns whether the process is cancelledboolean
isRunning()
This function identifies the state of the standardizer threadprotected void
setCanceled(boolean canceled)
Sets whether the process is cancelledprotected void
setChangeSupport(PropertyChangeSupport changeSupport)
Sets the changeSupportvoid
setConfiguration(StandardizerConfiguration configuration)
Sets the configuration of the runnervoid
setConfigurationReader(StandardizerConfigurationReader configurationReader)
Sets a new configuration for the runner.void
setIgnoreConfigurationErrors(boolean ignore)
Sets whether configuration errors should be ignoredprotected void
setIndex(int index)
Sets the index of the actual action of the configurationvoid
setLicenseEnvironment(String env)
Sets the license environment of the runnervoid
setMolecule(Molecule molecule)
Sets the molecule to be standardized by the standardizer actionsvoid
setTargetGroup(String groupName)
Sets the target group of standardizer action of the runnervoid
setTargetGroups(String... groupNames)
Sets the target groups of standardizer action of the runnervoid
standardize()
Invoke a background thread which will run all standardizer actions on the given moleculeList<Changes>
standardizeAndWait()
Executes all standardizer actions contained by the pre-set configuration on the given molecule and returns the list of applied changes.
-
-
-
Constructor Detail
-
BasicStandardizerRunner
public BasicStandardizerRunner(StandardizerConfigurationReader configurationReader)
Initialize aBasicStandardizerRunner
instance with theStandardizerConfiguration
read from the provided configuration reader.- Parameters:
configurationReader
- aStandardizerConfigurationReader
instance, containing the configuration of the standardization process
-
BasicStandardizerRunner
public BasicStandardizerRunner(StandardizerConfiguration configuration)
Initialize aBasicStandardizerRunner
instance with specifiedStandardizerConfiguration
.- Parameters:
configuration
- the configuration of the standardization procedure
-
-
Method Detail
-
setConfigurationReader
public void setConfigurationReader(StandardizerConfigurationReader configurationReader)
Description copied from interface:StandardizerActionRunner
Sets a new configuration for the runner.- Specified by:
setConfigurationReader
in interfaceStandardizerActionRunner
- Parameters:
configurationReader
- is theStandardizerConfigurationReader
instance which provides the current configuration
-
setMolecule
public void setMolecule(Molecule molecule)
Description copied from interface:StandardizerActionRunner
Sets the molecule to be standardized by the standardizer actions- Specified by:
setMolecule
in interfaceStandardizerActionRunner
- Parameters:
molecule
- aMolecule
instance to be standardized
-
standardize
public void standardize() throws IllegalArgumentException
Description copied from interface:StandardizerActionRunner
Invoke a background thread which will run all standardizer actions on the given molecule- Specified by:
standardize
in interfaceStandardizerActionRunner
- Throws:
IllegalArgumentException
- if the configuration or the molecule contains errors
-
cancel
public void cancel()
Description copied from interface:StandardizerActionRunner
Stops the background thread- Specified by:
cancel
in interfaceStandardizerActionRunner
-
getCurrent
public int getCurrent()
Description copied from interface:StandardizerActionRunner
Gets the current progress percent- Specified by:
getCurrent
in interfaceStandardizerActionRunner
- Returns:
- the current progress percent
-
getCurrentActionName
public String getCurrentActionName()
Description copied from interface:StandardizerActionRunner
Gets whichStandardizerAction
instance run currently- Specified by:
getCurrentActionName
in interfaceStandardizerActionRunner
- Returns:
- which
StandardizerAction
instance run currently
-
getProgessLength
public int getProgessLength()
Description copied from interface:StandardizerActionRunner
Gets the length of the standardization process- Specified by:
getProgessLength
in interfaceStandardizerActionRunner
- Returns:
- the length of the standardization process
-
isRunning
public boolean isRunning()
Description copied from interface:StandardizerActionRunner
This function identifies the state of the standardizer thread- Specified by:
isRunning
in interfaceStandardizerActionRunner
- Returns:
- true if the background thread runs false otherwise
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener changeListener)
Description copied from interface:StandardizerActionRunner
Adds aPropertyChangeListener
that will receive all thePropertyChangeEvent
fired by this class- Specified by:
addPropertyChangeListener
in interfaceStandardizerActionRunner
- Parameters:
changeListener
- aPropertyChangeListener
instance
-
addPropertyChangeListener
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
Description copied from interface:StandardizerActionRunner
Adds aPropertyChangeListener
that will receive thePropertyChangeEvent
fired when the property with the given name is changed- Specified by:
addPropertyChangeListener
in interfaceStandardizerActionRunner
- Parameters:
propertyName
- the name of the property to be listenedlistener
- aPropertyChangeListener
instance
-
standardizeAndWait
public List<Changes> standardizeAndWait() throws IllegalArgumentException
Description copied from interface:StandardizerActionRunner
Executes all standardizer actions contained by the pre-set configuration on the given molecule and returns the list of applied changes. For each action of the configuration there is a change object (or null) in the list.- Specified by:
standardizeAndWait
in interfaceStandardizerActionRunner
- Returns:
- the list of changes applied on the molecule
- Throws:
IllegalArgumentException
- if the configuration or the molecule contains errors
-
getStrategy
protected Runnable getStrategy()
Returns the strategy to use.- Returns:
- the strategy
-
setCanceled
protected void setCanceled(boolean canceled)
Sets whether the process is cancelled- Parameters:
canceled
- whether the process should be cancelled
-
isCanceled
protected boolean isCanceled()
Returns whether the process is cancelled- Returns:
- whether the process is cancelled
-
setIndex
protected void setIndex(int index)
Sets the index of the actual action of the configuration- Parameters:
index
- the index of the actual action of the configuration
-
getIndex
protected int getIndex()
Returns the index of the actual action of the configuration- Returns:
- the index of the actual action of the configuration
-
setConfiguration
public void setConfiguration(StandardizerConfiguration configuration)
Description copied from interface:StandardizerActionRunner
Sets the configuration of the runner- Specified by:
setConfiguration
in interfaceStandardizerActionRunner
- Parameters:
configuration
- the configuration to be set to the runner
-
getMolecule
public Molecule getMolecule()
Returns the target molecule- Returns:
- the target molecule
-
setChangeSupport
protected void setChangeSupport(PropertyChangeSupport changeSupport)
Sets the changeSupport- Parameters:
changeSupport
- the changeSupport to be set
-
getChangeSupport
protected PropertyChangeSupport getChangeSupport()
Returns the changeSupport- Returns:
- the changeSupport
-
getConfiguration
public StandardizerConfiguration getConfiguration()
Description copied from interface:StandardizerActionRunner
Gets the configuration of the runner- Specified by:
getConfiguration
in interfaceStandardizerActionRunner
- Returns:
- the configuration of the runner
-
getAppliedActions
public List<StandardizerAction> getAppliedActions()
Description copied from interface:StandardizerActionRunner
Gets the list of actions applied in the configuration at the last execution- Specified by:
getAppliedActions
in interfaceStandardizerActionRunner
- Returns:
- the list of applied actions at the last execution
-
setTargetGroup
public void setTargetGroup(String groupName)
Description copied from interface:StandardizerActionRunner
Sets the target group of standardizer action of the runner- Specified by:
setTargetGroup
in interfaceStandardizerActionRunner
- Parameters:
groupName
- the name of the group of standardizer actions
-
setTargetGroups
public void setTargetGroups(String... groupNames)
Description copied from interface:StandardizerActionRunner
Sets the target groups of standardizer action of the runner- Specified by:
setTargetGroups
in interfaceStandardizerActionRunner
- Parameters:
groupNames
- the names of the groups of standardizer actions
-
getTargetGroups
public String[] getTargetGroups()
Gets the target action groups of the standardizer- Returns:
- the target action groups of the standardizer
-
clone
public BasicStandardizerRunner clone() throws CloneNotSupportedException
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
setLicenseEnvironment
public void setLicenseEnvironment(String env)
Description copied from interface:StandardizerActionRunner
Sets the license environment of the runner- Specified by:
setLicenseEnvironment
in interfaceStandardizerActionRunner
- Parameters:
env
- the license environment of the runner
-
getChanges
public List<Changes> getChanges()
Description copied from interface:StandardizerActionRunner
Gets the list of changes applied on the molecule. For each action of the configuration there is a change object (or null) in the list.- Specified by:
getChanges
in interfaceStandardizerActionRunner
- Returns:
- the list of changes applied on the molecule
-
setIgnoreConfigurationErrors
public void setIgnoreConfigurationErrors(boolean ignore)
Description copied from interface:StandardizerActionRunner
Sets whether configuration errors should be ignored- Specified by:
setIgnoreConfigurationErrors
in interfaceStandardizerActionRunner
- Parameters:
ignore
- whether configuration errors should be ignored
-
-