MDLV2000Reader extends DefaultChemObjectReader { static void readNonStructuralData(final BufferedReader input, final IAtomContainer container) throws IOException { String line, header = null; boolean wrap = false; final StringBuilder data = new StringBuilder(80); while (!endOfRecord(line = input.readLine())) { final String newHeader = dataHeader(line); if (newHeader != null) { if (header != null) container.setProperty(header, data.toString()); header = newHeader; wrap = false; data.setLength(0); } else { if (data.length() > 0 || !line.equals(" ")) line = line.trim(); if (line.isEmpty()) continue; if (!wrap && data.length() > 0) data.append('\n'); data.append(line); wrap = line.length() == 80; } } if (header != null) container.setProperty(header, data.toString()); } MDLV2000Reader();  MDLV2000Reader(InputStream in);  MDLV2000Reader(InputStream in, Mode mode);  MDLV2000Reader(Reader in);  MDLV2000Reader(Reader in, Mode mode); @Override IResourceFormat getFormat(); @Override void setReader(Reader input); @Override void setReader(InputStream input); @SuppressWarnings("unchecked") @Override boolean accepts(Class<? extends IChemObject> classObject); @SuppressWarnings("unchecked") @Override T read(T object); @Override void close(); void customizeJob();  }
@Test public void readNonStructuralData() throws Exception { StringBuilder sb = new StringBuilder(); sb.append("> 29 <DENSITY>").append('\n'); sb.append("0.9132 - 20.0").append('\n'); sb.append('\n'); sb.append("> 29 <BOILING.POINT>").append('\n'); sb.append("63.0 (737 MM)").append('\n'); sb.append("79.0 (42 MM)").append('\n'); sb.append('\n'); sb.append("> 29 <ALTERNATE.NAMES>").append('\n'); sb.append("SYLVAN").append('\n'); sb.append('\n'); sb.append("> 29 <DATE>").append('\n'); sb.append("09-23-1980").append('\n'); sb.append('\n'); sb.append("> 29 <CRC.NUMBER>").append('\n'); sb.append("F-0213").append('\n'); sb.append('\n'); BufferedReader input = new BufferedReader(new StringReader(sb.toString())); IAtomContainer mock = mock(IAtomContainer.class); MDLV2000Reader.readNonStructuralData(input, mock); verify(mock).setProperty("DENSITY", "0.9132 - 20.0"); verify(mock).setProperty("BOILING.POINT", "63.0 (737 MM)\n79.0 (42 MM)"); verify(mock).setProperty("ALTERNATE.NAMES", "SYLVAN"); verify(mock).setProperty("DATE", "09-23-1980"); verify(mock).setProperty("CRC.NUMBER", "F-0213"); }
@Test public void readNonStructuralData_emtpy() throws Exception { StringBuilder sb = new StringBuilder(); sb.append("> <ONE_SPACE>").append('\n'); sb.append(" ").append('\n'); sb.append('\n'); sb.append("> <EMTPY_LINES>").append('\n'); sb.append('\n'); sb.append('\n'); sb.append('\n'); BufferedReader input = new BufferedReader(new StringReader(sb.toString())); IAtomContainer mock = mock(IAtomContainer.class); MDLV2000Reader.readNonStructuralData(input, mock); verify(mock).setProperty("ONE_SPACE", " "); verify(mock).setProperty("EMTPY_LINES", ""); }
@Test public void readNonStructuralData_wrap() throws Exception { StringBuilder sb = new StringBuilder(); sb.append("> <LONG_PROPERTY>").append('\n'); sb.append("This is a long property which should be wrapped when stored as field in an SDF D"); sb.append('\n'); sb.append("ata entry"); sb.append('\n'); BufferedReader input = new BufferedReader(new StringReader(sb.toString())); IAtomContainer mock = mock(IAtomContainer.class); MDLV2000Reader.readNonStructuralData(input, mock); verify(mock).setProperty("LONG_PROPERTY", "This is a long property which should be wrapped when stored as field in an SDF Data entry"); }