Skip to content

Commit d4be48a

Browse files
committed
Resolve #523 13 Don't need to check line length > 6 (as > 7 already) also replace indexOf with contains check.
1 parent 66d52e4 commit d4be48a

File tree

1 file changed

+9
-9
lines changed
  • storage/ioformats/src/main/java/org/openscience/cdk/io/formats

1 file changed

+9
-9
lines changed

storage/ioformats/src/main/java/org/openscience/cdk/io/formats/MDLFormat.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,22 @@ public String getWriterClassName() {
7676
/** {@inheritDoc} */
7777
@Override
7878
public boolean matches(int lineNumber, String line) {
79-
if (lineNumber == 4 && line.length() > 7 && (line.indexOf("2000") == -1) && // MDL Mol V2000 format
80-
(line.indexOf("3000") == -1)) // MDL Mol V3000 format
79+
if (lineNumber == 4
80+
&& line.length() > 7
81+
&& (!line.contains("2000")) && // MDL Mol V2000 format
82+
(!line.contains("3000"))) // MDL Mol V3000 format
8183
{
8284
// possibly a MDL mol file
8385
try {
8486
String atomCountString = line.substring(0, 3).trim();
8587
String bondCountString = line.substring(3, 6).trim();
8688
Integer.valueOf(atomCountString);
8789
Integer.valueOf(bondCountString);
88-
if (line.length() > 6) {
89-
String remainder = line.substring(6).trim();
90-
for (int i = 0; i < remainder.length(); ++i) {
91-
char c = remainder.charAt(i);
92-
if (!(Character.isDigit(c) || Character.isWhitespace(c))) {
93-
return false;
94-
}
90+
String remainder = line.substring(6).trim();
91+
for (int i = 0; i < remainder.length(); ++i) {
92+
char c = remainder.charAt(i);
93+
if (!(Character.isDigit(c) || Character.isWhitespace(c))) {
94+
return false;
9595
}
9696
}
9797
} catch (NumberFormatException nfe) {

0 commit comments

Comments
 (0)