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.ProbeServerOperation.java

@Override
protected HttpUriRequest createRequest() {
    final Writer body = new StringBuilderWriter();
    try {// w  w w.j av a 2  s .c om
        final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body);
        writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0);
        writer.writeStartElement("options");
        writer.writeDefaultNamespace(XmlConstants.DAV_NAMESPACE);
        writer.writeEmptyElement("activity-collection-set");
        writer.writeEndElement(); //options
        writer.writeEndDocument();
        writer.close();
    } catch (final XMLStreamException e) {
        throw new SubversionException("could not create request body: " + e.getMessage(), e);
    }

    final DavTemplateRequest request = new DavTemplateRequest("OPTIONS", repository);
    request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML));
    return request;
}

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

@Override
protected HttpUriRequest createRequest() {
    final URI uri = URIUtils.createURI(repository, resource);
    final DavTemplateRequest request = new DavTemplateRequest("LOCK", uri);
    if (steal) {/*ww  w  .j a  v a2s .  c om*/
        request.addHeader("X-SVN-Options", "lock-steal");
    }

    final Writer body = new StringBuilderWriter();
    try {
        final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body);
        writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0);
        writer.writeStartElement("lockinfo");
        writer.writeDefaultNamespace(XmlConstants.DAV_NAMESPACE);
        writer.writeStartElement("lockscope");
        writer.writeEmptyElement("exclusive");
        writer.writeEndElement(); // lockscope
        writer.writeStartElement("locktype");
        writer.writeEmptyElement("write");
        writer.writeEndElement(); // locktype
        writer.writeEndElement(); //lockinfo
        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.GenericMetadataFetcher.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {// w ww.j  a v  a  2  s. co m
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("httpHeadersFetcher");
        writer.writeAttribute("class", getClass().getCanonicalName());
        writer.writeStartElement("validStatusCodes");
        writer.writeCharacters(StringUtils.join(validStatusCodes, ","));
        writer.writeEndElement();
        writer.writeStartElement("headersPrefix");
        writer.writeCharacters(headersPrefix);
        writer.writeEndElement();
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}

From source file:com.norconex.committer.core.impl.FileSystemCommitter.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {//  w  ww .  j  ava  2s.  c  o  m
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("committer");
        writer.writeAttribute("class", getClass().getCanonicalName());
        writer.writeStartElement("directory");
        writer.writeCharacters(directory);
        writer.writeEndElement();
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}

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

@Override
protected HttpUriRequest createRequest() {
    final Writer body = new StringBuilderWriter();
    try {/*from w  w  w  .j  ava2 s  . c o  m*/
        final XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(body);
        writer.writeStartDocument(XmlConstants.ENCODING, XmlConstants.VERSION_1_0);
        writer.writeStartElement("log-report");
        writer.writeDefaultNamespace(XmlConstants.SVN_NAMESPACE);
        writer.writeStartElement("start-revision");
        writer.writeCharacters(start.toString());
        writer.writeEndElement(); // start-revision
        writer.writeStartElement("end-revision");
        writer.writeCharacters(end.toString());
        writer.writeEndElement(); // end-revision
        if (limit > 0) {
            writer.writeStartElement("limit");
            writer.writeCharacters(Integer.toString(limit));
            writer.writeEndElement(); // limit
        }
        writer.writeEmptyElement("discover-changed-paths");
        writer.writeEmptyElement("all-revprops");
        writer.writeEmptyElement("path");
        writer.writeEndElement(); // log-report
        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("REPORT", uri);
    request.setEntity(new StringEntity(body.toString(), CONTENT_TYPE_XML));
    return request;
}

From source file:com.norconex.committer.cloudsearch.CloudSearchCommitter.java

@Override
protected void saveToXML(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("documentEndpoint");
    writer.writeCharacters(documentEndpoint);
    writer.writeEndElement();

    writer.writeStartElement("accessKey");
    writer.writeCharacters(accessKey);/*from  ww  w  . ja  va 2  s.c o m*/
    writer.writeEndElement();

    writer.writeStartElement("secretKey");
    writer.writeCharacters(secretKey);
    writer.writeEndElement();
}

From source file:com.fiorano.openesb.application.application.MessageTransformation.java

protected void toJXMLString_1(XMLStreamWriter writer, boolean writeCDataSections)
        throws XMLStreamException, FioranoException {
    if (writeCDataSections)
        writeCDATAElement(writer, ELEM_JMS_SCRIPT, jmsScript);
    else {//from   www. ja  va  2  s.c  o m
        if (jmsScriptFile != null) {
            writer.writeStartElement(ELEM_JMS_SCRIPT_FILE);
            writer.writeAttribute(ATTR_NAME, jmsScriptFile);
            writer.writeEndElement();
        }
    }
}

From source file:com.norconex.jef4.log.FileLogManager.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {// w w w  .  j  a  v  a 2 s .  c o  m
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("logManager");
        writer.writeAttribute("class", getClass().getCanonicalName());
        writer.writeStartElement("logDir");
        writer.writeCharacters(new File(logdir).getAbsolutePath());
        writer.writeEndElement();
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}

From source file:microsoft.exchange.webservices.data.core.EwsUtilities.java

/**
 * .// www .  j  a  v  a  2 s  .  c  o m
 *
 * @param entryKind the entry kind
 * @param logEntry  the log entry
 * @return the string
 * @throws XMLStreamException the XML stream exception
 * @throws IOException signals that an I/O exception has occurred.
 */
public static String formatLogMessage(String entryKind, String logEntry)
        throws XMLStreamException, IOException {
    String lineSeparator = System.getProperty("line.separator");
    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    XMLStreamWriter writer = factory.createXMLStreamWriter(outStream);
    EwsUtilities.writeTraceStartElement(writer, entryKind, false);
    writer.writeCharacters(lineSeparator);
    writer.writeCharacters(logEntry);
    writer.writeCharacters(lineSeparator);
    writer.writeEndElement();
    writer.writeCharacters(lineSeparator);
    writer.flush();
    writer.close();
    outStream.flush();
    String formattedLogMessage = outStream.toString();
    formattedLogMessage = formattedLogMessage.replaceAll("'", "'");
    formattedLogMessage = formattedLogMessage.replaceAll(""", "\"");
    formattedLogMessage = formattedLogMessage.replaceAll(">", ">");
    formattedLogMessage = formattedLogMessage.replaceAll("&lt;", "<");
    formattedLogMessage = formattedLogMessage.replaceAll("&amp;", "&");
    outStream.close();
    return formattedLogMessage;
}

From source file:com.norconex.collector.http.url.impl.DefaultURLExtractor.java

@Override
public void saveToXML(Writer out) throws IOException {
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    try {/*from www .  ja v a 2 s.c om*/
        XMLStreamWriter writer = factory.createXMLStreamWriter(out);
        writer.writeStartElement("urlExtractor");
        writer.writeAttribute("class", getClass().getCanonicalName());
        writer.writeStartElement("maxURLLength");
        writer.writeCharacters(Integer.toString(maxURLLength));
        writer.writeEndElement();
        writer.writeEndElement();
        writer.flush();
        writer.close();
    } catch (XMLStreamException e) {
        throw new IOException("Cannot save as XML.", e);
    }
}