package com.mongodb;
import com.mongodb.lang.Nullable;
import org.bson.LazyBSONDecoder;
import java.io.IOException;
import java.io.InputStream;
public class LazyDBDecoder extends LazyBSONDecoder implements DBDecoder {
@Override
public DBCallback getDBCallback(@Nullable final DBCollection collection) {
return new LazyDBCallback(collection);
}
@Override
public DBObject readObject(final InputStream in) throws IOException {
DBCallback dbCallback = getDBCallback(null);
decode(in, dbCallback);
return (DBObject) dbCallback.get();
}
@Override
public DBObject decode(final InputStream input, final DBCollection collection) throws IOException {
DBCallback callback = getDBCallback(collection);
decode(input, callback);
return (DBObject) callback.get();
}
@Override
public DBObject decode(final byte[] bytes, final DBCollection collection) {
DBCallback callback = getDBCallback(collection);
decode(bytes, callback);
return (DBObject) callback.get();
}
public static final DBDecoderFactory FACTORY = new DBDecoderFactory() {
@Override
public DBDecoder create() {
return new LazyDBDecoder();
}
};
}