This class is for reading ASN.1 elements from a readable byte channel. It will handle all partial element reads from the channel and save any unread ASN.1 elements if required. All data read from the channel will be ready to be read as ASN.1 elements no matter how many times the channel is read. However, to minimize the the amount of memory used by this reader, the client should read ASN.1 elements as soon as they are read off the channel.
{@code ASN1ByteChannelReader}s are created using the factory methods in {@link ASN1}.
The client should use this class in the following manner:
When NIO signals new data is available in the channel, the client should call {@link #processChannelData()}.
If bytes are read from the channel, the client should call {@link #elementAvailable()} to see if a complete element is ready tobe read. However, if no data is actually read, the client should wait for the next signal and try again.
As long as a complete element is ready, the client should read the appropriate ASN.1 element(s). Once no more complete elements are available, the client should call {@link #processChannelData()}again to read more data (if available).
NOTE: Since this reader is non blocking, reading ASN.1 elements before making sure they are ready could result in {@link IllegalBlockingModeException}s being thrown while reading ASN.1 elements. Once an exception is thrown, the state of the reader is no longer stable and can not be used again.