Skip to content
Permalink
Browse files

Added some checks for null specification references. Code is now more…

… robust to ill-formed dictionary elements
  • Loading branch information...
rajarshi committed Apr 10, 2012
1 parent f2080e1 commit faa5404fb8627ced4c36c46abf3e14e0822095d4
Showing with 10 additions and 3 deletions.
  1. +10 −3 src/main/org/openscience/cdk/qsar/DescriptorEngine.java
@@ -23,7 +23,6 @@
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;
@@ -411,8 +410,12 @@ public String getDictionaryDefinition(String identifier) {
Entry[] dictEntries = dict.getEntries();

String specRef = getSpecRef(identifier);
String definition = null;
if (specRef == null) {
logger.error("Cannot determine specification for id: ", identifier);
return "";
}

String definition = null;
for (Entry dictEntry : dictEntries) {
if (!dictEntry.getClassName().equals("Descriptor")) continue;
if (dictEntry.getID().equals(specRef.toLowerCase())) {
@@ -448,8 +451,12 @@ public String getDictionaryDefinition(DescriptorSpecification descriptorSpecific
public String getDictionaryTitle(String identifier) {
Entry[] dictEntries = dict.getEntries();
String specRef = getSpecRef(identifier);
String title = null;
if (specRef == null) {
logger.error("Cannot determine specification for id: ", identifier);
return "";
}

String title = null;
for (Entry dictEntry : dictEntries) {
if (!dictEntry.getClassName().equals("Descriptor")) continue;
if (dictEntry.getID().equals(specRef.toLowerCase())) {

0 comments on commit faa5404

Please sign in to comment.
You can’t perform that action at this time.