@Test public void test() throws Exception { final URL resource = getClass().getClassLoader().getResource("uas_older.xml"); final String expected = formatSimilar(UrlUtil.read(resource, Charsets.UTF_8)).replaceAll("/si </regstring>", "/si</regstring>"); final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); XmlDataWriter.write(new TestXmlDataStore().getData(), outputStream); final String actual = new String(outputStream.toByteArray(), "UTF-8"); assertThat(formatSimilar(actual)).isEqualTo(expected); }
public static void write(@Nonnull final Data data, @Nonnull final OutputStream outputStream) throws ParserConfigurationException, TransformerException { Check.notNull(data, "data"); Check.notNull(outputStream, "outputStream"); final Document doc = newDocumentBuilder().newDocument(); final Element uasdataElement = doc.createElement(Tag.UASDATA); doc.appendChild(uasdataElement); uasdataElement.appendChild(createDescription(data, doc)); final Element dataElement = doc.createElement(Tag.DATA); uasdataElement.appendChild(dataElement); dataElement.appendChild(createRobots(data, doc)); dataElement.appendChild(createOperatingSystems(data, doc)); dataElement.appendChild(createBrowsers(data, doc)); dataElement.appendChild(createBrowserTypes(data, doc)); dataElement.appendChild(createBrowserPatterns(data, doc)); dataElement.appendChild(createBrowserOperatingSystemMappings(data, doc)); dataElement.appendChild(createOperatingSystemPatterns(data, doc)); dataElement.appendChild(createDevices(data, doc)); dataElement.appendChild(createDevicePatterns(data, doc)); final DOMSource source = new DOMSource(doc); final StreamResult result = new StreamResult(outputStream); transform(source, result); }
XmlDataWriter { public static void write(@Nonnull final Data data, @Nonnull final OutputStream outputStream) throws ParserConfigurationException, TransformerException { Check.notNull(data, "data"); Check.notNull(outputStream, "outputStream"); final Document doc = newDocumentBuilder().newDocument(); final Element uasdataElement = doc.createElement(Tag.UASDATA); doc.appendChild(uasdataElement); uasdataElement.appendChild(createDescription(data, doc)); final Element dataElement = doc.createElement(Tag.DATA); uasdataElement.appendChild(dataElement); dataElement.appendChild(createRobots(data, doc)); dataElement.appendChild(createOperatingSystems(data, doc)); dataElement.appendChild(createBrowsers(data, doc)); dataElement.appendChild(createBrowserTypes(data, doc)); dataElement.appendChild(createBrowserPatterns(data, doc)); dataElement.appendChild(createBrowserOperatingSystemMappings(data, doc)); dataElement.appendChild(createOperatingSystemPatterns(data, doc)); dataElement.appendChild(createDevices(data, doc)); dataElement.appendChild(createDevicePatterns(data, doc)); final DOMSource source = new DOMSource(doc); final StreamResult result = new StreamResult(outputStream); transform(source, result); } }
XmlDataWriter { public static void write(@Nonnull final Data data, @Nonnull final OutputStream outputStream) throws ParserConfigurationException, TransformerException { Check.notNull(data, "data"); Check.notNull(outputStream, "outputStream"); final Document doc = newDocumentBuilder().newDocument(); final Element uasdataElement = doc.createElement(Tag.UASDATA); doc.appendChild(uasdataElement); uasdataElement.appendChild(createDescription(data, doc)); final Element dataElement = doc.createElement(Tag.DATA); uasdataElement.appendChild(dataElement); dataElement.appendChild(createRobots(data, doc)); dataElement.appendChild(createOperatingSystems(data, doc)); dataElement.appendChild(createBrowsers(data, doc)); dataElement.appendChild(createBrowserTypes(data, doc)); dataElement.appendChild(createBrowserPatterns(data, doc)); dataElement.appendChild(createBrowserOperatingSystemMappings(data, doc)); dataElement.appendChild(createOperatingSystemPatterns(data, doc)); dataElement.appendChild(createDevices(data, doc)); dataElement.appendChild(createDevicePatterns(data, doc)); final DOMSource source = new DOMSource(doc); final StreamResult result = new StreamResult(outputStream); transform(source, result); } private  XmlDataWriter(); }
XmlDataWriter { public static void write(@Nonnull final Data data, @Nonnull final OutputStream outputStream) throws ParserConfigurationException, TransformerException { Check.notNull(data, "data"); Check.notNull(outputStream, "outputStream"); final Document doc = newDocumentBuilder().newDocument(); final Element uasdataElement = doc.createElement(Tag.UASDATA); doc.appendChild(uasdataElement); uasdataElement.appendChild(createDescription(data, doc)); final Element dataElement = doc.createElement(Tag.DATA); uasdataElement.appendChild(dataElement); dataElement.appendChild(createRobots(data, doc)); dataElement.appendChild(createOperatingSystems(data, doc)); dataElement.appendChild(createBrowsers(data, doc)); dataElement.appendChild(createBrowserTypes(data, doc)); dataElement.appendChild(createBrowserPatterns(data, doc)); dataElement.appendChild(createBrowserOperatingSystemMappings(data, doc)); dataElement.appendChild(createOperatingSystemPatterns(data, doc)); dataElement.appendChild(createDevices(data, doc)); dataElement.appendChild(createDevicePatterns(data, doc)); final DOMSource source = new DOMSource(doc); final StreamResult result = new StreamResult(outputStream); transform(source, result); } private  XmlDataWriter(); static void write(@Nonnull final Data data, @Nonnull final OutputStream outputStream); }
XmlDataWriter { public static void write(@Nonnull final Data data, @Nonnull final OutputStream outputStream) throws ParserConfigurationException, TransformerException { Check.notNull(data, "data"); Check.notNull(outputStream, "outputStream"); final Document doc = newDocumentBuilder().newDocument(); final Element uasdataElement = doc.createElement(Tag.UASDATA); doc.appendChild(uasdataElement); uasdataElement.appendChild(createDescription(data, doc)); final Element dataElement = doc.createElement(Tag.DATA); uasdataElement.appendChild(dataElement); dataElement.appendChild(createRobots(data, doc)); dataElement.appendChild(createOperatingSystems(data, doc)); dataElement.appendChild(createBrowsers(data, doc)); dataElement.appendChild(createBrowserTypes(data, doc)); dataElement.appendChild(createBrowserPatterns(data, doc)); dataElement.appendChild(createBrowserOperatingSystemMappings(data, doc)); dataElement.appendChild(createOperatingSystemPatterns(data, doc)); dataElement.appendChild(createDevices(data, doc)); dataElement.appendChild(createDevicePatterns(data, doc)); final DOMSource source = new DOMSource(doc); final StreamResult result = new StreamResult(outputStream); transform(source, result); } private  XmlDataWriter(); static void write(@Nonnull final Data data, @Nonnull final OutputStream outputStream);  }