/** * Writes the supplied string to the wrapped stream with the specified indent * level. * * @param tag * The string to be written. * @param nestinglevel * The multiplier for the <code>INDENT_WIDTH</code>, giving the * number of spaces to be written before the supplied string. */ public void writeRaw(String tag, int nestinglevel) { indent(nestinglevel, internalwriter); internalwriter.print(tag); // Logger.println(tag, Logger.DEBUG_SUBATOMIC); }
/** * 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 void dumpHiddenField(UIParameter todump, XMLWriter xmlw) { xmlw.writeRaw("<input type=\"hidden\" "); boolean isvirtual = todump instanceof UIBinding && ((UIBinding)todump).virtual; XMLUtil.dumpAttribute(isvirtual? "id" : "name", todump.name, xmlw); XMLUtil.dumpAttribute("value", todump.value, xmlw); xmlw.writeRaw(" />\n"); }
this.xmlw = new XMLWriter(os); if (indentlevel == 0) { xmlw.writeDeclaration(); break; // GLOBAL EXIT POINT top = getDeSAXingObject(); xmlw.closeTag(top.stashedclosingtag, getIndent(), writtenchild); continue; xmlw.closeTag(roottagname, indentlevel, top.writtenchild); xmlw.close();
/** * 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); }
public void render(PrintOutputStream pos) { IDassigner = new IDAssigner(debugrender ? ContentTypeInfo.ID_FORCE : contenttypeinfo.IDStrategy); // Add and remove the flyweight immediately around "resolveBranches" - instances of it // will be dynamically "invented" around the tree wherever there are messages messageFlyweight = new MessageFlyweight(view.viewroot); branchmap = BranchResolver.resolveBranches(globalmap, view.viewroot, roott.rootlump, idrewritemap); view.viewroot.remove(messageFlyweight.rsfMessages); messagelump = (XMLLump) branchmap.get(messageFlyweight.rsfMessages); collectContributions(); messagetargets = MessageTargetter.targetMessages(branchmap, view, messagelist, globalmessagetarget); String declaration = contenttypeinfo.get().declaration; if (declaration != null) pos.print(declaration); this.pos = pos; this.xmlw = new XMLWriter(pos); rsc = new RenderSystemContext(debugrender, view, pos, xmlw, IDassigner, collected, idrewritemap); rendereddeadletters = false; if (debugrender) { debugGlobalTargets(); } renderRecurse(view.viewroot, roott.rootlump, roott.lumps[roott.roottagindex]); }
/** * Closes this XMLWriter object, in effect flushing it and making it unusable * for any further write operations. * <p> * Closing this does not close the underlying input stream! */ public void close() { if (internalwriter != null) { try { flush(); } catch (Throwable t) { Logger.println("Unhandled exception closing XML Writer: " + t, Logger.DEBUG_SEVERE); // internalwriter.close(); internalwriter = null; } } } }
public int render(TagRenderContext trc) { if (headmatter == null) { return NullRewriteSCR.instance.render(trc); } else { if (RenderUtil.isFirstSCR(trc.uselump, getName())) { trc.xmlw.writeRaw(headmatter); } return ComponentRenderer.LEAF_TAG; } }
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/>"); }
public int render(TagRenderContext trc) { if (headmatter == null) { return NullRewriteSCR.instance.render(trc); } else { if (RenderUtil.isFirstSCR(trc.uselump, getName())) { trc.xmlw.writeRaw(headmatter); } return ComponentRenderer.LEAF_TAG; } }
public void replaceBody(String value) { XMLUtil.dumpAttributes(attrcopy, xmlw); if (!iselide) { pos.print(">"); } xmlw.write(value); closeTag(); }
public void closeTag(String tag, int nestinglevel, boolean writtenchildren) { if (writtenchildren) { indent(nestinglevel, internalwriter); internalwriter.print("</"); internalwriter.print(tag); internalwriter.print(">"); } else { internalwriter.print("/>"); } if (nestinglevel >= 0) { internalwriter.print("\n"); } }
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 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; }
SerialContext oldtop = getDeSAXingObject(); if (oldtop != null && !oldtop.writtenchild) { xmlw.writeRaw(">"); if (indentlevel != COMPACT_MODE) { xmlw.writeRaw("\n"); xmlw.writeRaw("<" + childtagname, getIndent()); String genericdata = null; if (child instanceof GenericSAX) { xmlw.writeRaw(">", 0); xmlw.write(mappingcontext.generalLeafParser.render(child)); xmlw.writeRaw("</" + childtagname + ">\n", 0); top = null;