The Octet Molecular Representation Framework v0.8.2

net.sf.octet.query
Class CachedMoleculeQuery

java.lang.Object
  extended bynet.sf.octet.query.CachedMoleculeQuery
All Implemented Interfaces:
MoleculeQuery

public class CachedMoleculeQuery
extends java.lang.Object
implements MoleculeQuery

An implementation of the MoleculeQuery interface that enables query results to be cached to improve performance. CachedMoleculeQuery decorates an instance of MoleculeQuery, forwarding requests to this instance if the Molecule being queried is not known, and returning a cached result otherwise.

This implementation supports the storage of one result per method in the MoleculeQuery interface. In other words, if match is called twice for the same Molecule, the result is determined only for the first invocation. However, a subsequent call to countMatches will forward this request to the decorated MoleculeQuery instance.

Author:
Richard Apodaca
See Also:
"Decorator Pattern (GoF95)"

Constructor Summary
CachedMoleculeQuery(MoleculeQuery query)
          Constructs a fully functional CachedMoleculeQuery that forwards requests to query.
 
Method Summary
 int countMatches(Molecule molecule)
          Returns the number of non-degenerate occurrences of this query in the specified Molecule.
 AtomGraphCollection getMatches(Molecule molecule)
          Returns a mapping of all occurrences of this query onto the specified Molecule.
 boolean match(Molecule molecule)
          Returns true if this MoleculeQuery matches molecule, or false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachedMoleculeQuery

public CachedMoleculeQuery(MoleculeQuery query)
Constructs a fully functional CachedMoleculeQuery that forwards requests to query.

Method Detail

match

public boolean match(Molecule molecule)
Description copied from interface: MoleculeQuery
Returns true if this MoleculeQuery matches molecule, or false otherwise.

Specified by:
match in interface MoleculeQuery
Parameters:
molecule - the Molecule to query
Returns:
true if a match was found, or false otherwise

countMatches

public int countMatches(Molecule molecule)
Description copied from interface: MoleculeQuery
Returns the number of non-degenerate occurrences of this query in the specified Molecule.

Specified by:
countMatches in interface MoleculeQuery
Parameters:
molecule - the Molecule to query
Returns:
the number of non-degenerate occurrences of this query in molecule

getMatches

public AtomGraphCollection getMatches(Molecule molecule)
Description copied from interface: MoleculeQuery
Returns a mapping of all occurrences of this query onto the specified Molecule.

Specified by:
getMatches in interface MoleculeQuery
Parameters:
molecule - the Molecule to query
Returns:
the mapping of all occurrences of this query in molecule

The Octet Molecular Representation Framework v0.8.2