public static void dumpAttribute(String name, String value, XMLWriter xmlw) { xmlw.writeRaw(" ").writeRaw(name).writeRaw("=\""); xmlw.write(value); xmlw.writeRaw("\""); }
/** * Writes the supplied data to the wrapped stream, escaping all mandatory * XML/HTML entities, being &, <, >, " and '. ' is * escaped to &#39; since HTML 4.0 does not define the &apos; entity * and does not plan to. * * @param towrite * The string to be written. */ public void write(String towrite) { char[] array = (towrite == null ? "null" : towrite).toCharArray(); write(array, 0, array.length); }
private void appendAttr(String attrname, Object attrvalue) { xmlw.writeRaw(" "); xmlw.writeRaw(attrname); // attribute names may not contain escapes xmlw.writeRaw("=\""); xmlw.write(mappingcontext.generalLeafParser.render(attrvalue)); xmlw.writeRaw("\""); }
public static void writeEncodeLinks(XMLWriter xmlw, String line) { int linkpos = line.indexOf("://"); if (linkpos == -1) { xmlw.write(line); return; } int backpos = linkpos - 1; for (; backpos >= 0; --backpos) { if (Character.isWhitespace(line.charAt(backpos))) break; } ++ backpos; if (backpos == linkpos - 1) { // require non-empty protocol xmlw.write(line); return; } int frontpos = linkpos + 3; for (; frontpos < line.length(); ++ frontpos) { if (Character.isWhitespace(line.charAt(backpos))) break; } String url = line.substring(backpos, frontpos); xmlw.write(line.substring(0, backpos)); xmlw.writeRaw("<a target=\"_top\" href=\""); xmlw.write(url); xmlw.writeRaw("\">"); xmlw.write(url); xmlw.writeRaw("</a>"); xmlw.write(line.substring(frontpos)); }
public void renderDebugMessage(RenderSystemContext rsc, String string) { rsc.pos.print("<span style=\"background-color:#FF466B;color:white;padding:1px;\">"); rsc.xmlw.write(string); rsc.pos.print("</span><br/>"); }
/** * Copies text from input to output, converting newlines into XHTML * <br/> elements. The supplied streams WILL be closed! */ public void copyReader(Reader r, PrintOutputStream pos) { BufferedReader br = new BufferedReader(r); XMLWriter xmlw = new XMLWriter(pos); try { while (true) { String line = br.readLine(); if (line == null) break; xmlw.write(line); // TODO: make some kind of "XMLFilterWriter" architecture if necessary // writeEncodeLinks(xmlw, line); xmlw.writeRaw("<br/>"); } } catch (Throwable t) { throw UniversalRuntimeException.accumulate(t, "Error rendering text as HTML"); } finally { StreamCloseUtil.closeReader(r); pos.close(); } }
public static String handleFatalErrorStatic(Throwable t, PrintOutputStream pos) { // We may have such a fatal misconfiguration that we can't even rely on // IKAT to format this error message Logger.log.fatal("Completely fatal error populating view root", t); pos.println("<html><head><title>Internal Error</title></head></body><pre>"); pos.println(ERROR_STRING); StringWriter todump = new StringWriter(); t.printStackTrace(new PrintWriter(todump)); XMLWriter xml = new XMLWriter(pos); xml.write(todump.toString()); pos.println("</pre></body></html>"); pos.close(); return HANDLED; }
xmlw.write(mappingcontext.generalLeafParser.render(child));
public void replaceBody(String value) { XMLUtil.dumpAttributes(attrcopy, xmlw); if (!iselide) { pos.print(">"); } xmlw.write(value); closeTag(); }
/** A slow method for XML-encoding text * * @param toencode text to encode * @return encoded text */ public static String encode(String toencode) { StringPOS pos = new StringPOS(); XMLWriter xmlw = new XMLWriter(pos); xmlw.write(toencode); return pos.toString(); }