Class MessageStreams


  • public class MessageStreams
    extends java.lang.Object
    Helper class to create streams that read providence messages.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static byte[] READABLE_ENTRY_SEP  
    • Constructor Summary

      Constructors 
      Constructor Description
      MessageStreams()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <Message extends PMessage<Message,Field>,Field extends PField>
      java.util.stream.Stream<Message>
      file​(java.io.File file, Serializer serializer, PMessageDescriptor<Message,Field> descriptor)
      Read a file containing entries of a given type.
      static <Message extends PMessage<Message,Field>,Field extends PField>
      java.util.stream.Stream<Message>
      path​(java.nio.file.Path file, Serializer serializer, PMessageDescriptor<Message,Field> descriptor)
      Read a file containing entries of a given type.
      static <Message extends PMessage<Message,Field>,Field extends PField>
      java.util.stream.Stream<Message>
      resource​(java.lang.String resource, Serializer serializer, PMessageDescriptor<Message,Field> descriptor)
      Read a file containing entries of a given type.
      static <Message extends PMessage<Message,Field>,Field extends PField>
      java.util.stream.Stream<Message>
      stream​(java.io.InputStream in, Serializer serializer, PMessageDescriptor<Message,Field> descriptor)
      Read a input stream containing entries of a given type.
      • Methods inherited from class java.lang.Object

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

      • READABLE_ENTRY_SEP

        public static final byte[] READABLE_ENTRY_SEP
    • Constructor Detail

      • MessageStreams

        public MessageStreams()
    • Method Detail

      • path

        @Nonnull
        public static <Message extends PMessage<Message,Field>,Field extends PField> java.util.stream.Stream<Message> path​(java.nio.file.Path file,
                                                                                                                           Serializer serializer,
                                                                                                                           PMessageDescriptor<Message,Field> descriptor)
                                                                                                                    throws java.io.IOException
        Read a file containing entries of a given type. Tries to detect the entry format of the file based on file magic. If not detected will try to use the default binary serializer format.
        Type Parameters:
        Message - The message type.
        Field - The message field type.
        Parameters:
        file - The file to read.
        serializer - The serializer to use.
        descriptor - The descriptor of the entry type of the file.
        Returns:
        The stream that reads the file.
        Throws:
        java.io.IOException - when unable to open the stream.
      • file

        @Nonnull
        public static <Message extends PMessage<Message,Field>,Field extends PField> java.util.stream.Stream<Message> file​(java.io.File file,
                                                                                                                           Serializer serializer,
                                                                                                                           PMessageDescriptor<Message,Field> descriptor)
                                                                                                                    throws java.io.IOException
        Read a file containing entries of a given type. Tries to detect the entry format of the file based on file magic. If not detected will try to use the default binary serializer format.
        Type Parameters:
        Message - The message type.
        Field - The message field type.
        Parameters:
        file - The file to read.
        serializer - The serializer to use.
        descriptor - The descriptor of the entry type of the file.
        Returns:
        The stream that reads the file.
        Throws:
        java.io.IOException - when unable to open the stream.
      • resource

        @Nonnull
        public static <Message extends PMessage<Message,Field>,Field extends PField> java.util.stream.Stream<Message> resource​(@Nonnull
                                                                                                                               java.lang.String resource,
                                                                                                                               @Nonnull
                                                                                                                               Serializer serializer,
                                                                                                                               @Nonnull
                                                                                                                               PMessageDescriptor<Message,Field> descriptor)
                                                                                                                        throws java.io.IOException
        Read a file containing entries of a given type. Tries to detect the entry format of the file based on file magic. If not detected will try to use the default binary serializer format.
        Type Parameters:
        Message - The message type.
        Field - The message field type.
        Parameters:
        resource - The file to read.
        serializer - The serializer to use.
        descriptor - The descriptor of the entry type of the file.
        Returns:
        The stream that reads the file.
        Throws:
        java.io.IOException - when unable find the resource.
      • stream

        @Nonnull
        public static <Message extends PMessage<Message,Field>,Field extends PField> java.util.stream.Stream<Message> stream​(java.io.InputStream in,
                                                                                                                             Serializer serializer,
                                                                                                                             PMessageDescriptor<Message,Field> descriptor)
        Read a input stream containing entries of a given type.
        Type Parameters:
        Message - The message type.
        Field - The message field type.
        Parameters:
        in - The input stream to read.
        serializer - The serializer to use.
        descriptor - The descriptor of the entry type of the file.
        Returns:
        The stream that reads the file.