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 ofInDoipMessagewhich reads a serialized DOIP message from anInputStream.
-
-
Constructor Summary
Constructors Constructor Description InDoipMessageImpl(java.io.InputStream in)Constructs anInDoipMessageusing the serialized DOIP message from the suppliedInputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Reads all remaining segments (unless the DOIP message is malformed, in which case it returns immediately).BadDoipExceptiongetTerminalException()If the DOIP message was malformed, retrieves aBadDoipExceptionindicating how; otherwise returns null.java.util.Iterator<InDoipSegment>iterator()voidsetCompleter(java.util.concurrent.CompletableFuture<?> completer)Sets aCompletableFuturewhich 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 typeInDoipSegment.
-
-
-
Constructor Detail
-
InDoipMessageImpl
public InDoipMessageImpl(java.io.InputStream in)
Constructs anInDoipMessageusing the serialized DOIP message from the suppliedInputStream.- 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 aCompletableFuturewhich will be completed when the message is fully processed. It will be completed normally withnullwhen 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 aBadDoipExceptionindicating how; otherwise returns null.- Returns:
- an instance of
BadDoipExceptionwhich indicates how the DOIP message was malformed, or null
-
iterator
public java.util.Iterator<InDoipSegment> iterator()
- Specified by:
iteratorin interfacejava.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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceInDoipMessage
-
spliterator
public java.util.Spliterator<InDoipSegment> spliterator()
- Specified by:
spliteratorin interfacejava.lang.Iterable<InDoipSegment>
-
stream
public java.util.stream.Stream<InDoipSegment> stream()
Description copied from interface:InDoipMessageReturns an stream over elements of typeInDoipSegment.- Specified by:
streamin interfaceInDoipMessage- Returns:
- a Stream.
-
-