Package net.dona.doip

## Class InDoipMessageImpl

- java.lang.Object
- - net.dona.doip.InDoipMessageImpl

- All Implemented Interfaces:
    `java.lang.AutoCloseable`, `java.lang.Iterable<InDoipSegment>`, `InDoipMessage`

      public class InDoipMessageImpl
      extends java.lang.Object
      implements InDoipMessage

  An implementation of `InDoipMessage` which reads a serialized DOIP message from an `InputStream`.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `InDoipMessageImpl​(java.io.InputStream in)` | Constructs an `InDoipMessage` using the serialized DOIP message from the supplied `InputStream`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Reads all remaining segments (unless the DOIP message is malformed, in which case it returns immediately).
    `BadDoipException` | `getTerminalException()` | If the DOIP message was malformed, retrieves a `BadDoipException` indicating how; otherwise returns null.
    `java.util.Iterator<InDoipSegment>` | `iterator()` |
    `void` | `setCompleter​(java.util.concurrent.CompletableFuture<?> completer)` | Sets a `CompletableFuture` which will be completed when the message is fully processed.
    `java.util.Spliterator<InDoipSegment>` | `spliterator()` |
    `java.util.stream.Stream<InDoipSegment>` | `stream()` | Returns an stream over elements of type `InDoipSegment`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

- - ### Constructor Detail

    - #### InDoipMessageImpl

          public InDoipMessageImpl​(java.io.InputStream in)

      Constructs an `InDoipMessage` using the serialized DOIP message from the supplied `InputStream`.
      Parameters:
        `in` - the input stream from which to read the serialized DOIP message

  - ### Method Detail

    - #### setCompleter

          public void setCompleter​(java.util.concurrent.CompletableFuture<?> completer)

      Sets a `CompletableFuture` which will be completed when the message is fully processed. It will be completed normally with `null` when all segments are read; it will be completed exceptionally if the DOIP message is malformed.
      Parameters:
        `completer` - the future to complete when the message is fully processed

    - #### getTerminalException

          public BadDoipException getTerminalException()

      If the DOIP message was malformed, retrieves a `BadDoipException` indicating how; otherwise returns null.
      Returns:
        an instance of `BadDoipException` which indicates how the DOIP message was malformed, or null

    - #### iterator

          public java.util.Iterator<InDoipSegment> iterator()

      Specified by:
        `iterator` in interface `java.lang.Iterable<InDoipSegment>`

    - #### close

          public void close()

      Reads all remaining segments (unless the DOIP message is malformed, in which case it returns immediately).
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Specified by:
        `close` in interface `InDoipMessage`

    - #### spliterator

          public java.util.Spliterator<InDoipSegment> spliterator()

      Specified by:
        `spliterator` in interface `java.lang.Iterable<InDoipSegment>`

    - #### stream

          public java.util.stream.Stream<InDoipSegment> stream()

      Description copied from interface: `InDoipMessage`
      Returns an stream over elements of type `InDoipSegment`.
      Specified by:
        `stream` in interface `InDoipMessage`
      Returns:
        a Stream.