Class XmppStreamEncoder

  • All Implemented Interfaces:
    WriterInterceptor

    public final class XmppStreamEncoder
    extends Object
    implements WriterInterceptor
    Encodes XMPP elements to binary data.

    This class is capable to encode elements to either an OutputStream or to a ByteBuffer.

    Encoding is thread-safe, as long as the supplied Marshaller is not shared by another thread, e.g. if a thread-local Marshaller is supplied.

    • Constructor Detail

      • XmppStreamEncoder

        public XmppStreamEncoder​(XMLOutputFactory outputFactory,
                                 Supplier<javax.xml.bind.Marshaller> marshaller,
                                 Function<StreamElement,​Boolean> writeStreamNamespace)
        Creates the XMPP encoder.

        Because Marshaller is not thread-safe, it is recommended to pass a ThreadLocal<Marshaller> to this constructor, which ensures thread-safety during marshalling.

        Parameters:
        outputFactory - The XML output factory.
        marshaller - Supplies the marshaller which will convert objects to XML.
        writeStreamNamespace - If the stream namespace should be written in the root element.