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:
AutoCloseable
- Direct Known Subclasses:
CommandDecoder
,EventDecoder
public abstract class AbstractStreamDecoder<M,MT extends Enum<MT>,ST extends Enum<ST>>
extends Object
implements AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal class
This class avoids locking which gains the performance of this decoder.static final class
final class
static final class
static enum
Underflow - could not completely read out al bytes in one call. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ForkNodeArguments
static final int
private static final int
private final ReadableByteChannel
private static final byte[]
private static final int
private static final int
private static final String[]
private final ConsoleLogger
private static final int
private final Map<AbstractStreamDecoder.Segment,
MT> private static final int
private static final String
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractStreamDecoder
(ReadableByteChannel channel, ForkNodeArguments arguments, Map<AbstractStreamDecoder.Segment, MT> messageTypes) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
checkArguments
(AbstractStreamDecoder<M, MT, ST>.Memento memento, int expectedDataElements) protected final void
checkDelimiter
(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected final void
checkHeader
(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected void
debugStream
(byte[] array, int position, int remaining) abstract M
private static int
decodeString
(CharsetDecoder decoder, ByteBuffer input, CharBuffer output, int bytesToDecode, boolean endOfInput, int errorStreamFrom) protected final ForkNodeArguments
protected abstract byte[]
protected abstract ST[]
nextSegmentType
(MT messageType) private void
printCorruptedStream
(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected final void
printRemainingStream
(AbstractStreamDecoder<M, MT, ST>.Memento memento) Print the last string which has not been finished by a new line character.read
(ByteBuffer buffer, int oldPosition, int recommendedCount) protected AbstractStreamDecoder.StreamReadStatus
protected byte
protected Charset
readCharset
(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected int
protected Integer
readInteger
(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected Long
protected long
readLongPrivate
(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected MT
readMessageType
(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected AbstractStreamDecoder.Segment
readSegment
(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected String
readString
(AbstractStreamDecoder<M, MT, ST>.Memento memento) private String
readString
(AbstractStreamDecoder<M, MT, ST>.Memento memento, int totalBytes) protected abstract M
private static String
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.AutoCloseable
close
-
Field Details
-
BUFFER_SIZE
public static final int BUFFER_SIZE- See Also:
-
PRINTABLE_JVM_NATIVE_STREAM
- See Also:
-
JVM_ERROR_PATTERNS
-
DEFAULT_STREAM_ENCODING_BYTES
private static final byte[] DEFAULT_STREAM_ENCODING_BYTES -
NO_POSITION
private static final int NO_POSITION- See Also:
-
DELIMITER_LENGTH
private static final int DELIMITER_LENGTH- See Also:
-
BYTE_LENGTH
private static final int BYTE_LENGTH- See Also:
-
INT_LENGTH
private static final int INT_LENGTH- See Also:
-
LONG_LENGTH
private static final int LONG_LENGTH- See Also:
-
channel
-
arguments
-
messageTypes
-
logger
-
-
Constructor Details
-
AbstractStreamDecoder
protected AbstractStreamDecoder(@Nonnull ReadableByteChannel channel, @Nonnull ForkNodeArguments arguments, @Nonnull Map<AbstractStreamDecoder.Segment, MT> messageTypes)
-
-
Method Details
-
decode
public abstract M decode(@Nonnull AbstractStreamDecoder<M, MT, throws MalformedChannelException, IOExceptionST>.Memento memento) - Throws:
MalformedChannelException
IOException
-
getEncodedMagicNumber
@Nonnull protected abstract byte[] getEncodedMagicNumber() -
nextSegmentType
-
toMessage
@Nonnull protected abstract M toMessage(@Nonnull MT messageType, @Nonnull AbstractStreamDecoder<M, MT, throws AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento) -
getArguments
-
debugStream
protected void debugStream(byte[] array, int position, int remaining) -
readMessageType
protected MT readMessageType(@Nonnull AbstractStreamDecoder<M, MT, throws IOException, AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento) -
readSegment
@Nonnull protected AbstractStreamDecoder.Segment readSegment(@Nonnull AbstractStreamDecoder<M, MT, throws IOException, AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento) -
readCharset
@Nonnull protected Charset readCharset(@Nonnull AbstractStreamDecoder<M, MT, throws IOException, AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento) -
readString
protected String readString(@Nonnull AbstractStreamDecoder<M, MT, throws IOException, AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento) -
readInteger
protected Integer readInteger(@Nonnull AbstractStreamDecoder<M, MT, throws IOException, AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento) -
readByte
protected byte readByte(@Nonnull AbstractStreamDecoder<M, MT, throws IOException, AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento) -
readInt
protected int readInt(@Nonnull AbstractStreamDecoder<M, MT, throws IOException, AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento) -
readLong
protected Long readLong(@Nonnull AbstractStreamDecoder<M, MT, throws IOException, AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento) -
readLongPrivate
protected long readLongPrivate(@Nonnull AbstractStreamDecoder<M, MT, throws IOException, AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento) -
checkDelimiter
protected final void checkDelimiter(AbstractStreamDecoder<M, MT, throws AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento) -
checkHeader
protected final void checkHeader(AbstractStreamDecoder<M, MT, throws AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento) -
checkArguments
protected void checkArguments(AbstractStreamDecoder<M, MT, throws AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento, int expectedDataElements) -
readString
private String readString(@Nonnull AbstractStreamDecoder<M, MT, throws IOException, AbstractStreamDecoder.MalformedFrameExceptionST>.Memento memento, @Nonnegative int totalBytes) -
decodeString
private static int decodeString(@Nonnull CharsetDecoder decoder, @Nonnull ByteBuffer input, @Nonnull CharBuffer output, @Nonnegative int bytesToDecode, boolean endOfInput, @Nonnegative int errorStreamFrom) throws AbstractStreamDecoder.MalformedFrameException -
toString
-
printCorruptedStream
-
printRemainingStream
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<M, MT, throws IOExceptionST>.Memento memento, int recommendedCount) - Throws:
IOException
-
read
private AbstractStreamDecoder.StreamReadStatus read(ByteBuffer buffer, int oldPosition, int recommendedCount) throws IOException - Throws:
IOException
-