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:org.unitedinternet.cosmo.dav.CosmoDavException.java

public void writeTo(XMLStreamWriter writer) throws XMLStreamException {
    writer.setNamespaceContext(nsc);//from w w  w  . j  a  v a 2 s  .com
    writer.writeStartElement("DAV:", "error");
    for (String uri : nsc.getNamespaceURIs()) {
        writer.writeNamespace(nsc.getPrefix(uri), uri);
    }
    writeContent(writer);
    writer.writeEndElement();
}

From source file:com.flexive.extractor.audio.FxAudioMetaDataImpl.java

/**
 * {@inheritDoc}/*  w  w  w  .j  ava 2 s.com*/
 */
@Override
protected void writeXMLTags(XMLStreamWriter writer) throws XMLStreamException {
    // remaining audio data (sample rate, etc): FxMetadataItems
    writer.writeStartElement("audioData");
    writeSimpleTag(writer, "length", getLengthAsTimeString(), false);
    writeSimpleTag(writer, "durationmicros", getLength(), false);
    writer.writeEndElement();
}

From source file:de.huxhorn.sulky.plist.impl.PropertyListWriter.java

private void writeArray(XMLStreamWriter writer, Collection collection) throws XMLStreamException {
    StaxUtilities.writeStartElement(writer, null, null, ARRAY_NODE);

    for (Object o : collection) {
        writeValue(writer, o);//w  w w .  j  a v a  2s  .c  o m
    }

    writer.writeEndElement();
}

From source file:net.solarnetwork.web.support.SimpleXmlHttpMessageConverter.java

private void outputCollection(Collection<?> col, String name, XMLStreamWriter writer)
        throws IOException, XMLStreamException {
    writeElement(name, null, writer, false);
    for (Object o : col) {
        outputObject(o, null, writer);/*ww  w  .jav a  2s  .c o m*/
    }
    writer.writeEndElement();
}

From source file:org.maodian.flyingcat.xmpp.extensions.xep0077.RegistrationCodec.java

@Override
public void encode(Object object, XMLStreamWriter xmlsw) throws XMLStreamException {
    xmlsw.writeStartElement("", "query", InBandRegistration.REGISTER);
    xmlsw.writeDefaultNamespace(InBandRegistration.REGISTER);

    xmlsw.writeEmptyElement(InBandRegistration.REGISTER, "username");
    xmlsw.writeEmptyElement(InBandRegistration.REGISTER, "password");

    xmlsw.writeEndElement();
}

From source file:com.norconex.committer.solr.SolrCommitter.java

@Override
protected void saveToXML(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("solrURL");
    writer.writeCharacters(solrURL);//from w w w  . j av  a  2  s  . co m
    writer.writeEndElement();

    writer.writeStartElement("solrUpdateURLParams");
    for (String name : updateUrlParams.keySet()) {
        writer.writeStartElement("param");
        writer.writeAttribute("name", name);
        writer.writeCharacters(updateUrlParams.get(name));
        writer.writeEndElement();
    }
    writer.writeEndElement();
}

From source file:XmlReaderToWriter.java

public static void write(XMLStreamReader xmlr, XMLStreamWriter writer) throws XMLStreamException {
    switch (xmlr.getEventType()) {
    case XMLEvent.START_ELEMENT:
        final String localName = xmlr.getLocalName();
        final String namespaceURI = xmlr.getNamespaceURI();
        if (namespaceURI != null && namespaceURI.length() > 0) {
            final String prefix = xmlr.getPrefix();
            if (prefix != null)
                writer.writeStartElement(prefix, localName, namespaceURI);
            else// w  ww .j  a v  a  2  s . c  om
                writer.writeStartElement(namespaceURI, localName);
        } else {
            writer.writeStartElement(localName);
        }

        for (int i = 0, len = xmlr.getNamespaceCount(); i < len; i++) {
            writer.writeNamespace(xmlr.getNamespacePrefix(i), xmlr.getNamespaceURI(i));
        }

        for (int i = 0, len = xmlr.getAttributeCount(); i < len; i++) {
            String attUri = xmlr.getAttributeNamespace(i);
            if (attUri != null)
                writer.writeAttribute(attUri, xmlr.getAttributeLocalName(i), xmlr.getAttributeValue(i));
            else
                writer.writeAttribute(xmlr.getAttributeLocalName(i), xmlr.getAttributeValue(i));
        }
        break;
    case XMLEvent.END_ELEMENT:
        writer.writeEndElement();
        break;
    case XMLEvent.SPACE:
    case XMLEvent.CHARACTERS:
        writer.writeCharacters(xmlr.getTextCharacters(), xmlr.getTextStart(), xmlr.getTextLength());
        break;
    case XMLEvent.PROCESSING_INSTRUCTION:
        writer.writeProcessingInstruction(xmlr.getPITarget(), xmlr.getPIData());
        break;
    case XMLEvent.CDATA:
        writer.writeCData(xmlr.getText());
        break;

    case XMLEvent.COMMENT:
        writer.writeComment(xmlr.getText());
        break;
    case XMLEvent.ENTITY_REFERENCE:
        writer.writeEntityRef(xmlr.getLocalName());
        break;
    case XMLEvent.START_DOCUMENT:
        String encoding = xmlr.getCharacterEncodingScheme();
        String version = xmlr.getVersion();

        if (encoding != null && version != null)
            writer.writeStartDocument(encoding, version);
        else if (version != null)
            writer.writeStartDocument(xmlr.getVersion());
        break;
    case XMLEvent.END_DOCUMENT:
        writer.writeEndDocument();
        break;
    case XMLEvent.DTD:
        writer.writeDTD(xmlr.getText());
        break;
    }
}

From source file:com.norconex.committer.elasticsearch.ElasticsearchCommitter.java

@Override
protected void saveToXML(XMLStreamWriter writer) throws XMLStreamException {

    writer.writeStartElement("clusterName");
    writer.writeCharacters(clusterName);
    writer.writeEndElement();

    writer.writeStartElement("indexName");
    writer.writeCharacters(indexName);//from  ww  w. j a v a 2  s .  c  o  m
    writer.writeEndElement();

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

From source file:com.norconex.committer.elasticsearch_rest.ElasticsearchCommitter.java

@Override
protected void saveToXML(XMLStreamWriter writer) throws XMLStreamException {

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

    writer.writeStartElement("indexName");
    writer.writeCharacters(indexName);
    writer.writeEndElement();

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