/** * Prints XML-escaped text. * * @param str * @throws PaintException * if the paint operation failed. * */ @Override public void addText(String str) throws PaintException { tag.addData("\"" + escapeJSON(str) + "\""); }
@Override public String getJsonPresentation() { StringBuilder sb = new StringBuilder(); sb.append("\""); sb.append(name); sb.append("\":["); for (int i = 0; i < value.length;) { sb.append("\""); sb.append(escapeJSON(value[i])); sb.append("\""); i++; if (i < value.length) { sb.append(','); } } sb.append(']'); return sb.toString(); } }
@Override public void addAttribute(String name, String value) throws PaintException { // In case of null data output nothing: if ((value == null) || (name == null)) { throw new NullPointerException( "Parameters must be non-null strings"); } tag.addAttribute("\"" + name + "\":\"" + escapeJSON(value) + "\""); if (customLayoutArgumentsOpen && "template".equals(name)) { getUsedResources().add("layouts/" + value + ".html"); } }
/** * Prints the single text section. * * Prints full text section. The section data is escaped * * @param sectionTagName * the name of the tag. * @param sectionData * the section data to be printed. * @throws PaintException * if the paint operation failed. */ @Override public void addSection(String sectionTagName, String sectionData) throws PaintException { tag.addData("{\"" + sectionTagName + "\":\"" + escapeJSON(sectionData) + "\"}"); }
@Override public void addAttribute(String name, Object[] values) { // In case of null data output nothing: if ((values == null) || (name == null)) { throw new NullPointerException( "Parameters must be non-null strings"); } final StringBuilder buf = new StringBuilder(); buf.append("\"").append(name).append("\":["); for (int i = 0; i < values.length; i++) { if (i > 0) { buf.append(','); } buf.append("\""); buf.append(escapeJSON(values[i].toString())); buf.append("\""); } buf.append(']'); tag.addAttribute(buf.toString()); }
@Override public void addVariable(VariableOwner owner, String name, String value) throws PaintException { tag.addVariable(new StringVariable(owner, name, escapeJSON(value))); }
sb.append(((ClientConnector) key).getConnectorId()); } else { sb.append(escapeJSON(key.toString())); } else { sb.append("\""); sb.append(escapeJSON(mapValue.toString())); sb.append("\"");
/** * Adds XML directly to UIDL. * * @param xml * the Xml to be added. * @throws PaintException * if the paint operation failed. */ @Override public void addUIDL(String xml) throws PaintException { // Ensure that the target is open if (closed) { throw new PaintException( "Attempted to write to a closed PaintTarget."); } // Make sure that the open start tag is closed before // anything is written. // Escape and write what was given if (xml != null) { tag.addData("\"" + escapeJSON(xml) + "\""); } }
+ JsonPaintTarget.escapeJSON(layout.toString()) + "\""); } else {
tag.addData("\"" + escapeJSON(sectionData) + "\"");