com.fasterxml.clustermate.client.call.GetContentProcessorForBytes Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clustermate-client Show documentation
Show all versions of clustermate-client Show documentation
Building blocks for client libraries that access
ClusterMate-based service.
package com.fasterxml.clustermate.client.call;
import java.io.IOException;
import com.fasterxml.storemate.shared.util.ByteAggregator;
/**
* Simple {@link GetContentProcessor} implementation for GETting content
* and aggregating it in (and returning as) {@link ByteAggregator}.
*/
public class GetContentProcessorForBytes extends GetContentProcessor
{
@Override public GetContentProcessorForBytes.Handler createHandler() {
return new Handler();
}
/**
* Simple {@link PutContentProvider} implementation that is backed by
* specific File. More advanced implementations would probably try creating
* new temporary files instead.
*/
public static class Handler extends GetContentProcessor.Handler
{
protected ByteAggregator _bytes;
public Handler() { }
@Override
public void processContent(byte[] content, int offset, int length)
throws IOException
{
_bytes = ByteAggregator.with(_bytes, content, offset, length);
}
@Override
public ByteAggregator completeContentProcessing() throws IOException
{
if (_bytes == null) {
_bytes = new ByteAggregator();
}
return _bytes;
}
@Override
public void contentProcessingFailed(Throwable cause) { }
}
}