List of usage examples for javax.xml.stream XMLStreamWriter writeEndElement
public void writeEndElement() throws XMLStreamException;
From source file:com.norconex.jefmon.model.ConfigurationDAO.java
private static void saveJobActions(XMLStreamWriter xml, IJobAction[] jobActions) throws XMLStreamException { if (jobActions == null) { return;//www.j a v a2 s . c o m } xml.writeStartElement("job-actions"); for (IJobAction action : jobActions) { xml.writeStartElement("action"); xml.writeCharacters(action.getClass().getName()); xml.writeEndElement(); } xml.writeEndElement(); }
From source file:gdv.xport.util.HtmlFormatter.java
private static void writeTagTo(final XMLStreamWriter xmlStreamWriter, final String tag, final String content) throws XMLStreamException { xmlStreamWriter.writeStartElement(tag); xmlStreamWriter.writeCharacters(content); xmlStreamWriter.writeEndElement(); }
From source file:gdv.xport.util.HtmlFormatter.java
private static void writeDetailsTo(final XMLStreamWriter xmlStreamWriter, final Satz satz, final int zeile) throws XMLStreamException { xmlStreamWriter.writeStartElement("h3"); xmlStreamWriter/* www .jav a2 s.c om*/ .writeCharacters("Satzart " + satz.getSatzart() + " (" + satz.getClass().getSimpleName() + ")"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); int n = zeile; for (Iterator<Teildatensatz> iterator = satz.getTeildatensaetze().iterator(); iterator.hasNext();) { Teildatensatz teildatensatz = iterator.next(); writeDetailsTo(xmlStreamWriter, teildatensatz, n); n++; } xmlStreamWriter.flush(); }
From source file:gdv.xport.util.HtmlFormatter.java
private static void writeDetailsTo(final XMLStreamWriter xmlStreamWriter, final Teildatensatz teildatensatz, final int zeile) throws XMLStreamException { xmlStreamWriter.writeStartElement("h4"); xmlStreamWriter/*from w w w . j a va 2 s . co m*/ .writeCharacters("Zeile " + zeile + ": Teildatensatz " + teildatensatz.getNummer().getInhalt()); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("table"); xmlStreamWriter.writeStartElement("thead"); xmlStreamWriter.writeStartElement("tr"); writeTagTo(xmlStreamWriter, "th", "Nr"); writeTagTo(xmlStreamWriter, "th", "Byte"); writeTagTo(xmlStreamWriter, "th", "Bezeichner"); writeTagTo(xmlStreamWriter, "th", "Datentyp"); writeTagTo(xmlStreamWriter, "th", "Inhalt"); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.writeStartElement("tbody"); int nr = 1; for (Iterator<Feld> iterator = teildatensatz.getFelder().iterator(); iterator.hasNext();) { Feld feld = iterator.next(); writeDetailsTo(xmlStreamWriter, feld, zeile, nr); nr++; } xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); xmlStreamWriter.flush(); }
From source file:gdv.xport.util.HtmlFormatter.java
private static void writeDetailsTo(final XMLStreamWriter xmlStreamWriter, final Feld feld, final int zeile, final int nr) throws XMLStreamException { String typ = feld.getClass().getSimpleName(); xmlStreamWriter.writeStartElement("tr"); xmlStreamWriter.writeAttribute("class", typ); writeTagTo(xmlStreamWriter, "td", Integer.toString(nr)); xmlStreamWriter.writeStartElement("td"); xmlStreamWriter.writeStartElement("a"); xmlStreamWriter.writeAttribute("name", getAnchorFor(zeile, feld)); xmlStreamWriter.writeEndElement(); if (feld.getAnzahlBytes() == 1) { xmlStreamWriter.writeCharacters(Integer.toString(feld.getByteAdresse())); } else {//from ww w . j a va2 s . co m xmlStreamWriter.writeCharacters(feld.getByteAdresse() + " - " + feld.getEndAdresse()); } xmlStreamWriter.writeEndElement(); writeTagTo(xmlStreamWriter, "td", feld.getBezeichnung()); writeTagTo(xmlStreamWriter, "td", typ); xmlStreamWriter.writeStartElement("td"); writeInhaltTo(xmlStreamWriter, feld); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeCharacters("\n"); }
From source file:org.elasticsearch.discovery.ec2.Ec2DiscoveryClusterFormationTests.java
/** * Creates mock EC2 endpoint providing the list of started nodes to the DescribeInstances API call *//* w w w . ja va2 s .co m*/ @BeforeClass public static void startHttpd() throws Exception { logDir = createTempDir(); httpServer = MockHttpServer .createHttp(new InetSocketAddress(InetAddress.getLoopbackAddress().getHostAddress(), 0), 0); httpServer.createContext("/", (s) -> { Headers headers = s.getResponseHeaders(); headers.add("Content-Type", "text/xml; charset=UTF-8"); String action = null; for (NameValuePair parse : URLEncodedUtils.parse(IOUtils.toString(s.getRequestBody()), StandardCharsets.UTF_8)) { if ("Action".equals(parse.getName())) { action = parse.getValue(); break; } } assertThat(action, equalTo("DescribeInstances")); XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newFactory(); xmlOutputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); StringWriter out = new StringWriter(); XMLStreamWriter sw; try { sw = xmlOutputFactory.createXMLStreamWriter(out); sw.writeStartDocument(); String namespace = "http://ec2.amazonaws.com/doc/2013-02-01/"; sw.setDefaultNamespace(namespace); sw.writeStartElement(XMLConstants.DEFAULT_NS_PREFIX, "DescribeInstancesResponse", namespace); { sw.writeStartElement("requestId"); sw.writeCharacters(UUID.randomUUID().toString()); sw.writeEndElement(); sw.writeStartElement("reservationSet"); { Path[] files = FileSystemUtils.files(logDir); for (int i = 0; i < files.length; i++) { Path resolve = files[i].resolve("transport.ports"); if (Files.exists(resolve)) { List<String> addresses = Files.readAllLines(resolve); Collections.shuffle(addresses, random()); sw.writeStartElement("item"); { sw.writeStartElement("reservationId"); sw.writeCharacters(UUID.randomUUID().toString()); sw.writeEndElement(); sw.writeStartElement("instancesSet"); { sw.writeStartElement("item"); { sw.writeStartElement("instanceId"); sw.writeCharacters(UUID.randomUUID().toString()); sw.writeEndElement(); sw.writeStartElement("imageId"); sw.writeCharacters(UUID.randomUUID().toString()); sw.writeEndElement(); sw.writeStartElement("instanceState"); { sw.writeStartElement("code"); sw.writeCharacters("16"); sw.writeEndElement(); sw.writeStartElement("name"); sw.writeCharacters("running"); sw.writeEndElement(); } sw.writeEndElement(); sw.writeStartElement("privateDnsName"); sw.writeCharacters(addresses.get(0)); sw.writeEndElement(); sw.writeStartElement("dnsName"); sw.writeCharacters(addresses.get(0)); sw.writeEndElement(); sw.writeStartElement("instanceType"); sw.writeCharacters("m1.medium"); sw.writeEndElement(); sw.writeStartElement("placement"); { sw.writeStartElement("availabilityZone"); sw.writeCharacters("use-east-1e"); sw.writeEndElement(); sw.writeEmptyElement("groupName"); sw.writeStartElement("tenancy"); sw.writeCharacters("default"); sw.writeEndElement(); } sw.writeEndElement(); sw.writeStartElement("privateIpAddress"); sw.writeCharacters(addresses.get(0)); sw.writeEndElement(); sw.writeStartElement("ipAddress"); sw.writeCharacters(addresses.get(0)); sw.writeEndElement(); } sw.writeEndElement(); } sw.writeEndElement(); } sw.writeEndElement(); } } } sw.writeEndElement(); } sw.writeEndElement(); sw.writeEndDocument(); sw.flush(); final byte[] responseAsBytes = out.toString().getBytes(StandardCharsets.UTF_8); s.sendResponseHeaders(200, responseAsBytes.length); OutputStream responseBody = s.getResponseBody(); responseBody.write(responseAsBytes); responseBody.close(); } catch (XMLStreamException e) { Loggers.getLogger(Ec2DiscoveryClusterFormationTests.class).error("Failed serializing XML", e); throw new RuntimeException(e); } }); httpServer.start(); }
From source file:gdv.xport.util.HtmlFormatter.java
private static void writeTo(final XMLStreamWriter xmlStreamWriter, final Feld feld, final int zeile) throws XMLStreamException { String feldType = feld.getClass().getSimpleName(); xmlStreamWriter.writeStartElement("a"); xmlStreamWriter.writeAttribute("class", feldType); xmlStreamWriter.writeAttribute("title", "Byte " + feld.getByteAdresse() + "-" + feld.getEndAdresse() + ": " + feld.getBezeichnung()); xmlStreamWriter.writeAttribute("href", "#" + getAnchorFor(zeile, feld)); writeInhaltTo(xmlStreamWriter, feld); xmlStreamWriter.writeEndElement(); }
From source file:com.hdsfed.cometapi.XMLHelper.java
public static XMLStreamWriter CreateTagListTuplet(XMLStreamWriter serializer, int i, String key, String value) throws XMLStreamException { if (value == null || key == null) return serializer; serializer.writeCharacters("\t"); serializer.writeStartElement("tag"); serializer.writeAttribute("id", String.valueOf(i)); serializer.writeCharacters("\n\t\t"); serializer = XMLHelper.CreateSimpleTagAndContent(serializer, "name", key); serializer.writeCharacters("\n\t\t"); serializer = XMLHelper.CreateSimpleTagAndContent(serializer, "value", value); serializer.writeCharacters("\n\t"); serializer.writeEndElement(); //end tag serializer.writeCharacters("\n"); return serializer; }
From source file:com.fiorano.openesb.application.DmiObject.java
protected static void writeCDATAElement(XMLStreamWriter writer, String element, String content) throws XMLStreamException { if (!StringUtils.isEmpty(content)) { writer.writeStartElement(element); writer.writeCData(content);/*from w ww . j a va 2 s . c o m*/ writer.writeEndElement(); } }
From source file:com.fiorano.openesb.application.DmiObject.java
protected static void writeElement(XMLStreamWriter writer, String element, String content) throws XMLStreamException { if (!StringUtils.isEmpty(content)) { writer.writeStartElement(element); writer.writeCharacters(content); writer.writeEndElement(); }//w w w .ja v a 2s . co m }