@Override
protected boolean readValue(ByteBuffer buffer, int bodyLength,
int keyLength, int extrasLength) {
if (this.responseStatus == ResponseStatus.NO_ERROR) {
int valueLength = bodyLength - keyLength - extrasLength;
CachedData responseValue = ((Map<String, CachedData>) this.result)
.get(this.responseKey);
if (valueLength >= 0 && responseValue.getCapacity() < 0) {
responseValue.setCapacity(valueLength);
responseValue.setData(new byte[valueLength]);
}
int remainingCapacity = responseValue.remainingCapacity();
int remaining = buffer.remaining();
if (remaining < remainingCapacity) {
int length = remaining > remainingCapacity ? remainingCapacity
: remaining;
responseValue.fillData(buffer, length);
return false;
} else if (remainingCapacity > 0) {
responseValue.fillData(buffer, remainingCapacity);
}
return true;
} else {
((Map<String, CachedData>) this.result).remove(this.responseKey);
return true;