TMXMLWriter extends AbstractTopicMapExporter implements TopicMapWriterIF { @Override public void write(TopicMapIF topicmap) throws IOException { try { gatherPrefixes(topicmap.getTopics()); startTopicMap(topicmap); writeTopics(filterCollection(topicmap.getTopics())); endTopicMap(); close(); } catch (SAXException e) { throw new OntopiaRuntimeException(e); } } TMXMLWriter(Writer out);  TMXMLWriter(Writer out, String encoding);  TMXMLWriter(File out);  TMXMLWriter(File out, String encoding);  TMXMLWriter(OutputStream out, String encoding);  TMXMLWriter(ContentHandler out); void close(); String getDocumentElement(); void setDocumentElement(String docelem); @Override void write(TopicMapIF topicmap); void startTopicMap(TopicMapIF topicmap); void gatherPrefixes(Collection topics); void writeTopics(Collection topics); void writeTopic(TopicIF topic); void endTopicMap(); void gatherPrefixes(TopicIF topic); Map getNamespaceURIMapping(); void addPrefix(String prefix, String nsuri); @Override void setAdditionalProperties(Map<String, Object> properties); static final String PROPERTY_PREFIXES; static final String PROPERTY_DOCUMENT_ELEMENT; static final String NS_ISO; static final String NS_XTM; static final String NS_TM; static final String XSD_ANYURI; static final String XSD_STRING; }
@Test public void testBug2116() throws IOException, SAXException { MockWriter mock = new MockWriter(); TMXMLWriter writer = new TMXMLWriter(mock, "utf-8"); writer.write(topicmap); }
@Test public void testWriteToFile() throws IOException { builder.makeTopic(); File file = TestFileUtils.getTestOutputFile("tmxml", "io-f.xtm"); new TMXMLWriter(file).write(topicmap); Assert.assertTrue(Files.size(file.toPath()) > 0); }
@Test public void testWriteToOutputStream() throws IOException { builder.makeTopic(); File file = TestFileUtils.getTestOutputFile("tmxml", "io-o.xtm"); new TMXMLWriter(new FileOutputStream(file), "utf-8").write(topicmap); Assert.assertTrue(Files.size(file.toPath()) > 0); }
@Test public void testWriteToWriter() throws IOException { builder.makeTopic(); File file = TestFileUtils.getTestOutputFile("tmxml", "io-w.xtm"); new TMXMLWriter(new FileWriter(file), "utf-8").write(topicmap); Assert.assertTrue(Files.size(file.toPath()) > 0); }