下面列出了怎么用com.fasterxml.jackson.core.async.ByteArrayFeeder的API类实例代码及写法,或者点击链接到github查看源代码。
private static <T> StreamingDeserializer<T> newDeserializer(ObjectReader reader) {
final JsonFactory factory = reader.getFactory();
final JsonParser parser;
try {
// TODO(scott): ByteBufferFeeder is currently not supported by jackson, and the current API throws
// UnsupportedOperationException if not supported. When jackson does support two NonBlockingInputFeeder
// types we need an approach which doesn't involve catching UnsupportedOperationException to try to get
// ByteBufferFeeder and then ByteArrayFeeder.
parser = factory.createNonBlockingByteArrayParser();
} catch (IOException e) {
throw new IllegalArgumentException("parser initialization error for factory: " + factory, e);
}
NonBlockingInputFeeder rawFeeder = parser.getNonBlockingInputFeeder();
if (rawFeeder instanceof ByteBufferFeeder) {
return new ByteBufferJacksonDeserializer<>(reader, parser, (ByteBufferFeeder) rawFeeder);
}
if (rawFeeder instanceof ByteArrayFeeder) {
return new ByteArrayJacksonDeserializer<>(reader, parser, (ByteArrayFeeder) rawFeeder);
}
throw new IllegalArgumentException("unsupported feeder type: " + rawFeeder);
}
private Jackson2Tokenizer(
JsonParser parser, DeserializationContext deserializationContext, boolean tokenizeArrayElements) {
this.parser = parser;
this.deserializationContext = deserializationContext;
this.tokenizeArrayElements = tokenizeArrayElements;
this.tokenBuffer = new TokenBuffer(parser, deserializationContext);
this.inputFeeder = (ByteArrayFeeder) this.parser.getNonBlockingInputFeeder();
}
private Jackson2Tokenizer(JsonParser parser, boolean tokenizeArrayElements) {
Assert.notNull(parser, "'parser' must not be null");
this.parser = parser;
this.tokenizeArrayElements = tokenizeArrayElements;
this.tokenBuffer = new TokenBuffer(parser);
this.inputFeeder = (ByteArrayFeeder) this.parser.getNonBlockingInputFeeder();
}
ByteArrayJacksonDeserializer(ObjectReader reader, JsonParser parser, ByteArrayFeeder feeder) {
super(reader, parser);
this.feeder = feeder;
}
@Override
public ByteArrayFeeder getNonBlockingInputFeeder() {
return this;
}