Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use the interface instead of the implementation
Change-Id: I5e2712e7897bfcdb7f8dcf13e5978d24407a57e6
  • Loading branch information
egonw committed Feb 20, 2012
1 parent b1827a7 commit 6955c25
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
20 changes: 11 additions & 9 deletions src/main/org/openscience/cdk/qsar/DescriptorEngine.java
Expand Up @@ -23,6 +23,8 @@
import nu.xom.Attribute;
import nu.xom.Element;
import nu.xom.Elements;

import org.openscience.cdk.IImplementationSpecification;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.dict.Dictionary;
Expand Down Expand Up @@ -89,7 +91,7 @@ public class DescriptorEngine {
private Dictionary dict = null;
private List<String> classNames = null;
private List<IDescriptor> descriptors = null;
private List<DescriptorSpecification> speclist = null;
private List<IImplementationSpecification> speclist = null;
private static ILoggingTool logger =
LoggingToolFactory.createLoggingTool(DescriptorEngine.class);

Expand Down Expand Up @@ -311,7 +313,7 @@ public String getDictionaryType(String identifier) {
* the supplied identifier
*/
@TestMethod(value="testDictionaryType")
public String getDictionaryType(DescriptorSpecification descriptorSpecification) {
public String getDictionaryType(IImplementationSpecification descriptorSpecification) {
return getDictionaryType(descriptorSpecification.getSpecificationReference());
}

Expand Down Expand Up @@ -388,7 +390,7 @@ public String[] getDictionaryClass(String identifier) {
*/

@TestMethod(value="testDictionaryClass")
public String[] getDictionaryClass(DescriptorSpecification descriptorSpecification) {
public String[] getDictionaryClass(IImplementationSpecification descriptorSpecification) {
return getDictionaryClass(descriptorSpecification.getSpecificationReference());
}

Expand Down Expand Up @@ -475,7 +477,7 @@ public String getDictionaryTitle(DescriptorSpecification descriptorSpecification
* with which the <code>DescriptorValue</code> objects can be obtained from a
* molecules property list
*/
public List<DescriptorSpecification> getDescriptorSpecifications() {
public List<IImplementationSpecification> getDescriptorSpecifications() {
return (speclist);
}

Expand All @@ -485,7 +487,7 @@ public List<DescriptorSpecification> getDescriptorSpecifications() {
* @param specs A list of specification objects
* @see #getDescriptorSpecifications
*/
public void setDescriptorSpecifications(List<DescriptorSpecification> specs) {
public void setDescriptorSpecifications(List<IImplementationSpecification> specs) {
speclist = specs;
}

Expand Down Expand Up @@ -526,7 +528,7 @@ public void setDescriptorInstances(List<IDescriptor> descriptors) {
@TestMethod(value="testAvailableClass")
public String[] getAvailableDictionaryClasses() {
List<String> classList = new ArrayList<String>();
for (DescriptorSpecification spec : speclist) {
for (IImplementationSpecification spec : speclist) {
String[] tmp = getDictionaryClass(spec);
if (tmp != null) classList.addAll(Arrays.asList(tmp));
}
Expand Down Expand Up @@ -700,8 +702,8 @@ public List<IDescriptor> instantiateDescriptors(List<String> descriptorClassName
return descriptors;
}

public List<DescriptorSpecification> initializeSpecifications(List<IDescriptor> descriptors) {
List<DescriptorSpecification> speclist = new ArrayList<DescriptorSpecification>();
public List<IImplementationSpecification> initializeSpecifications(List<IDescriptor> descriptors) {
List<IImplementationSpecification> speclist = new ArrayList<IImplementationSpecification>();
for (IDescriptor descriptor : descriptors) {
speclist.add(descriptor.getSpecification());
}
Expand All @@ -715,7 +717,7 @@ private String getSpecRef(String identifier) {
String className = classNames.get(i);
if (className.equals(identifier)) {
IDescriptor descriptor = descriptors.get(i);
DescriptorSpecification descSpecification = descriptor.getSpecification();
IImplementationSpecification descSpecification = descriptor.getSpecification();
String[] tmp = descSpecification.getSpecificationReference().split("#");
if (tmp.length != 2) {
logger.debug("Something fishy with the spec ref: ", descSpecification.getSpecificationReference());
Expand Down
5 changes: 3 additions & 2 deletions src/main/org/openscience/cdk/qsar/IDescriptor.java
Expand Up @@ -20,6 +20,7 @@
*/
package org.openscience.cdk.qsar;

import org.openscience.cdk.IImplementationSpecification;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.qsar.result.IDescriptorResult;

Expand Down Expand Up @@ -86,7 +87,7 @@
public interface IDescriptor {

/**
* Returns a <code>Map</code> which specifies which descriptor
* Returns a <code>IImplementationSpecification</code> which specifies which descriptor
* is implemented by this class.
*
* These fields are used in the map:
Expand All @@ -100,7 +101,7 @@ public interface IDescriptor {
*
* @return An object containing the descriptor specification
*/
public DescriptorSpecification getSpecification();
public IImplementationSpecification getSpecification();

/**
* Returns the names of the parameters for this descriptor. The method
Expand Down
5 changes: 3 additions & 2 deletions src/test/org/openscience/cdk/qsar/DescriptorNamesTest.java
Expand Up @@ -28,6 +28,7 @@
import org.junit.Test;
import org.openscience.cdk.ChemFile;
import org.openscience.cdk.CDKTestCase;
import org.openscience.cdk.IImplementationSpecification;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.io.ISimpleChemObjectReader;
import org.openscience.cdk.io.MDLV2000Reader;
Expand All @@ -50,7 +51,7 @@ public DescriptorNamesTest() {
@Test
public void checkUniqueMolecularDescriptorNames() throws Exception {
DescriptorEngine engine = new DescriptorEngine(DescriptorEngine.MOLECULAR);
List<DescriptorSpecification> specs = engine.getDescriptorSpecifications();
List<IImplementationSpecification> specs = engine.getDescriptorSpecifications();

// we work with a simple molecule with 3D coordinates
String filename = "data/mdl/lobtest2.sdf";
Expand All @@ -65,7 +66,7 @@ public void checkUniqueMolecularDescriptorNames() throws Exception {

int ncalc = 0;
List<String> descNames = new ArrayList<String>();
for (DescriptorSpecification spec : specs) {
for (IImplementationSpecification spec : specs) {
DescriptorValue value = (DescriptorValue) ac.getProperty(spec);
if (value == null) continue;
ncalc++;
Expand Down
Expand Up @@ -23,6 +23,7 @@
import org.junit.Assert;
import org.junit.Test;
import org.openscience.cdk.CDKTestCase;
import org.openscience.cdk.IImplementationSpecification;
import org.openscience.cdk.qsar.DescriptorSpecification;
import org.openscience.cdk.qsar.IDescriptor;

Expand Down Expand Up @@ -141,7 +142,7 @@ public void setDescriptor(Class<? extends IDescriptor> descriptorClass) throws E
}

@Test public void testGetSpecification() {
DescriptorSpecification spec = descriptor.getSpecification();
IImplementationSpecification spec = descriptor.getSpecification();
Assert.assertNotNull(
"The descriptor specification returned must not be null.",
spec
Expand Down Expand Up @@ -189,7 +190,7 @@ public void setDescriptor(Class<? extends IDescriptor> descriptorClass) throws E
* but one based on a repository blob or commit.
*/
@Test public void testGetSpecification_IdentifierNonDefault() {
DescriptorSpecification spec = descriptor.getSpecification();
IImplementationSpecification spec = descriptor.getSpecification();
Assert.assertNotSame("$Id$", spec.getImplementationIdentifier());
}

Expand Down

0 comments on commit 6955c25

Please sign in to comment.