Package chemaxon.standardizer
Class AbstractStandardizerAction
java.lang.Object
chemaxon.standardizer.AbstractStandardizerAction
- All Implemented Interfaces:
chemaxon.license.Licensable
,StandardizerAction
,PropertyChangeListener
,Cloneable
,EventListener
- Direct Known Subclasses:
AbsoluteStereoAction
,AbstractSgroupAction
,AddExplicitHydrogensAction
,AliasToAtomAction
,AliasToGroupAction
,AromatizeAction
,Clean2DAction
,Clean3DAction
,ClearIsotopesAction
,ClearStereoAction
,ConvertDoubleBondsAction
,ConvertPiMetalBondsAction
,ConvertToEnhancedStereoAction
,CreateGroupAction
,DearomatizeAction
,DisconnectMetalAtomsAction
,ExpandAction
,MapAction
,MapReactionAction
,MesomerizeAction
,NeutralizeAction
,RearrangeReactionAction
,RemoveAbsoluteStereoAction
,RemoveAtomValuesAction
,RemoveAttachedDataAction
,RemoveExplicitHydrogensAction
,RemoveFragmentAction
,RemoveRGroupDefinitionsAction
,RemoveSolventsAction
,RemoveStereoCareBoxAction
,ReplaceAtomsAction
,SetAbsoluteStereoAction
,SetHydrogenIsotopeSymbolAction
,StripSaltsAction
,TautomerizeAction
,TransformAction
,UnmapAction
,WedgeCleanAction
@PublicApi
public abstract class AbstractStandardizerAction
extends Object
implements StandardizerAction, chemaxon.license.Licensable, Cloneable, PropertyChangeListener
Abstract implementation of the
StandardizerAction
.
The abstract implementation manages license checking, availability, validity
of the action, manages the Changes, and collecting information for mapping.
The standardization process of the target molecule must be implemented by the
method standardize1(Molecule)
Special molecules containing more components (e.g. RgMolecule
,
RxnMolecule
) are decomponented by the method
getComponents(Molecule)
, and standardize1(Molecule)
method
is called on each component, before applied on the original molecule. If a
descendant does not want this to occur, this method must be overridden.
- Since:
- 5.11
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The key of configuration path parameter of the abstract action.static final String
The key of the molecule format parameter of the abstract action.static final String
The key of the ID parameter of the abstract action.protected PropertyChangeSupport
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractStandardizerAction
(Map<String, String> params) Initializes the functionality of the abstract implementation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a PropertyChangeListener to the listener list.void
addPropertyChangeListener
(String propertyName, PropertyChangeListener listener) Add a PropertyChangeListener for a specific property.protected boolean
anyBooleanPropertyTrue
(Map<String, String> params, String... keys) Check the given map, whether there is a String 'true' (case in-sensitive) value for any of the given keysclone()
Returns a clone of thisStandardizerAction
instancegetComponents
(Molecule molecule) A recursive algorithm getting all components (reactants, agents and products of reaction molecules, R-group definitions of Rg-Molecules) of the molecule.Gets the descriptor of the standardizer action.getID()
Gets the identifier string of the standardizer action.boolean
isActive()
Returns true if the action is active, and can be usedboolean
Returns true if the action is available, and can be usedboolean
boolean
isValid()
Returns true if the action's parameters are valid, false otherwisevoid
void
Remove a PropertyChangeListener from the listener list.void
removePropertyChangeListener
(String propertyName, PropertyChangeListener listener) Remove a PropertyChangeListener for a specific property.void
setActive
(boolean active) Sets whether the action is active, and can be usedvoid
Sets the identifier string of the standardizer actionvoid
Sets the license environment of the actionvoid
setValid
(boolean valid) Sets the validity of the standardizer action.final Changes
standardize
(Molecule molecule) Callsstandardize1(Molecule)
If molecule has more componentsstandardize1(Molecule)
is invoked on all components instead of the molecule itself.
Ifstandardize1(Molecule)
doesn't return a not null Change object for the molecule or for any of the components the value of the returned changes object'sChanges.isModified()
property is set based on whether molecule'sMoleculeGraph.getGrinvCC()
property value has changed during the standardization action.protected abstract Changes
standardize1
(Molecule molecule) This method contains the current standardization mechanism.toString()
-
Field Details
-
CONFIG_PATH_KEY
The key of configuration path parameter of the abstract action. The map provided in the constructorAbstractStandardizerAction(Map)
may contain the value of the path of the configuration defined by this key.- See Also:
-
ID_KEY
The key of the ID parameter of the abstract action. The map provided in the constructorAbstractStandardizerAction(Map)
may contain the value of the identifier of the action defined by this key.- See Also:
-
FORMAT_KEY
The key of the molecule format parameter of the abstract action. The map provided in the constructorAbstractStandardizerAction(Map)
may contain the value of the identifier of the action defined by this key.- See Also:
-
support
-
-
Constructor Details
-
AbstractStandardizerAction
Initializes the functionality of the abstract implementation. Sets the ID of the action, if it is provided, and starts property change observing on the descriptor- Parameters:
params
- the parameters of the action in a map representation
-
-
Method Details
-
getDescriptor
Description copied from interface:StandardizerAction
Gets the descriptor of the standardizer action. Contains all necessary informations of the action for user interfaces.- Specified by:
getDescriptor
in interfaceStandardizerAction
- Returns:
- the descriptor of the standardizer action.
-
isValid
public boolean isValid()Description copied from interface:StandardizerAction
Returns true if the action's parameters are valid, false otherwise- Specified by:
isValid
in interfaceStandardizerAction
- Returns:
- true if the action's parameters are valid, false otherwise
-
setValid
public void setValid(boolean valid) Sets the validity of the standardizer action. The validity of the standardizer action depends on the validity of the provided parameters of the constructorAbstractStandardizerAction(Map)
If a descendant standardizer action has an invalid parameter, the validity should be false.
- Parameters:
valid
- the validity of the standardizer action
-
isAvailable
public boolean isAvailable()Description copied from interface:StandardizerAction
Returns true if the action is available, and can be used- Specified by:
isAvailable
in interfaceStandardizerAction
- Returns:
- true if the action is available, and can be used
-
standardize
Callsstandardize1(Molecule)
If molecule has more componentsstandardize1(Molecule)
is invoked on all components instead of the molecule itself.
Ifstandardize1(Molecule)
doesn't return a not null Change object for the molecule or for any of the components the value of the returned changes object'sChanges.isModified()
property is set based on whether molecule'sMoleculeGraph.getGrinvCC()
property value has changed during the standardization action.- Specified by:
standardize
in interfaceStandardizerAction
- Parameters:
molecule
- the target molecule of the standardization process- Returns:
- the change set of the molecule
-
standardize1
This method contains the current standardization mechanism. Descendants needs to implement this method.
Special molecules containing more components (e.g.RgMolecule
,RxnMolecule
) are decomponented by the methodgetComponents(Molecule)
, andstandardize1(Molecule)
method is called on each component, before applied on the original molecule. If a descendant does not want this to occur, this method must be overridden.
Logs of standardization should be generated to aLogger
, that can be collected by usingStandardizerLogger.getLogger()
method.- Parameters:
molecule
- theMolecule
instance to be standardized- Returns:
- the changes applied on the molecule during the standardization process
- Throws:
IllegalArgumentException
- if the provided molecule or the provided parameters of the action are invalid
-
cloneItem
Description copied from interface:StandardizerAction
Returns a clone of thisStandardizerAction
instance- Specified by:
cloneItem
in interfaceStandardizerAction
- Returns:
- a clone of this
StandardizerAction
instance
-
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
removePropertyChangeListener
Description copied from interface:StandardizerAction
Remove a PropertyChangeListener for a specific property. Iflistener
was added more than once to the same event source for the specified property, it will be notified one less time after being removed. IfpropertyName
is null, no exception is thrown and no action is taken. Iflistener
is null, or was never added for the specified property, no exception is thrown and no action is taken.- Specified by:
removePropertyChangeListener
in interfaceStandardizerAction
- Parameters:
propertyName
- The name of the property that was listened on.listener
- The PropertyChangeListener to be removed- See Also:
-
addPropertyChangeListener
Description copied from interface:StandardizerAction
Add a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property. The same listener object may be added more than once. For each property, the listener will be invoked the number of times it was added for that property. IfpropertyName
orlistener
is null, no exception is thrown and no action is taken.- Specified by:
addPropertyChangeListener
in interfaceStandardizerAction
- Parameters:
propertyName
- The name of the property to listen on.listener
- The PropertyChangeListener to be added- See Also:
-
removePropertyChangeListener
Description copied from interface:StandardizerAction
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties. Iflistener
was added more than once to the same event source, it will be notified one less time after being removed. Iflistener
is null, or was never added, no exception is thrown and no action is taken.- Specified by:
removePropertyChangeListener
in interfaceStandardizerAction
- Parameters:
listener
- The PropertyChangeListener to be removed- See Also:
-
addPropertyChangeListener
Description copied from interface:StandardizerAction
Add a PropertyChangeListener to the listener list. The listener is registered for all properties. The same listener object may be added more than once, and will be called as many times as it is added. Iflistener
is null, no exception is thrown and no action is taken.- Specified by:
addPropertyChangeListener
in interfaceStandardizerAction
- Parameters:
listener
- The PropertyChangeListener to be added- See Also:
-
setLicenseEnvironment
Description copied from interface:StandardizerAction
Sets the license environment of the action- Specified by:
setLicenseEnvironment
in interfacechemaxon.license.Licensable
- Specified by:
setLicenseEnvironment
in interfaceStandardizerAction
- Parameters:
env
- the license environment of the action
-
isLicensed
public boolean isLicensed()- Specified by:
isLicensed
in interfacechemaxon.license.Licensable
-
toString
-
propertyChange
- Specified by:
propertyChange
in interfacePropertyChangeListener
-
getID
Gets the identifier string of the standardizer action.- Specified by:
getID
in interfaceStandardizerAction
- Returns:
- the identifier string of the standardizer action
-
setID
Sets the identifier string of the standardizer action- Parameters:
id
- the identifier string of the standardizer action
-
isActive
public boolean isActive()Description copied from interface:StandardizerAction
Returns true if the action is active, and can be used- Specified by:
isActive
in interfaceStandardizerAction
- Returns:
- true if the action is active, and can be used
-
setActive
public void setActive(boolean active) Description copied from interface:StandardizerAction
Sets whether the action is active, and can be used- Specified by:
setActive
in interfaceStandardizerAction
- Parameters:
active
- whether the action should be active, and can be used
-
anyBooleanPropertyTrue
Check the given map, whether there is a String 'true' (case in-sensitive) value for any of the given keys- Parameters:
params
- The map in questionkeys
- array of one or more keys, which values we are interested in- Returns:
- true is returned if 'true' (case in-sensitive) is found for any key in the map, 'false' otherwise
-
getComponents
A recursive algorithm getting all components (reactants, agents and products of reaction molecules, R-group definitions of Rg-Molecules) of the molecule. Used to collect all. If components must not be standardized, this method should be overridden.- Parameters:
molecule
- the target molecule- Returns:
- the resulted list of components
-