blob: c49f8a04b9742c16c79f674a161d2d1745cd3af2 (
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.result;
import com.yahoo.data.access.Inspector;
import com.yahoo.data.access.Inspectable;
import com.yahoo.data.access.simple.JsonRender;
import com.yahoo.data.JsonProducer;
import com.yahoo.data.XmlProducer;
import com.yahoo.prelude.hitfield.XmlRenderer;
/**
* A wrapper for structured data representing feature values.
*/
public class StructuredData implements Inspectable, JsonProducer, XmlProducer {
private final Inspector value;
public StructuredData(Inspector value) {
this.value = value;
}
@Override
public Inspector inspect() {
return value;
}
public String toString() {
return toXML();
}
@Override
public String toXML() {
return writeXML(new StringBuilder()).toString();
}
@Override
public StringBuilder writeXML(StringBuilder target) {
return XmlRenderer.render(target, value);
}
@Override
public String toJson() {
return writeJson(new StringBuilder()).toString();
}
@Override
public StringBuilder writeJson(StringBuilder target) {
return JsonRender.render(value, target, true);
}
}
|