use of com.yahoo.io.ByteWriter in project vespa by vespa-engine.
the class DefaultRenderer method renderFieldContentPossiblyNotDecoded.
private void renderFieldContentPossiblyNotDecoded(XMLWriter writer, Hit hit, boolean probablyNotDecoded, String fieldName) throws IOException {
boolean dumpedRaw = false;
if (probablyNotDecoded && (hit instanceof FastHit)) {
writer.closeStartTag();
if ((writer.getWriter() instanceof ByteWriter) && utf8Output) {
dumpedRaw = UserTemplate.dumpBytes((ByteWriter) writer.getWriter(), (FastHit) hit, fieldName);
}
if (dumpedRaw) {
// let the xml writer note that this tag had content
writer.content("", false);
}
}
if (!dumpedRaw) {
String xmlval = hit.getFieldXML(fieldName);
if (xmlval == null) {
xmlval = "(null)";
}
writer.escapedContent(xmlval, false);
}
}
use of com.yahoo.io.ByteWriter in project vespa by vespa-engine.
the class TemplateTestCase method testASCIIQuoting.
public void testASCIIQuoting() throws java.io.IOException {
stream.reset();
byte[] c = new byte[] { 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 };
ByteWriter bw = new ByteWriter(stream, encoder);
UserTemplate.dumpAndXMLQuoteUTF8(bw, c);
bw.close();
String res = stream.toString("UTF-8");
String correct = "abc\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\u0008\t\n\\u000B\\u000C\r\\u000E\\u000F\\u0010\\u0011";
assertEquals(correct, res);
}
use of com.yahoo.io.ByteWriter in project vespa by vespa-engine.
the class TemplateTestCase method testXMLQuoting.
public void testXMLQuoting() throws java.io.IOException {
stream.reset();
// c = <s>>
byte[] c = new byte[] { 60, 115, 62, 38, 103, 116, 59 };
ByteWriter bw = new ByteWriter(stream, encoder);
UserTemplate.dumpAndXMLQuoteUTF8(bw, c);
bw.close();
String res = stream.toString("UTF-8");
String correct = "<s>&gt;";
assertEquals(correct, res);
}
Aggregations