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, 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 Details

  • Constructor Details

    • 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 Details

    • 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 interface StandardizerAction
      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 interface StandardizerAction
      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 constructor AbstractStandardizerAction(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 interface StandardizerAction
      Returns:
      true if the action is available, and can be used
    • standardize

      public final Changes standardize(Molecule molecule)
      Calls standardize1(Molecule)
      If molecule has more components standardize1(Molecule) is invoked on all components instead of the molecule itself.
      If standardize1(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's Changes.isModified() property is set based on whether molecule's MoleculeGraph.getGrinvCC() property value has changed during the standardization action.
      Specified by:
      standardize in interface StandardizerAction
      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 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.
      Logs of standardization should be generated to a Logger, that can be collected by using StandardizerLogger.getLogger() method.
      Parameters:
      molecule - the Molecule 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 this StandardizerAction instance
      Specified by:
      cloneItem in interface StandardizerAction
      Returns:
      a clone of this StandardizerAction instance
    • clone

      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • removePropertyChangeListener

      public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
      Description copied from interface: StandardizerAction
      Remove a PropertyChangeListener for a specific property. If listener was added more than once to the same event source for the specified property, it will be notified one less time after being removed. If propertyName is null, no exception is thrown and no action is taken. If listener is null, or was never added for the specified property, no exception is thrown and no action is taken.
      Specified by:
      removePropertyChangeListener in interface StandardizerAction
      Parameters:
      propertyName - The name of the property that was listened on.
      listener - The PropertyChangeListener to be removed
      See Also:
    • 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. If propertyName or listener is null, no exception is thrown and no action is taken.
      Specified by:
      addPropertyChangeListener in interface StandardizerAction
      Parameters:
      propertyName - The name of the property to listen on.
      listener - The PropertyChangeListener to be added
      See Also:
    • 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. If listener was added more than once to the same event source, it will be notified one less time after being removed. If listener is null, or was never added, no exception is thrown and no action is taken.
      Specified by:
      removePropertyChangeListener in interface StandardizerAction
      Parameters:
      listener - The PropertyChangeListener to be removed
      See Also:
    • 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. If listener is null, no exception is thrown and no action is taken.
      Specified by:
      addPropertyChangeListener in interface StandardizerAction
      Parameters:
      listener - The PropertyChangeListener to be added
      See Also:
    • setLicenseEnvironment

      public void setLicenseEnvironment(String env)
      Description copied from interface: StandardizerAction
      Sets the license environment of the action
      Specified by:
      setLicenseEnvironment in interface chemaxon.license.Licensable
      Specified by:
      setLicenseEnvironment in interface StandardizerAction
      Parameters:
      env - the license environment of the action
    • isLicensed

      public boolean isLicensed()
      Specified by:
      isLicensed in interface chemaxon.license.Licensable
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface PropertyChangeListener
    • getID

      public String getID()
      Gets the identifier string of the standardizer action.
      Specified by:
      getID in interface StandardizerAction
      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 interface StandardizerAction
      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 interface StandardizerAction
      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 question
      keys - 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