decode
Decodes as many bytes as possible from the given input buffer, writing the results to the given output buffer.
The buffers are read from, and written to, starting at their current positions. At most Buffer.remaining bytes will be read and at most Buffer.remaining characters will be written. The buffers' positions will be advanced to reflect the bytes read and the characters written, but their marks and limits will not be modified.
In addition to reading bytes from the input buffer and writing characters to the output buffer, this method returns a CoderResult object to describe its reason for termination:
CoderResult.UNDERFLOW indicates that as much of the input buffer as possible has been decoded. If there is no further input then the invoker can proceed to the next step of the #steps. Otherwise this method should be invoked again with further input.
CoderResult.OVERFLOW indicates that there is insufficient space in the output buffer to decode any more bytes. This method should be invoked again with an output buffer that has more Buffer.remaining characters. This is typically done by draining any decoded characters from the output buffer.
A malformed-input result indicates that a malformed-input error has been detected. The malformed bytes begin at the input buffer's (possibly incremented) position; the number of malformed bytes may be determined by invoking the result object's method. This case applies only if the .onMalformedInput of this decoder is CodingErrorAction.REPORT; otherwise the malformed input will be ignored or replaced, as requested.
An unmappable-character result indicates that an unmappable-character error has been detected. The bytes that decode the unmappable character begin at the input buffer's (possibly incremented) position; the number of such bytes may be determined by invoking the result object's length method. This case applies only if the .onUnmappableCharacter of this decoder is ; otherwise the unmappable character will be ignored or replaced, as requested.
In any case, if this method is to be reinvoked in the same decoding operation then care should be taken to preserve any bytes remaining in the input buffer so that they are available to the next invocation.
The endOfInput parameter advises this method as to whether the invoker can provide further input beyond that contained in the given input buffer. If there is a possibility of providing additional input then the invoker should pass false for this parameter; if there is no possibility of providing further input then the invoker should pass true. It is not erroneous, and in fact it is quite common, to pass false in one invocation and later discover that no further input was actually available. It is critical, however, that the final invocation of this method in a sequence of invocations always pass true so that any remaining undecoded input will be treated as being malformed.
This method works by invoking the .decodeLoop method, interpreting its results, handling error conditions, and reinvoking it as necessary.
Return
A coder-result object describing the reason for termination
Parameters
The input byte buffer
The output character buffer
true if, and only if, the invoker can provide no additional input bytes beyond those in the given buffer
Throws
If a decoding operation is already in progress and the previous step was an invocation neither of the .reset method, nor of this method with a value of false for the endOfInput parameter, nor of this method with a value of true for the endOfInput parameter but a return value indicating an incomplete decoding operation
If an invocation of the decodeLoop method threw an unexpected exception
Convenience method that decodes the remaining content of a single input byte buffer into a newly-allocated character buffer.
This method implements an entire #steps; that is, it resets this decoder, then it decodes the bytes in the given byte buffer, and finally it flushes this decoder. This method should therefore not be invoked if a decoding operation is already in progress.
Return
A newly-allocated character buffer containing the result of the decoding operation. The buffer's position will be zero and its limit will follow the last character written.
Parameters
The input byte buffer
Throws
If a decoding operation is already in progress
If the byte sequence starting at the input buffer's current position is not legal for this charset and the current malformed-input action is CodingErrorAction.REPORT
MalformedInputException if the byte sequence starting at the input buffer's current position is not legal for this charset and the current malformed-input action is CodingErrorAction.REPORT; UnmappableCharacterException if the byte sequence starting at the input buffer's current position cannot be mapped to an equivalent character sequence and the current unmappable-character action is CodingErrorAction.REPORT
If the output character buffer for the requested size of the input byte buffer cannot be allocated