Skip to content

Commit

Permalink
Resolve #523 13 Don't need to check line length > 6 (as > 7 already) …
Browse files Browse the repository at this point in the history
…also replace indexOf with contains check.
  • Loading branch information
johnmay committed Jan 2, 2019
1 parent 66d52e4 commit d4be48a
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@ public String getWriterClassName() {
/** {@inheritDoc} */
@Override
public boolean matches(int lineNumber, String line) {
if (lineNumber == 4 && line.length() > 7 && (line.indexOf("2000") == -1) && // MDL Mol V2000 format
(line.indexOf("3000") == -1)) // MDL Mol V3000 format
if (lineNumber == 4
&& line.length() > 7
&& (!line.contains("2000")) && // MDL Mol V2000 format
(!line.contains("3000"))) // MDL Mol V3000 format
{
// possibly a MDL mol file
try {
String atomCountString = line.substring(0, 3).trim();
String bondCountString = line.substring(3, 6).trim();
Integer.valueOf(atomCountString);
Integer.valueOf(bondCountString);
if (line.length() > 6) {
String remainder = line.substring(6).trim();
for (int i = 0; i < remainder.length(); ++i) {
char c = remainder.charAt(i);
if (!(Character.isDigit(c) || Character.isWhitespace(c))) {
return false;
}
String remainder = line.substring(6).trim();
for (int i = 0; i < remainder.length(); ++i) {
char c = remainder.charAt(i);
if (!(Character.isDigit(c) || Character.isWhitespace(c))) {
return false;
}
}
} catch (NumberFormatException nfe) {
Expand Down

0 comments on commit d4be48a

Please sign in to comment.