Package io.protostuff

Class XmlIOUtil


  • public final class XmlIOUtil
    extends java.lang.Object
    Utility for the XML serialization/deserialization of messages and objects tied to a schema.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String XML_ENCODING  
      static java.lang.String XML_VERSION  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private XmlIOUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> void mergeFrom​(byte[] data, int offset, int len, T message, Schema<T> schema)
      Merges the message with the byte array using the given schema.
      static <T> void mergeFrom​(byte[] data, int offset, int len, T message, Schema<T> schema, javax.xml.stream.XMLInputFactory inFactory)
      Merges the message with the byte array using the given schema.
      static <T> void mergeFrom​(byte[] data, T message, Schema<T> schema)
      Merges the message with the byte array using the given schema.
      static <T> void mergeFrom​(java.io.InputStream in, T message, Schema<T> schema)
      Merges the message from the InputStream using the given schema.
      static <T> void mergeFrom​(java.io.InputStream in, T message, Schema<T> schema, javax.xml.stream.XMLInputFactory inFactory)
      Merges the message from the InputStream using the given schema.
      static <T> void mergeFrom​(java.io.Reader r, T message, Schema<T> schema)
      Merges the message from the Reader using the given schema.
      static <T> void mergeFrom​(java.io.Reader r, T message, Schema<T> schema, javax.xml.stream.XMLInputFactory inFactory)
      Merges the message from the Reader using the given schema.
      static <T> void mergeFrom​(javax.xml.stream.XMLStreamReader parser, T message, Schema<T> schema)
      Merges the message from the XMLStreamReader using the given schema.
      static Pipe newPipe​(byte[] data)
      Creates an xml pipe from a byte array.
      static Pipe newPipe​(byte[] data, int offset, int length)
      Creates an xml pipe from a byte array.
      static Pipe newPipe​(java.io.InputStream in)
      Creates an xml pipe from an InputStream.
      static Pipe newPipe​(java.io.Reader reader)
      Creates an xml pipe from a Reader.
      static Pipe newPipe​(javax.xml.stream.XMLStreamReader parser)
      Creates an xml pipe from an XMLStreamReader.
      static <T> java.util.List<T> parseListFrom​(java.io.InputStream in, Schema<T> schema)
      Parses the messages from the InputStream using the given schema.
      static <T> java.util.List<T> parseListFrom​(java.io.InputStream in, Schema<T> schema, javax.xml.stream.XMLInputFactory inFactory)
      Parses the messages from the InputStream using the given schema.
      static <T> java.util.List<T> parseListFrom​(javax.xml.stream.XMLStreamReader parser, Schema<T> schema)
      Parses the messages from the XMLStreamReader using the given schema.
      static <T> byte[] toByteArray​(T message, Schema<T> schema)
      Serializes the message into a byte array.
      static <T> byte[] toByteArray​(T message, Schema<T> schema, javax.xml.stream.XMLOutputFactory outFactory)
      Serializes the message into a byte array.
      static <T> void writeListTo​(java.io.OutputStream out, java.util.List<T> messages, Schema<T> schema)
      Serializes the messages into the OutputStream using the given schema.
      static <T> void writeListTo​(java.io.OutputStream out, java.util.List<T> messages, Schema<T> schema, javax.xml.stream.XMLOutputFactory outFactory)
      Serializes the messages into the OutputStream using the given schema.
      static <T> void writeListTo​(javax.xml.stream.XMLStreamWriter writer, java.util.List<T> messages, Schema<T> schema)
      Serializes the messages into the XMLStreamWriter using the given schema.
      static <T> void writeTo​(java.io.OutputStream out, T message, Schema<T> schema)
      Serializes the message into an OutputStream using the given schema.
      static <T> void writeTo​(java.io.OutputStream out, T message, Schema<T> schema, javax.xml.stream.XMLOutputFactory outFactory)
      Serializes the message into an OutputStream using the given schema.
      static <T> void writeTo​(java.io.Writer w, T message, Schema<T> schema)
      Serializes the message into a Writer using the given schema.
      static <T> void writeTo​(java.io.Writer w, T message, Schema<T> schema, javax.xml.stream.XMLOutputFactory outFactory)
      Serializes the message into a Writer using the given schema.
      static <T> void writeTo​(javax.xml.stream.XMLStreamWriter writer, T message, Schema<T> schema)
      Serializes the message into an XMLStreamWriter using the given schema.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XmlIOUtil

        private XmlIOUtil()
    • Method Detail

      • newPipe

        public static Pipe newPipe​(byte[] data)
                            throws java.io.IOException
        Creates an xml pipe from a byte array.
        Throws:
        java.io.IOException
      • newPipe

        public static Pipe newPipe​(byte[] data,
                                   int offset,
                                   int length)
                            throws java.io.IOException
        Creates an xml pipe from a byte array.
        Throws:
        java.io.IOException
      • newPipe

        public static Pipe newPipe​(java.io.InputStream in)
                            throws java.io.IOException
        Creates an xml pipe from an InputStream.
        Throws:
        java.io.IOException
      • newPipe

        public static Pipe newPipe​(java.io.Reader reader)
                            throws java.io.IOException
        Creates an xml pipe from a Reader.
        Throws:
        java.io.IOException
      • newPipe

        public static Pipe newPipe​(javax.xml.stream.XMLStreamReader parser)
        Creates an xml pipe from an XMLStreamReader.
      • mergeFrom

        public static <T> void mergeFrom​(byte[] data,
                                         T message,
                                         Schema<T> schema)
        Merges the message with the byte array using the given schema.
      • mergeFrom

        public static <T> void mergeFrom​(byte[] data,
                                         int offset,
                                         int len,
                                         T message,
                                         Schema<T> schema)
        Merges the message with the byte array using the given schema.
      • mergeFrom

        public static <T> void mergeFrom​(byte[] data,
                                         int offset,
                                         int len,
                                         T message,
                                         Schema<T> schema,
                                         javax.xml.stream.XMLInputFactory inFactory)
        Merges the message with the byte array using the given schema.
      • mergeFrom

        public static <T> void mergeFrom​(java.io.InputStream in,
                                         T message,
                                         Schema<T> schema)
                                  throws java.io.IOException
        Merges the message from the InputStream using the given schema.
        Throws:
        java.io.IOException
      • mergeFrom

        public static <T> void mergeFrom​(java.io.InputStream in,
                                         T message,
                                         Schema<T> schema,
                                         javax.xml.stream.XMLInputFactory inFactory)
                                  throws java.io.IOException
        Merges the message from the InputStream using the given schema.
        Throws:
        java.io.IOException
      • mergeFrom

        public static <T> void mergeFrom​(java.io.Reader r,
                                         T message,
                                         Schema<T> schema)
                                  throws java.io.IOException
        Merges the message from the Reader using the given schema.
        Throws:
        java.io.IOException
      • mergeFrom

        public static <T> void mergeFrom​(java.io.Reader r,
                                         T message,
                                         Schema<T> schema,
                                         javax.xml.stream.XMLInputFactory inFactory)
                                  throws java.io.IOException
        Merges the message from the Reader using the given schema.
        Throws:
        java.io.IOException
      • mergeFrom

        public static <T> void mergeFrom​(javax.xml.stream.XMLStreamReader parser,
                                         T message,
                                         Schema<T> schema)
                                  throws java.io.IOException,
                                         javax.xml.stream.XMLStreamException,
                                         XmlInputException
        Merges the message from the XMLStreamReader using the given schema.
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
        XmlInputException
      • toByteArray

        public static <T> byte[] toByteArray​(T message,
                                             Schema<T> schema)
        Serializes the message into a byte array.
      • toByteArray

        public static <T> byte[] toByteArray​(T message,
                                             Schema<T> schema,
                                             javax.xml.stream.XMLOutputFactory outFactory)
        Serializes the message into a byte array.
      • writeTo

        public static <T> void writeTo​(java.io.OutputStream out,
                                       T message,
                                       Schema<T> schema)
                                throws java.io.IOException
        Serializes the message into an OutputStream using the given schema.
        Throws:
        java.io.IOException
      • writeTo

        public static <T> void writeTo​(java.io.OutputStream out,
                                       T message,
                                       Schema<T> schema,
                                       javax.xml.stream.XMLOutputFactory outFactory)
                                throws java.io.IOException
        Serializes the message into an OutputStream using the given schema.
        Throws:
        java.io.IOException
      • writeTo

        public static <T> void writeTo​(java.io.Writer w,
                                       T message,
                                       Schema<T> schema)
                                throws java.io.IOException
        Serializes the message into a Writer using the given schema.
        Throws:
        java.io.IOException
      • writeTo

        public static <T> void writeTo​(java.io.Writer w,
                                       T message,
                                       Schema<T> schema,
                                       javax.xml.stream.XMLOutputFactory outFactory)
                                throws java.io.IOException
        Serializes the message into a Writer using the given schema.
        Throws:
        java.io.IOException
      • writeTo

        public static <T> void writeTo​(javax.xml.stream.XMLStreamWriter writer,
                                       T message,
                                       Schema<T> schema)
                                throws java.io.IOException,
                                       javax.xml.stream.XMLStreamException,
                                       XmlOutputException
        Serializes the message into an XMLStreamWriter using the given schema.
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
        XmlOutputException
      • writeListTo

        public static <T> void writeListTo​(java.io.OutputStream out,
                                           java.util.List<T> messages,
                                           Schema<T> schema)
                                    throws java.io.IOException
        Serializes the messages into the OutputStream using the given schema.
        Throws:
        java.io.IOException
      • writeListTo

        public static <T> void writeListTo​(java.io.OutputStream out,
                                           java.util.List<T> messages,
                                           Schema<T> schema,
                                           javax.xml.stream.XMLOutputFactory outFactory)
                                    throws java.io.IOException
        Serializes the messages into the OutputStream using the given schema.
        Throws:
        java.io.IOException
      • writeListTo

        public static <T> void writeListTo​(javax.xml.stream.XMLStreamWriter writer,
                                           java.util.List<T> messages,
                                           Schema<T> schema)
                                    throws java.io.IOException,
                                           javax.xml.stream.XMLStreamException
        Serializes the messages into the XMLStreamWriter using the given schema.
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • parseListFrom

        public static <T> java.util.List<T> parseListFrom​(java.io.InputStream in,
                                                          Schema<T> schema)
                                                   throws java.io.IOException
        Parses the messages from the InputStream using the given schema.
        Throws:
        java.io.IOException
      • parseListFrom

        public static <T> java.util.List<T> parseListFrom​(java.io.InputStream in,
                                                          Schema<T> schema,
                                                          javax.xml.stream.XMLInputFactory inFactory)
                                                   throws java.io.IOException
        Parses the messages from the InputStream using the given schema.
        Throws:
        java.io.IOException
      • parseListFrom

        public static <T> java.util.List<T> parseListFrom​(javax.xml.stream.XMLStreamReader parser,
                                                          Schema<T> schema)
                                                   throws java.io.IOException,
                                                          javax.xml.stream.XMLStreamException
        Parses the messages from the XMLStreamReader using the given schema.
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException