chemaxon.checkers
Class AbstractStructureChecker

java.lang.Object
  extended by chemaxon.checkers.AbstractStructureChecker
All Implemented Interfaces:
StructureChecker, chemaxon.license.Licensable, java.beans.PropertyChangeListener, java.lang.Cloneable, java.util.EventListener
Direct Known Subclasses:
AbbreviatedGroupChecker, AromaticityErrorChecker, AttachedDataChecker, ComponentChecker, CoordinationSystemErrorChecker, DoubleBondStereoErrorChecker, ExternalStructureChecker, MetalloceneErrorChecker, MoleculeChargeChecker, RatomChecker, ReactionChecker, RgroupAttachmentErrorChecker, RgroupReferenceErrorChecker, RingStrainErrorChecker, UnbalancedReactionChecker, WedgeErrorChecker, WigglyDoubleBondChecker

public abstract class AbstractStructureChecker
extends java.lang.Object
implements StructureChecker, chemaxon.license.Licensable, java.lang.Cloneable, java.beans.PropertyChangeListener

Abstract base class of all functions checking and repairing chemical structures.

Since:
Marvin 5.3
Version:
5.7
Author:
Attila Szabo, Istvan Rabel

Field Summary
protected  StructureCheckerErrorType errorType
          The error type of the current checker.
protected  java.beans.PropertyChangeSupport propertyChangeSupport
          property change support object bound to this
 
Fields inherited from interface chemaxon.checkers.StructureChecker
PROPERTY_KEY_VALID
 
Constructor Summary
AbstractStructureChecker(StructureCheckerErrorType errorType)
          Constructor to create a Structure checker instance with the given errorType
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener for a specific property.
 StructureCheckerResult check(Molecule molecule)
          Detects a specific error in the molecule.
protected abstract  StructureCheckerResult check1(Molecule molecule)
          This method contains the current checking mechanism.
 AbstractStructureChecker clone()
           
 StructureChecker cloneItem()
          Returns a clone of this StructureChecker instance
protected  void convertResult(Molecule originalMolecule, Molecule expandedMolecule, StructureCheckerResult result, java.util.Map<MolAtom,MolAtom> atomMap, java.util.Map<MolBond,MolBond> bondMap)
          Handles the mapping of a cloned and expanded molecule result to the original molecule.
 boolean equals(java.lang.Object obj)
           
protected  Molecule expandMolecule(Molecule molecule, java.util.Map<MolAtom,MolAtom> atomMap, java.util.Map<MolBond,MolBond> bondMap)
          Returns the original molecule if no groups to expand, or the clone of the original molecule with expanded groups.
 java.lang.String getDescription()
           
 chemaxon.checkers.StructureCheckerDescriptor getDescriptor()
          Returns a StructureCheckerDescriptor instance which represents the user interface related informations of the checker
 java.lang.String getEditorClassName()
           
 java.lang.String getErrorCode()
          Returns the String represented error code of the checker (this error code should be used for external implementation support instead of StructureChecker.getErrorType())
protected  java.lang.String getErrorDescription(int errorCount)
          Generate the error description depends on erroCount
 StructureCheckerErrorType getErrorType()
           
 java.lang.String getHelpText()
          Gets the help text of the checker
 javax.swing.Icon getIcon()
          Gets the Icon of the current checker
 java.lang.String getLocalMenuName()
          Gets the local menu name of the checker
 java.lang.String getName()
          Gets the name of the checker
 int hashCode()
           
 boolean isAvailable()
          Returns true if the checker is available, and can be used
 boolean isLicensed()
          Returns information about the licensing of the product.
 boolean isValid()
          Returns true if the checker's configuration is valid, false otherwise
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener for a specific property.
 void setDescription(java.lang.String description)
          Sets the description of the checker
 void setHelpText(java.lang.String helpText)
          Sets the detailed help of the checker which will shown in the tooltip on the GUI
 void setIcon(javax.swing.Icon icon)
          Sets the icon of the checker
 void setLicenseEnvironment(java.lang.String env)
          Every license can have a modifier environment that's typically an integration environment.
 void setLocalMenuName(java.lang.String localMenuName)
          Set the local menu name of the checker
 void setMoreErrorMessage(java.lang.String moreErrorMessage)
          Sets the message which will given in the result if two or more error found
 void setName(java.lang.String name)
          Sets the name of the checker
 void setNoErrorMessage(java.lang.String noErrorMessage)
          Sets the message which will given in the result if no error found
 void setOneErrorMessage(java.lang.String oneErrorMessage)
          Sets the message which will given in the result if one error found
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

