Example usage for javax.xml.stream XMLStreamWriter writeEndElement

List of usage examples for javax.xml.stream XMLStreamWriter writeEndElement

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamWriter writeEndElement.

Prototype

public void writeEndElement() throws XMLStreamException;

Source Link

Document

Writes an end tag to the output relying on the internal state of the writer to determine the prefix and local name of the event.

Usage

From source file:de.shadowhunt.subversion.internal.MergeOperation.java

@Override
protected HttpUriRequest createRequest() {
    final DavTemplateRequest request = new DavTemplateRequest("MERGE", repository);
    request.addHeader("X-SVN-Options", "release-locks");

    final Writer body = new StringBuilderWriter();
    try {/*from   w w  w. j  av a  2  s  .com*/
        final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body);
        writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0);
        writer.writeStartElement("merge");
        writer.writeDefaultNamespace(XmlConstants.DAV_NAMESPACE);
        writer.writeStartElement("source");
        writer.writeStartElement("href");
        writer.writeCData(repository.getPath() + resource.getValue());
        writer.writeEndElement(); // href
        writer.writeEndElement(); // source
        writer.writeEmptyElement("no-auto-merge");
        writer.writeEmptyElement("no-checkout");
        writer.writeStartElement("prop");
        writer.writeEmptyElement("checked-in");
        writer.writeEmptyElement("version-name");
        writer.writeEmptyElement("resourcetype");
        writer.writeEmptyElement("creationdate");
        writer.writeEmptyElement("creator-displayname");
        writer.writeEndElement(); // prop
        if (!infoSet.isEmpty()) {
            writer.setPrefix(XmlConstants.SVN_PREFIX, XmlConstants.SVN_NAMESPACE);
            writer.writeStartElement(XmlConstants.SVN_NAMESPACE, "lock-token-list");
            writer.writeNamespace(XmlConstants.SVN_PREFIX, XmlConstants.SVN_NAMESPACE);
            for (final Info info : infoSet) {
                final String lockToken = info.getLockToken();
                assert (lockToken != null) : "must not be null";
                final Resource infoResource = info.getResource();

                writer.writeStartElement(XmlConstants.SVN_NAMESPACE, "lock");
                writer.writeStartElement(XmlConstants.SVN_NAMESPACE, "lock-path");
                writer.writeCData(infoResource.getValueWithoutLeadingSeparator());
                writer.writeEndElement(); // lock-path
                writer.writeStartElement(XmlConstants.SVN_NAMESPACE, "lock-token");
                writer.writeCharacters(lockToken);
                writer.writeEndElement(); // lock-token
                writer.writeEndElement(); // lock
            }
            writer.writeEndElement(); // lock-token-list
        }
        writer.writeEndElement(); // merge
        writer.writeEndDocument();
        writer.close();
    } catch (final XMLStreamException e) {
        throw new SubversionException("could not create request body", e);
    }

    request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML));
    return request;
}

From source file:com.norconex.collector.http.fetch.impl.DefaultDocumentFetcher.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {//from   www .  j av a2s .  com
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("httpDocumentFetcher");
        writer.writeAttribute("class", getClass().getCanonicalName());
        writer.writeStartElement("validStatusCodes");
        if (validStatusCodes != null) {
            writer.writeCharacters(StringUtils.join(validStatusCodes));
        }
        writer.writeEndElement();
        writer.writeStartElement("headersPrefix");
        if (headersPrefix != null) {
            writer.writeCharacters(headersPrefix);
        }
        writer.writeEndElement();
        writer.writeEndElement();
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}

From source file:net.solarnetwork.util.JavaBeanXmlSerializer.java

private void outputCollection(Collection<?> col, String name, XMLStreamWriter out) throws XMLStreamException {
    writeElement(name, null, out, false);
    for (Object o : col) {
        outputObject(o, null, out);/*from www.  j av a2 s.c o m*/
    }
    out.writeEndElement();
}

From source file:de.shadowhunt.subversion.internal.httpv1.CheckoutOperation.java

