MDLV3000Writer extends DefaultChemObjectWriter { @Override public void write(IChemObject object) throws CDKException { try { if (IAtomContainer.class.isInstance(object)) writeMol((IAtomContainer) object); else throw new CDKException("Unsupported ChemObject " + object.getClass()); } catch (IOException ex) { throw new CDKException("Could not write V3000 format", ex); } } MDLV3000Writer(Writer writer);  MDLV3000Writer(OutputStream out);  MDLV3000Writer(); @Override void write(IChemObject object); @Override void setWriter(Writer writer); @Override void setWriter(OutputStream writer); @Override IResourceFormat getFormat(); @Override boolean accepts(Class<? extends IChemObject> c); @Override void close(); void customizeJob();  }
@Test public void writeDimensionField() throws Exception { IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newAtomContainer(); IAtom atom = builder.newAtom(); atom.setSymbol("C"); atom.setImplicitHydrogenCount(4); atom.setPoint2d(new Point2d(0.5, 0.5)); mol.addAtom(atom); StringWriter sw = new StringWriter(); try (MDLV3000Writer mdlw = new MDLV3000Writer(sw)) { mdlw.write(mol); } assertThat(sw.toString(), containsString("2D")); }
@Test public void writeDimensionField3D() throws Exception { IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance(); IAtomContainer mol = builder.newAtomContainer(); IAtom atom = builder.newAtom(); atom.setSymbol("C"); atom.setImplicitHydrogenCount(4); atom.setPoint3d(new Point3d(0.5, 0.5, 0.1)); mol.addAtom(atom); StringWriter sw = new StringWriter(); try (MDLV3000Writer mdlw = new MDLV3000Writer(sw)) { mdlw.write(mol); } assertThat(sw.toString(), containsString("3D")); }