errorType

protected final StructureCheckerErrorType errorType
The error type of the current checker. It is a value so can not assigned more than once


propertyChangeSupport

protected java.beans.PropertyChangeSupport propertyChangeSupport
property change support object bound to this

Constructor Detail

AbstractStructureChecker

public AbstractStructureChecker(StructureCheckerErrorType errorType)
Constructor to create a Structure checker instance with the given errorType

Parameters:
errorType - element of StructureCheckerErrorType
Method Detail

getName

public java.lang.String getName()
Description copied from interface: StructureChecker
Gets the name of the checker

Specified by:
getName in interface StructureChecker
Returns:
a human readable name

setName

public void setName(java.lang.String name)
Description copied from interface: StructureChecker
Sets the name of the checker

Specified by:
setName in interface StructureChecker
Parameters:
name - the human readable name of the checker

setNoErrorMessage

public void setNoErrorMessage(java.lang.String noErrorMessage)
Description copied from interface: StructureChecker
Sets the message which will given in the result if no error found

Specified by:
setNoErrorMessage in interface StructureChecker
Parameters:
noErrorMessage - the error message if no error found

setOneErrorMessage

public void setOneErrorMessage(java.lang.String oneErrorMessage)
Description copied from interface: StructureChecker
Sets the message which will given in the result if one error found

Specified by:
setOneErrorMessage in interface StructureChecker
Parameters:
oneErrorMessage - the error message if one error found

setMoreErrorMessage

public void setMoreErrorMessage(java.lang.String moreErrorMessage)
Description copied from interface: StructureChecker
Sets the message which will given in the result if two or more error found

Specified by:
setMoreErrorMessage in interface StructureChecker
Parameters:
moreErrorMessage - the error message if two or more error found

getErrorDescription

protected java.lang.String getErrorDescription(int errorCount)
Generate the error description depends on erroCount

Parameters:
errorCount - number of errors found
Returns:
a human readable description about how many and which kind of errors found

getLocalMenuName

public java.lang.String getLocalMenuName()
Description copied from interface: StructureChecker
Gets the local menu name of the checker

Specified by:
getLocalMenuName in interface StructureChecker
Returns:
the name for the local menu

setLocalMenuName

public void setLocalMenuName(java.lang.String localMenuName)
Description copied from interface: StructureChecker
Set the local menu name of the checker

Specified by:
setLocalMenuName in interface StructureChecker
Parameters:
localMenuName - a String to be shown in the local menu

getHelpText

public java.lang.String getHelpText()
Description copied from interface: StructureChecker
Gets the help text of the checker

Specified by:
getHelpText in interface StructureChecker
Returns:
the help text of the checker

setHelpText

public void setHelpText(java.lang.String helpText)
Description copied from interface: StructureChecker
Sets the detailed help of the checker which will shown in the tooltip on the GUI

Specified by:
setHelpText in interface StructureChecker
Parameters:
helpText - a String to be shown in the tooltip

getIcon

public javax.swing.Icon getIcon()
Description copied from interface: StructureChecker
Gets the Icon of the current checker

Specified by:
getIcon in interface StructureChecker
Returns:
the Icon of the current checker

setIcon

public void setIcon(javax.swing.Icon icon)
Description copied from interface: StructureChecker
Sets the icon of the checker

Specified by:
setIcon in interface StructureChecker
Parameters:
icon - is an instance of Icon

check

public final StructureCheckerResult check(Molecule molecule)
                                   throws java.lang.NullPointerException,
                                          chemaxon.license.LicenseException
Description copied from interface: StructureChecker
Detects a specific error in the molecule.

Specified by:
check in interface StructureChecker
Parameters:
molecule - a Molecule instance have to be checked
Returns:
an instance of StructureCheckerResult (which contains all data needed to fix the problem) if the molecule contains the examined error, null otherwise
Throws:
java.lang.NullPointerException - if molecule is null
chemaxon.license.LicenseException

check1

protected abstract StructureCheckerResult check1(Molecule molecule)
This method contains the current checking mechanism.

Parameters:
molecule - the Molecule instance to be checked for problems
Returns:
a StructureCheckerResult which represents the problem or null if no problem found

expandMolecule

protected Molecule expandMolecule(Molecule molecule,
                                  java.util.Map<MolAtom,MolAtom> atomMap,
                                  java.util.Map<MolBond,MolBond> bondMap)
Returns the original molecule if no groups to expand, or the clone of the original molecule with expanded groups.

