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
,chemaxon.standardizer.actions.AbstractSgroupAction
,AddExplicitHydrogensAction
,AliasToAtomAction
,AliasToGroupAction
,AromatizeAction
,Clean2DAction
,Clean3DAction
,ClearIsotopesAction
,ClearStereoAction
,ConvertDoubleBondsAction
,ConvertPiMetalBondsAction
,ConvertToEnhancedStereoAction
,CreateGroupAction
,DearomatizeAction
,DisconnectMetalAtomsAction
,ExpandAction
,MapAction
,MapReactionAction
,MesomerizeAction
,NeutralizeAction
,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 theStandardizerAction
.
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 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.- Since:
- 5.11
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONFIG_PATH_KEY
The key of configuration path parameter of the abstract action.static String
FORMAT_KEY
The key of the molecule format parameter of the abstract action.static String
ID_KEY
The key of the ID parameter of the abstract action.protected PropertyChangeSupport
support
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractStandardizerAction(Map<String,String> params)
Initializes the functionality of the abstract implementation.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addPropertyChangeListener(PropertyChangeListener listener)
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 keysAbstractStandardizerAction
clone()
StandardizerAction
cloneItem()
Returns a clone of thisStandardizerAction
instanceprotected List<Molecule>
getComponents(Molecule molecule)
A recursive algorithm getting all components (reactants, agents and products of reaction molecules, R-group definitions of Rg-Molecules) of the molecule.StandardizerActionDescriptor
getDescriptor()
Gets the descriptor of the standardizer action.String
getID()
Gets the identifier string of the standardizer action.boolean
isActive()
Returns true if the action is active, and can be usedboolean
isAvailable()
Returns true if the action is available, and can be usedboolean
isLicensed()
boolean
isValid()
Returns true if the action's parameters are valid, false otherwisevoid
propertyChange(PropertyChangeEvent evt)
void
removePropertyChangeListener(PropertyChangeListener listener)
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
setID(String id)
Sets the identifier string of the standardizer actionvoid
setLicenseEnvironment(String env)
Sets the license environment of the actionvoid
setValid(boolean valid)
Sets the validity of the standardizer action.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.String
toString()
-
-
-
Field Detail
-
CONFIG_PATH_KEY
public static final String 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:
- Constant Field Values
-
ID_KEY
public static final String 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:
- Constant Field Values
-
FORMAT_KEY
public static final String 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:
- Constant Field Values
-
support
protected PropertyChangeSupport support
-
-
Constructor Detail
-
AbstractStandardizerAction
protected AbstractStandardizerAction(Map<String,String> params)
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 Detail
-
getDescriptor
public StandardizerActionDescriptor 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
public 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.- Specified by:
standardize
in interfaceStandardizerAction
- Parameters:
molecule
- the target molecule of the standardization process- Returns:
- the change set of the molecule
-
standardize1
protected abstract Changes standardize1(Molecule molecule) throws IllegalArgumentException
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
public StandardizerAction 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
public AbstractStandardizerAction clone() throws CloneNotSupportedException
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
removePropertyChangeListener
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
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:
PropertyChangeSupport.removePropertyChangeListener(String, PropertyChangeListener)
-
addPropertyChangeListener
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
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:
PropertyChangeSupport.addPropertyChangeListener(String, PropertyChangeListener)
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
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:
PropertyChangeSupport.removePropertyChangeListener(PropertyChangeListener)
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
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:
PropertyChangeSupport.addPropertyChangeListener(PropertyChangeListener)
-
setLicenseEnvironment
public void setLicenseEnvironment(String env)
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
-
propertyChange
public void propertyChange(PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacePropertyChangeListener
-
getID
public String getID()
Gets the identifier string of the standardizer action.- Specified by:
getID
in interfaceStandardizerAction
- Returns:
- the identifier string of the standardizer action
-
setID
public void setID(String id)
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
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 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
protected List<Molecule> getComponents(Molecule molecule)
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
-
-