blob: bf7e6823a3e2b0041bec9b05141280fe69dcde8d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.storage.searcher;
import com.yahoo.search.Result;
import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
@SuppressWarnings("deprecation")
public class ResultRenderingUtil {
public static String getRendered(Result result) throws Exception {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Charset cs = Charset.forName("utf-8");
CharsetDecoder decoder = cs.newDecoder();
com.yahoo.prelude.templates.SearchRendererAdaptor.callRender(stream, result);
stream.flush();
return decoder.decode(ByteBuffer.wrap(stream.toByteArray())).toString();
}
}
|