Example usage for javax.xml.stream XMLStreamWriter getClass

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

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.apache.axiom.om.util.StAXUtils.java

public static XMLStreamWriter createXMLStreamWriter(StAXWriterConfiguration configuration,
        final OutputStream out) throws XMLStreamException {
    final XMLOutputFactory outputFactory = getXMLOutputFactory(configuration);
    try {//from   w w  w .  j a  v  a  2s.  com
        XMLStreamWriter writer = (XMLStreamWriter) AccessController
                .doPrivileged(new PrivilegedExceptionAction() {
                    public Object run() throws XMLStreamException {
                        return outputFactory.createXMLStreamWriter(out, OMConstants.DEFAULT_CHAR_SET_ENCODING);
                    }
                });

        if (isDebugEnabled) {
            log.debug("XMLStreamWriter is " + writer.getClass().getName());
        }
        return writer;
    } catch (PrivilegedActionException pae) {
        throw (XMLStreamException) pae.getException();
    }
}

From source file:org.apache.axiom.om.util.StAXUtils.java

public static XMLStreamWriter createXMLStreamWriter(StAXWriterConfiguration configuration,
        final OutputStream out, final String encoding) throws XMLStreamException {
    final XMLOutputFactory outputFactory = getXMLOutputFactory(configuration);
    try {//from w w w . java2s .  com
        XMLStreamWriter writer = (XMLStreamWriter) AccessController
                .doPrivileged(new PrivilegedExceptionAction() {
                    public Object run() throws XMLStreamException {
                        return outputFactory.createXMLStreamWriter(out, encoding);
                    }
                });

        if (isDebugEnabled) {
            log.debug("XMLStreamWriter is " + writer.getClass().getName());
        }
        return writer;
    } catch (PrivilegedActionException pae) {
        throw (XMLStreamException) pae.getException();
    }
}

From source file:org.apache.axiom.om.util.StAXUtils.java

public static XMLStreamWriter createXMLStreamWriter(StAXWriterConfiguration configuration, final Writer out)
        throws XMLStreamException {
    final XMLOutputFactory outputFactory = getXMLOutputFactory(configuration);
    try {/*ww w .j  a v a  2s  .  c  o m*/
        XMLStreamWriter writer = (XMLStreamWriter) AccessController
                .doPrivileged(new PrivilegedExceptionAction() {
                    public Object run() throws XMLStreamException {
                        return outputFactory.createXMLStreamWriter(out);
                    }
                });
        if (isDebugEnabled) {
            log.debug("XMLStreamWriter is " + writer.getClass().getName());
        }
        return writer;
    } catch (PrivilegedActionException pae) {
        throw (XMLStreamException) pae.getException();
    }
}

From source file:org.apache.axis2.datasource.jaxb.JAXBDSContext.java

/**
 * If the writer is backed by an OutputStream, then return the OutputStream
 * @param writer/*from w w  w . j a  v a 2  s.  c  o  m*/
 * @param Marshaller
 * @return OutputStream or null
 */
private static OutputStream getOutputStream(XMLStreamWriter writer, Marshaller m) throws XMLStreamException {
    if (log.isDebugEnabled()) {
        log.debug("XMLStreamWriter is " + writer);
    }
    OutputStream os = null;
    if (writer.getClass() == MTOMXMLStreamWriter.class) {
        os = ((MTOMXMLStreamWriter) writer).getOutputStream();
        if (log.isDebugEnabled()) {
            log.debug("OutputStream accessible from MTOMXMLStreamWriter is " + os);
        }
    }
    if (writer.getClass() == XMLStreamWriterWithOS.class) {
        os = ((XMLStreamWriterWithOS) writer).getOutputStream();
        if (log.isDebugEnabled()) {
            log.debug("OutputStream accessible from XMLStreamWriterWithOS is " + os);
        }
    }
    if (os != null) {
        String marshallerEncoding = null;
        try {
            marshallerEncoding = (String) m.getProperty(Marshaller.JAXB_ENCODING);
        } catch (PropertyException e) {
            if (DEBUG_ENABLED) {
                log.debug("Could not query JAXB_ENCODING..Continuing. " + e);
            }
        }
        if (marshallerEncoding != null && !marshallerEncoding.equalsIgnoreCase("UTF-8")) {
            if (DEBUG_ENABLED) {
                log.debug("Wrapping output stream to remove BOM");
            }
            os = new BOMOutputStreamFilter(marshallerEncoding, os);
        }
    }

    return os;
}

From source file:org.jboss.rusheye.result.writer.PrettyXMLStreamWriter.java

public static XMLStreamWriter pretty(XMLStreamWriter writer) {
    return (XMLStreamWriter) Proxy.newProxyInstance(writer.getClass().getClassLoader(),
            new Class[] { XMLStreamWriter.class }, new PrettyXMLStreamWriter(writer));
}