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 classThis class avoids locking which gains the performance of this decoder.static final classfinal classstatic final classstatic enumUnderflow - could not completely read out al bytes in one call. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ForkNodeArgumentsstatic final intprivate static final intprivate final ReadableByteChannelprivate static final byte[]private static final intprivate static final intprivate static final String[]private final ConsoleLoggerprivate static final intprivate final Map<AbstractStreamDecoder.Segment, MT> private static final intprivate static final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractStreamDecoder(ReadableByteChannel channel, ForkNodeArguments arguments, Map<AbstractStreamDecoder.Segment, MT> messageTypes) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckArguments(AbstractStreamDecoder<M, MT, ST>.Memento memento, int expectedDataElements) protected final voidcheckDelimiter(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected final voidcheckHeader(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected voiddebugStream(byte[] array, int position, int remaining) abstract Mprivate static intdecodeString(CharsetDecoder decoder, ByteBuffer input, CharBuffer output, int bytesToDecode, boolean endOfInput, int errorStreamFrom) protected final ForkNodeArgumentsprotected abstract byte[]protected abstract ST[]nextSegmentType(MT messageType) private voidprintCorruptedStream(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected final voidprintRemainingStream(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.StreamReadStatusprotected byteprotected CharsetreadCharset(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected intprotected IntegerreadInteger(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected Longprotected longreadLongPrivate(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected MTreadMessageType(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected AbstractStreamDecoder.SegmentreadSegment(AbstractStreamDecoder<M, MT, ST>.Memento memento) protected StringreadString(AbstractStreamDecoder<M, MT, ST>.Memento memento) private StringreadString(AbstractStreamDecoder<M, MT, ST>.Memento memento, int totalBytes) protected abstract Mprivate static StringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
MalformedChannelExceptionIOException
-
getEncodedMagicNumber
-
nextSegmentType
-
toMessage
-
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
-