Parameters:
molecule - the molecule to check
Returns:
the original molecule, or a clone with expanded sgroups
Since:
5.9

convertResult

protected void convertResult(Molecule originalMolecule,
                             Molecule expandedMolecule,
                             StructureCheckerResult result,
                             java.util.Map<MolAtom,MolAtom> atomMap,
                             java.util.Map<MolBond,MolBond> bondMap)
Handles the mapping of a cloned and expanded molecule result to the original molecule.

Parameters:
originalMolecule - the original molecule
expandedMolecule - the cloned then expanded molecule
result - the structure checker result on cloned molecule
atomMap - the mapping of cloned molecule and original molecule atoms
bondMap - the mapping of cloned molecule and original molecule bonds
Since:
5.9

isLicensed

public boolean isLicensed()
Description copied from interface: chemaxon.license.Licensable
Returns information about the licensing of the product. Example implementation: return LicenseHandler.isLicensed( LicenseHandler.MY_IDENTIFIER, licenseEnvironment );

Specified by:
isLicensed in interface chemaxon.license.Licensable
Returns:
true if the product is correctly licensed

setLicenseEnvironment

public void setLicenseEnvironment(java.lang.String env)
Description copied from interface: chemaxon.license.Licensable
Every license can have a modifier environment that's typically an integration environment. All being Licensable should be prepared to store and show a set environment to the LicenseHandler. Example implementation:
 private String licenseEnvironment = "";
 public void setLicenseEnvironment(String env) {
     licenseEnvironment = env;
 }
 

Specified by:
setLicenseEnvironment in interface chemaxon.license.Licensable
Parameters:
env - environment String to be stored and passed to the LicenseHandler in the isLicensed method

getErrorType

public StructureCheckerErrorType getErrorType()
Specified by:
getErrorType in interface StructureChecker
Returns:
the error type of this checker

getErrorCode

public java.lang.String getErrorCode()
Description copied from interface: StructureChecker
Returns the String represented error code of the checker (this error code should be used for external implementation support instead of StructureChecker.getErrorType())

Specified by:
getErrorCode in interface StructureChecker
Returns:
the String represented error code of the checker (this error code should be used for external implementation support instead of StructureChecker.getErrorType())

getEditorClassName

public java.lang.String getEditorClassName()
Specified by:
getEditorClassName in interface StructureChecker
Returns:
the name of the editor class of the checker

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in interface StructureChecker
Returns:
the description

isValid

public boolean isValid()
Description copied from interface: StructureChecker
Returns true if the checker's configuration is valid, false otherwise

Specified by:
isValid in interface StructureChecker
Returns:
true if the checker's configuration is valid, false otherwise

isAvailable

public boolean isAvailable()
Description copied from interface: StructureChecker
Returns true if the checker is available, and can be used

Specified by:
isAvailable in interface StructureChecker
Returns:
true if the checker is available, and can be used

cloneItem

public StructureChecker cloneItem()
Description copied from interface: StructureChecker
Returns a clone of this StructureChecker instance

Specified by:
cloneItem in interface StructureChecker
Returns:
a clone of this StructureChecker instance

clone

public AbstractStructureChecker clone()
                               throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

setDescription

public void setDescription(java.lang.String description)
Description copied from interface: StructureChecker
Sets the description of the checker

Specified by:
setDescription in interface StructureChecker
Parameters:
description - the description to set

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: StructureChecker
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 StructureChecker
Parameters:
listener - The PropertyChangeListener to be added
See Also:
PropertyChangeSupport.addPropertyChangeListener(PropertyChangeListener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: StructureChecker
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 StructureChecker
Parameters:
listener - The PropertyChangeListener to be removed
See Also:
PropertyChangeSupport.removePropertyChangeListener(PropertyChangeListener)

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Description copied from interface: StructureChecker
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 StructureChecker
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(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)
Description copied from interface: StructureChecker
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 StructureChecker
Parameters:
propertyName - The name of the property that was listened on.
listener - The PropertyChangeListener to be removed
See Also:
PropertyChangeSupport.removePropertyChangeListener(String, PropertyChangeListener)

getDescriptor

public chemaxon.checkers.StructureCheckerDescriptor getDescriptor()
Description copied from interface: StructureChecker
Returns a StructureCheckerDescriptor instance which represents the user interface related informations of the checker

Specified by:
getDescriptor in interface StructureChecker
Returns:
a StructureCheckerDescriptor instance which represents the user interface related informations of the checker

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object