public abstract class Decoder extends Object implements Closeable, AsyncCloseable<IOException>
| Modifier and Type | Field and Description |
|---|---|
protected ByteBuffer |
currentBuffer |
protected IO.Readable.Buffered |
io |
protected AsyncSupplier<ByteBuffer,IOException> |
nextBuffer |
| Constructor and Description |
|---|
Decoder() |
| Modifier and Type | Method and Description |
|---|---|
IAsync<IOException> |
canDecode()
When the decode method returns -2, this method can be used to know when new data is available to be decoded.
|
void |
close() |
IAsync<IOException> |
closeAsync()
Close asynchronously.
|
int |
decode(ByteBuffer b,
char[] chars,
int pos,
int len)
Decode characters without IO.
|
protected abstract int |
decode(ByteBuffer b,
char[] chars,
int pos,
int len,
MutableBoolean interrupt,
int min) |
int |
decode(char[] chars,
int pos,
int len,
MutableBoolean interrupt,
int min)
Decode characters from the IO.
|
static Decoder |
get(Charset charset)
Get a decoder for the given charset.
|
abstract Charset |
getEncoding()
Return the charset of this decoder.
|
static void |
register(Charset charset,
Class<? extends Decoder> decoder)
Register a decoder implementation.
|
void |
setFirstBytes(byte[] bytes)
Set first bytes to decode before the IO.
|
void |
setFirstBytes(ByteBuffer bytes)
Set first bytes to decode before the IO.
|
void |
setInput(IO.Readable.Buffered io)
Set readable IO to decode.
|
void |
transferTo(Decoder newDecoder)
Change charset by transfering the current state of this decoder to the new one.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcloseAfterprotected IO.Readable.Buffered io
protected AsyncSupplier<ByteBuffer,IOException> nextBuffer
protected ByteBuffer currentBuffer
public static Decoder get(Charset charset) throws InstantiationException, IllegalAccessException
public static void register(Charset charset, Class<? extends Decoder> decoder)
public void setFirstBytes(byte[] bytes)
public void setFirstBytes(ByteBuffer bytes)
public void setInput(IO.Readable.Buffered io)
public void transferTo(Decoder newDecoder)
public IAsync<IOException> canDecode()
public int decode(char[] chars,
int pos,
int len,
MutableBoolean interrupt,
int min)
throws IOException,
CancelException
chars - array to fillpos - offset in the array to filllen - maximum number of characters to fillinterrupt - when true, the decoding will stop as soon as possiblemin - minimum number of characters to fill, regardless of the interrupt valueIOException - error reading from IOCancelException - IO has been cancelledpublic int decode(ByteBuffer b, char[] chars, int pos, int len)
protected abstract int decode(ByteBuffer b, char[] chars, int pos, int len, MutableBoolean interrupt, int min)
public abstract Charset getEncoding()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic IAsync<IOException> closeAsync()
AsyncCloseablecloseAsync in interface AsyncCloseable<IOException>Copyright © 2019. All rights reserved.