IN
- The type of Buffer
being read from.OUT
- The type of Buffer
being written to.public interface ICoder<IN extends Buffer,OUT extends Buffer> extends Cloneable, Serializable
Base API for high-performance encoding and decoding between various Buffer
s.
Supports conversions between ByteBuffer
s and
CharBuffer
s through the IByteToCharEncoder
and
ICharToByteDecoder
child interfaces, e.g. URL/Percent and Base64 codecs.
This API is similar in design to CharsetEncoder
and
CharsetDecoder
.
Modifier and Type | Method and Description |
---|---|
ICoder<IN,OUT> |
clone()
Another means for obtaining a configured instance copy from another.
|
OUT |
code(IN in)
|
CoderResult |
code(IN in,
OUT out,
boolean endOfInput)
Encodes as many units as possible from the given input buffer,
writing the results to the given output buffer.
|
ICoder<IN,OUT> |
config(ICoder<IN,OUT> base)
Configures this instances based upon another.
|
CoderResult |
flush(OUT out)
Writes any final output after the entire input has been processed.
|
float |
getAverageOutPerIn()
Heuristic value of the average number of output units generated per input unit.
|
float |
getMaxOutPerIn()
Heuristic value of the maximum number of output units generated per input unit.
|
float |
getMinInPerOut()
Heuristic value of the minimum number of input units required to produce
one or more output units.
|
ICoder<IN,OUT> |
reset()
Resets the coder, allowing it to be reused against new input and output,
while keeping the same configuration.
|
ICoder<IN,OUT> config(ICoder<IN,OUT> base)
Configures this instances based upon another.
The passed-in parameter must be an instance of the current implementation,
or an IllegalArgumentException
will be thrown.
base
- The instance to copy the configuration from.IllegalArgumentException
- If the passed-in parameter is not a
class-compatible instance of the current implementation.ICoder<IN,OUT> clone() throws CloneNotSupportedException
Another means for obtaining a configured instance copy from another.
Typically utilizes config(ICoder)
.
CloneNotSupportedException
float getMinInPerOut()
Heuristic value of the minimum number of input units required to produce one or more output units.
Similar to getAverageOutPerIn()
and getMaxOutPerIn()
.
float getAverageOutPerIn()
Heuristic value of the average number of output units generated per input unit.
Similar to CharsetEncoder.averageBytesPerChar()
and CharsetDecoder.averageCharsPerByte()
.
float getMaxOutPerIn()
Heuristic value of the maximum number of output units generated per input unit.
Similar to CharsetEncoder.maxBytesPerChar()
and CharsetDecoder.maxCharsPerByte()
.
ICoder<IN,OUT> reset()
Resets the coder, allowing it to be reused against new input and output, while keeping the same configuration.
OUT code(IN in) throws CharacterCodingException
Convenience method that encodes the passed-in input Buffer
to a
returned output Buffer
.
Functions similar to
CharsetEncoder.encode(java.nio.CharBuffer)
and
CharsetDecoder.decode(java.nio.ByteBuffer)
.
in
- The input Buffer
to read from.Buffer
written to.CharacterCodingException
CoderResult code(IN in, OUT out, boolean endOfInput)
Encodes as many units as possible from the given input buffer, writing the results to the given output buffer.
Functions similar to
CharsetEncoder.encode(java.nio.CharBuffer, java.nio.ByteBuffer, boolean)
and
CharsetDecoder.decode(java.nio.ByteBuffer, java.nio.CharBuffer, boolean)
.
CoderResult flush(OUT out)
Writes any final output after the entire input has been processed.
Should be called after code(Buffer, Buffer, boolean)
is
called for the final time.
Functions similar to
CharsetEncoder.flush(java.nio.ByteBuffer)
and
CharsetDecoder.flush(java.nio.CharBuffer)
.
out
- The output Buffer
to write to.Copyright © 2009–2017 Mark A. Ziesemer. All rights reserved.