Class AbstractStreamDecoder<M,MT extends java.lang.Enum<MT>,ST extends java.lang.Enum<ST>>
- java.lang.Object
-
- org.apache.maven.surefire.api.stream.AbstractStreamDecoder<M,MT,ST>
-
- Type Parameters:
M
- message objectMT
- enum describing the meaning of the messageST
- enum for segment type
- All Implemented Interfaces:
java.lang.AutoCloseable
public abstract class AbstractStreamDecoder<M,MT extends java.lang.Enum<MT>,ST extends java.lang.Enum<ST>> extends java.lang.Object implements java.lang.AutoCloseable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
AbstractStreamDecoder.BufferedStream
This class avoids locking which gains the performance of this decoder.static class
AbstractStreamDecoder.MalformedFrameException
class
AbstractStreamDecoder.Memento
static class
AbstractStreamDecoder.Segment
static class
AbstractStreamDecoder.StreamReadStatus
Underflow - could not completely read out al bytes in one call.
-
Field Summary
Fields Modifier and Type Field Description static int
BUFFER_SIZE
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractStreamDecoder(java.nio.channels.ReadableByteChannel channel, ForkNodeArguments arguments, java.util.Map<AbstractStreamDecoder.Segment,MT> messageTypes)
-
Method Summary
-
-
-
Field Detail
-
BUFFER_SIZE
public static final int BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractStreamDecoder
protected AbstractStreamDecoder(@Nonnull java.nio.channels.ReadableByteChannel channel, @Nonnull ForkNodeArguments arguments, @Nonnull java.util.Map<AbstractStreamDecoder.Segment,MT> messageTypes)
-
-
Method Detail
-
decode
public abstract M decode(@Nonnull AbstractStreamDecoder.Memento memento) throws MalformedChannelException, java.io.IOException
- Throws:
MalformedChannelException
java.io.IOException
-
getEncodedMagicNumber
@Nonnull protected abstract byte[] getEncodedMagicNumber()
-
toMessage
@Nonnull protected abstract M toMessage(@Nonnull MT messageType, @Nonnull AbstractStreamDecoder.Memento memento) throws AbstractStreamDecoder.MalformedFrameException
-
getArguments
@Nonnull protected final ForkNodeArguments getArguments()
-
debugStream
protected void debugStream(byte[] array, int position, int remaining)
-
readMessageType
protected MT readMessageType(@Nonnull AbstractStreamDecoder.Memento memento) throws java.io.IOException, AbstractStreamDecoder.MalformedFrameException
- Throws:
java.io.IOException
AbstractStreamDecoder.MalformedFrameException
-
readSegment
@Nonnull protected AbstractStreamDecoder.Segment readSegment(@Nonnull AbstractStreamDecoder.Memento memento) throws java.io.IOException, AbstractStreamDecoder.MalformedFrameException
- Throws:
java.io.IOException
AbstractStreamDecoder.MalformedFrameException
-
readCharset
@Nonnull protected java.nio.charset.Charset readCharset(@Nonnull AbstractStreamDecoder.Memento memento) throws java.io.IOException, AbstractStreamDecoder.MalformedFrameException
- Throws:
java.io.IOException
AbstractStreamDecoder.MalformedFrameException
-
readString
protected java.lang.String readString(@Nonnull AbstractStreamDecoder.Memento memento) throws java.io.IOException, AbstractStreamDecoder.MalformedFrameException
- Throws:
java.io.IOException
AbstractStreamDecoder.MalformedFrameException
-
readInteger
protected java.lang.Integer readInteger(@Nonnull AbstractStreamDecoder.Memento memento) throws java.io.IOException, AbstractStreamDecoder.MalformedFrameException
- Throws:
java.io.IOException
AbstractStreamDecoder.MalformedFrameException
-
readByte
protected byte readByte(@Nonnull AbstractStreamDecoder.Memento memento) throws java.io.IOException, AbstractStreamDecoder.MalformedFrameException
- Throws:
java.io.IOException
AbstractStreamDecoder.MalformedFrameException
-
readInt
protected int readInt(@Nonnull AbstractStreamDecoder.Memento memento) throws java.io.IOException, AbstractStreamDecoder.MalformedFrameException
- Throws:
java.io.IOException
AbstractStreamDecoder.MalformedFrameException
-
readLong
protected java.lang.Long readLong(@Nonnull AbstractStreamDecoder.Memento memento) throws java.io.IOException, AbstractStreamDecoder.MalformedFrameException
- Throws:
java.io.IOException
AbstractStreamDecoder.MalformedFrameException
-
readLongPrivate
protected long readLongPrivate(@Nonnull AbstractStreamDecoder.Memento memento) throws java.io.IOException, AbstractStreamDecoder.MalformedFrameException
- Throws:
java.io.IOException
AbstractStreamDecoder.MalformedFrameException
-
checkDelimiter
protected final void checkDelimiter(AbstractStreamDecoder.Memento memento) throws AbstractStreamDecoder.MalformedFrameException
-
checkHeader
protected final void checkHeader(AbstractStreamDecoder.Memento memento) throws AbstractStreamDecoder.MalformedFrameException
-
checkArguments
protected void checkArguments(AbstractStreamDecoder.Memento memento, int expectedDataElements) throws AbstractStreamDecoder.MalformedFrameException
-
printRemainingStream
protected final void printRemainingStream(AbstractStreamDecoder.Memento memento)
Print the last string which has not been finished by a new line character.- Parameters:
memento
- current memento object
-
read
@Nonnull protected AbstractStreamDecoder.StreamReadStatus read(@Nonnull AbstractStreamDecoder.Memento memento, int recommendedCount) throws java.io.IOException
- Throws:
java.io.IOException
-
-