@Override
    public IReadWriteStream<ApiResponse> getResponseDataHandler(final ApiResponse response,
            IPolicyContext context, Object policyConfiguration) {
        final DataFormat clientFormat = (DataFormat) context.getAttribute(CLIENT_FORMAT, null);
        final DataFormat serverFormat = (DataFormat) context.getAttribute(SERVER_FORMAT, null);

        if (isValidTransformation(clientFormat, serverFormat)) {
            final IBufferFactoryComponent bufferFactory = context.getComponent(IBufferFactoryComponent.class);
            final int contentLength = response.getHeaders().containsKey(CONTENT_LENGTH)
                    ? Integer.parseInt(response.getHeaders().get(CONTENT_LENGTH))
                    : 0;

            return new AbstractStream<ApiResponse>() {

                private IApimanBuffer readBuffer = bufferFactory.createBuffer(contentLength);

                @Override
                public ApiResponse getHead() {
                    return response;
                }

                @Override
                protected void handleHead(ApiResponse head) {
                }

                @Override
                public void write(IApimanBuffer chunk) {
                    byte[] bytes = chunk.getBytes();
                    readBuffer.append(bytes);
                }

                @Override
                public void end() {
                    if (readBuffer.length() > 0) {
                        DataTransformer dataTransformer = DataTransformerFactory.getDataTransformer(serverFormat, clientFormat);
                        IApimanBuffer writeBuffer = bufferFactory.createBuffer(readBuffer.length());

                        String data = dataTransformer.transform(new String(readBuffer.getBytes()));
                        writeBuffer.append(data);

                        super.write(writeBuffer);
                    }
                    super.end();
                }
            };
        }

        return null;
    }
@see io.apiman.gateway.engine.policy.IDataPolicy#getResponseDataHandler(io.apiman.gateway.engine.beans.ApiResponse, io.apiman.gateway.engine.policy.IPolicyContext, java.lang.Object)
plugins/transformation-policy/src/main/java/io/apiman/plugins/transformation_policy/TransformationPolicy.java