@Override
protected HttpUriRequest createRequest() {
    final Writer body = new StringBuilderWriter();
    try {//from ww  w . j  a  v  a  2s  .co m
        final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body);
        writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0);
        writer.writeStartElement("checkout");
        writer.writeDefaultNamespace(XmlConstants.DAV_NAMESPACE);
        writer.writeStartElement("activity-set");
        writer.writeStartElement("href");
        final URI transactionURI = URIUtils.createURI(repository, transaction);
        writer.writeCData(transactionURI.toString());
        writer.writeEndElement(); // href
        writer.writeEndElement(); // activity-set
        writer.writeEmptyElement("apply-to-version");
        writer.writeEndElement(); //checkout
        writer.writeEndDocument();
        writer.close();
    } catch (final XMLStreamException e) {
        throw new SubversionException("could not create request body", e);
    }

    final URI uri = URIUtils.createURI(repository, resource);
    final DavTemplateRequest request = new DavTemplateRequest("CHECKOUT", uri);
    request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML));
    return request;
}

From source file:de.qucosa.webapi.v1.SearchResource.java

private ResponseEntity<String> errorResponse(String message, HttpStatus status) throws XMLStreamException {
    StringWriter sw = new StringWriter();
    XMLStreamWriter w = xmlOutputFactory.createXMLStreamWriter(sw);
    w.writeStartDocument("UTF-8", "1.0");
    w.writeStartElement("Opus");
    w.writeEmptyElement("SearchResult");
    w.writeStartElement("Error");
    w.writeAttribute("message", message);
    w.writeEndElement();
    w.writeEndElement();/* w w w  .  ja  v a 2 s . c o m*/
    w.writeEndDocument();
    w.flush();
    return new ResponseEntity<>(sw.toString(), status);
}

From source file:babel.content.pages.Page.java

public void persist(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement(XML_TAG_PAGE);
    writer.writeAttribute(XML_ATTRIB_URL, m_pageURL);

    if (m_pageProps.numKeys() > 0) {
        m_pageProps.persist(writer);// w w w  .j a  va 2 s  . c o m
    }

    for (PageVersion ver : m_versions) {
        ver.persist(writer);
    }

    writer.writeEndElement();
}

From source file:com.norconex.collector.core.filter.impl.RegexMetadataFilter.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {//from   w  w w.  j  a va  2  s  .c om
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("filter");
        writer.writeAttribute("class", getClass().getCanonicalName());
        super.saveToXML(writer);
        writer.writeAttribute("caseSensitive", Boolean.toString(caseSensitive));
        writer.writeAttribute("field", field);
        writer.writeCharacters(regex == null ? "" : regex);
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}

From source file:com.predic8.membrane.core.config.Proxy.java

@Override
public void write(XMLStreamWriter out) throws XMLStreamException {
    out.writeStartElement(ELEMENT_NAME);

    out.writeAttribute(ATTRIBUTE_ACTIVE, Boolean.toString(useProxy));

    out.writeAttribute(ATTRIBUTE_AUTHENTICATION, Boolean.toString(useAuthentication));

    new ProxyHost(proxyHost).write(out);

    new ProxyPort(Integer.toString(proxyPort)).write(out);

    new ProxyUsername(proxyUsername).write(out);

    new ProxyPassword(proxyPassword).write(out);

    out.writeEndElement();
}

From source file:com.github.lindenb.jvarkit.util.command.Command.java

protected void writeHtmlDoc(final XMLStreamWriter w) throws XMLStreamException {
    w.writeStartElement("div");
    w.writeComment("no doc available for " + getName());
    w.writeEndElement();
}

From source file:com.norconex.collector.http.sitemap.impl.StandardSitemapResolverFactory.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {/* w ww. j a v a 2s.c  o  m*/
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("sitemapResolverFactory");
        writer.writeAttribute("class", getClass().getCanonicalName());
        writer.writeAttribute("lenient", Boolean.toString(lenient));
        if (sitemapLocations != null) {
            for (String location : sitemapLocations) {
                writer.writeStartElement("location");
                writer.writeCharacters(location);
                writer.writeEndElement();
            }
        }
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}