DescriptorEngine { public String[] getDictionaryClass(String identifier) { Entry[] dictEntries = dict.getEntries(); String specRef = getSpecRef(identifier); if (specRef == null) { logger.error("Cannot determine specification for id: ", identifier); return new String[0]; } List<String> dictClasses = new ArrayList<String>(); for (Entry dictEntry : dictEntries) { if (!dictEntry.getClassName().equals("Descriptor")) continue; if (dictEntry.getID().equals(specRef.toLowerCase())) { Element rawElement = (Element) dictEntry.getRawContent(); Elements classifications = rawElement.getChildElements("isClassifiedAs", dict.getNS()); for (int i = 0; i < classifications.size(); i++) { Element element = classifications.get(i); Attribute attr = element.getAttribute("resource", rdfNS); if ((attr.getValue().indexOf("molecularDescriptor") >= 0) || (attr.getValue().indexOf("atomicDescriptor") >= 0)) { continue; } String[] tmp = attr.getValue().split("#"); dictClasses.add(tmp[1]); } } } if (dictClasses.size() == 0) return null; else return (String[]) dictClasses.toArray(new String[]{}); } DescriptorEngine(List<String> classNames, IChemObjectBuilder builder);  DescriptorEngine(Class<? extends IDescriptor> c, IChemObjectBuilder builder); void process(IAtomContainer molecule); String getDictionaryType(String identifier); String getDictionaryType(IImplementationSpecification descriptorSpecification); String[] getDictionaryClass(String identifier); String[] getDictionaryClass(IImplementationSpecification descriptorSpecification); String getDictionaryDefinition(String identifier); String getDictionaryDefinition(DescriptorSpecification descriptorSpecification); String getDictionaryTitle(String identifier); String getDictionaryTitle(DescriptorSpecification descriptorSpecification); List<IImplementationSpecification> getDescriptorSpecifications(); void setDescriptorSpecifications(List<IImplementationSpecification> specs); List<String> getDescriptorClassNames(); List<IDescriptor> getDescriptorInstances(); void setDescriptorInstances(List<IDescriptor> descriptors); String[] getAvailableDictionaryClasses(); static List<String> getDescriptorClassNameByInterface(String interfaceName, String[] jarFileNames); static List<String> getDescriptorClassNameByPackage(String packageName, String[] jarFileNames); List<IDescriptor> instantiateDescriptors(List<String> descriptorClassNames); List<IImplementationSpecification> initializeSpecifications(List<IDescriptor> descriptors);  }
@Test public void testDictionaryClass() { DescriptorEngine engine = new DescriptorEngine(IMolecularDescriptor.class, DefaultChemObjectBuilder.getInstance()); String className = "org.openscience.cdk.qsar.descriptors.molecular.TPSADescriptor"; DescriptorSpecification specRef = new DescriptorSpecification( "http: "The Chemistry Development Kit"); String[] dictClass = engine.getDictionaryClass(className); Assert.assertEquals(2, dictClass.length); Assert.assertEquals("topologicalDescriptor", dictClass[0]); Assert.assertEquals("electronicDescriptor", dictClass[1]); dictClass = engine.getDictionaryClass(specRef); Assert.assertEquals(2, dictClass.length); Assert.assertEquals("topologicalDescriptor", dictClass[0]); Assert.assertEquals("electronicDescriptor", dictClass[1]); }