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 ofInDoipMessage
which reads a serialized DOIP message from anInputStream
.
-
-
Constructor Summary
Constructors Constructor Description InDoipMessageImpl(java.io.InputStream in)
Constructs anInDoipMessage
using the serialized DOIP message from the suppliedInputStream
.
-
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 aBadDoipException
indicating how; otherwise returns null.java.util.Iterator<InDoipSegment>
iterator()
void
setCompleter(java.util.concurrent.CompletableFuture<?> completer)
Sets aCompletableFuture
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 typeInDoipSegment
.
-
-
-
Constructor Detail
-
InDoipMessageImpl
public InDoipMessageImpl(java.io.InputStream in)
Constructs anInDoipMessage
using 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 aCompletableFuture
which will be completed when the message is fully processed. It will be completed normally withnull
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 aBadDoipException
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 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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceInDoipMessage
-
spliterator
public java.util.Spliterator<InDoipSegment> spliterator()
- Specified by:
spliterator
in interfacejava.lang.Iterable<InDoipSegment>
-
stream
public java.util.stream.Stream<InDoipSegment> stream()
Description copied from interface:InDoipMessage
Returns an stream over elements of typeInDoipSegment
.- Specified by:
stream
in interfaceInDoipMessage
- Returns:
- a Stream.
-
-