com.adgear.anoa.read.ByteBufferReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of anoa-core Show documentation
Show all versions of anoa-core Show documentation
Core classes for Anoa library, which aims to be a safe, convenient and fast record
de/serialization wrapper for the Avro, Thrift and Jackson libraries, using the functional idioms
of Java 8.
The anoa-core module tries to keep upstream dependencies to a minimum.
package com.adgear.anoa.read;
import com.adgear.anoa.AnoaJacksonTypeException;
import com.fasterxml.jackson.core.JsonParser;
import java.io.IOException;
import java.nio.ByteBuffer;
class ByteBufferReader extends AbstractReader {
static private ByteArrayReader byteArrayReader = new ByteArrayReader();
@Override
protected ByteBuffer read(JsonParser jacksonParser) throws IOException {
final byte[] array = byteArrayReader.read(jacksonParser);
return (array == null) ? null : ByteBuffer.wrap(array);
}
@Override
protected ByteBuffer readStrict(JsonParser jacksonParser) throws AnoaJacksonTypeException, IOException {
final byte[] array = byteArrayReader.readStrict(jacksonParser);
return (array == null) ? null : ByteBuffer.wrap(array);
}
}