blob: 7f392b0565b066f9b3e08a5737c9ace5646600ac (
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 2017 Yahoo Holdings. 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();
}
}
|