Class MessageStreams


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

      Constructors 
      Constructor Description
      MessageStreams()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <Message extends PMessage<Message>>
      java.util.stream.Stream<Message>
      file​(java.io.File file, Serializer serializer, PMessageDescriptor<Message> descriptor)
      Read a file containing entries of a given type.
      static <Message extends PMessage<Message>>
      java.util.stream.Stream<Message>
      path​(java.nio.file.Path file, Serializer serializer, PMessageDescriptor<Message> descriptor)
      Read a file containing entries of a given type.
      static <Message extends PMessage<Message>>
      java.util.stream.Stream<Message>
      resource​(java.lang.String resource, Serializer serializer, PMessageDescriptor<Message> descriptor)
      Read a file containing entries of a given type.
      static <Message extends PMessage<Message>>
      java.util.stream.Stream<Message>
      stream​(java.io.InputStream in, Serializer serializer, PMessageDescriptor<Message> 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
    • Constructor Detail

      • MessageStreams

        public MessageStreams()
    • Method Detail

      • path

        @Nonnull
        public static <Message extends PMessage<Message>> java.util.stream.Stream<Message> path​(java.nio.file.Path file,
                                                                                                Serializer serializer,
                                                                                                PMessageDescriptor<Message> 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.
        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>> java.util.stream.Stream<Message> file​(java.io.File file,
                                                                                                Serializer serializer,
                                                                                                PMessageDescriptor<Message> 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.
        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>> java.util.stream.Stream<Message> resource​(@Nonnull
                                                                                                    java.lang.String resource,
                                                                                                    @Nonnull
                                                                                                    Serializer serializer,
                                                                                                    @Nonnull
                                                                                                    PMessageDescriptor<Message> 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.
        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>> java.util.stream.Stream<Message> stream​(java.io.InputStream in,
                                                                                                  Serializer serializer,
                                                                                                  PMessageDescriptor<Message> descriptor)
        Read a input stream containing entries of a given type.
        Type Parameters:
        Message - The message 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.