/** * Evaluate a Jelly script and return output as a String. * * @since 1.267 */ public static String runScript(Script script) throws JellyTagException { StringWriter out = new StringWriter(); script.run(getCurrentJellyContext(), XMLOutput.createXMLOutput(out)); return out.toString(); }
/** * Creates a text based XMLOutput which converts all XML events into * text and writes to the underlying OutputStream. */ public static XMLOutput createXMLOutput(OutputStream out) throws UnsupportedEncodingException { return createXMLOutput(out, DEFAULT_ESCAPE_TEXT); }
/** * Creates a text based XMLOutput which converts all XML events into * text and writes to the underlying Writer. */ public static XMLOutput createXMLOutput(Writer writer) { return createXMLOutput(writer, DEFAULT_ESCAPE_TEXT); }
/** * Creates a text based XMLOutput which converts all XML events into * text and writes to the underlying Writer. */ public static XMLOutput createXMLOutput(Writer writer) { return createXMLOutput(writer, DEFAULT_ESCAPE_TEXT); }
/** * Method setOutputStream. * @param outputStream */ public void setOutputStream(OutputStream outputStream) { m_outputStream = outputStream; m_output = XMLOutput.createXMLOutput(new OutputStreamWriter(m_outputStream)); }
/** * Executes the body of the tag and returns the result as a String. * * @param shouldEscape Signal if the text should be escaped. * * @return the text evaluation of the body */ protected String getBodyText(boolean shouldEscape) throws JellyTagException { StringWriter writer = new StringWriter(); invokeBody(XMLOutput.createXMLOutput(writer, shouldEscape)); return writer.toString(); }
/** * Set the file which is generated from the output * @param name The output file name */ public void setFile(String name) throws IOException { this.closeOutput = true; setXmlOutput( XMLOutput.createXMLOutput(new FileOutputStream(name)) ); } }
/** * Creates a text based XMLOutput which converts all XML events into * text and writes to the underlying Writer. * * @param writer is the writer to output to * @param escapeText is whether or not text output will be escaped. This must be true * if the underlying output is XML or could be false if the underlying output is textual. */ public static XMLOutput createXMLOutput(Writer writer, boolean escapeText) { XMLWriter xmlWriter = new XMLWriter(writer); xmlWriter.setEscapeText(escapeText); return createXMLOutput(xmlWriter); }
/** * Set the file which is generated from the output * @param name The output file name */ public void setFile(String name) throws IOException { this.closeOutput = true; setXmlOutput( XMLOutput.createXMLOutput(new FileOutputStream(name)) ); } }
/** * Executes the body of the tag and returns the result as a String. * * @param shouldEscape Signal if the text should be escaped. * * @return the text evaluation of the body */ protected String getBodyText(boolean shouldEscape) throws JellyTagException { StringWriter writer = new StringWriter(); invokeBody(XMLOutput.createXMLOutput(writer, shouldEscape)); return writer.toString(); }
/** * Set the file which is generated from the output * @param name The output file name */ public void setFile(String name) throws IOException { this.closeOutput = true; setXmlOutput( XMLOutput.createXMLOutput(new FileOutputStream(name)) ); } }
/** * Evaluate a Jelly script and return output as a String. * * @since 1.267 */ public static String runScript(Script script) throws JellyTagException { StringWriter out = new StringWriter(); script.run(getCurrentJellyContext(), XMLOutput.createXMLOutput(out)); return out.toString(); }
/** * Evaluate a Jelly script and return output as a String. * * @since 1.267 */ public static String runScript(Script script) throws JellyTagException { StringWriter out = new StringWriter(); script.run(getCurrentJellyContext(), XMLOutput.createXMLOutput(out)); return out.toString(); }
public String getHtml(ProjectConfigInfo projectConfigInfo) throws IOException, ClassNotFoundException, JellyException { String name = getClass().getName().replace('.', '/').replace('$', '/') + "/" + "index.jelly"; URL actionTemplate = getClass().getClassLoader().getResource(name); JellyContext context = new JellyContext(); context.setVariable("p", projectConfigInfo); context.setVariable("it", this); OutputStream outputStream = new ByteArrayOutputStream(); XMLOutput output = XMLOutput.createXMLOutput(outputStream); context.runScript(actionTemplate, output); output.flush(); return "<p>" + outputStream.toString() + " </p>"; }
private String convert(Run<?, ?> build, JellyContext context, Script script) throws JellyTagException, IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(16 * 1024); XMLOutput xmlOutput = XMLOutput.createXMLOutput(output); script.run(context, xmlOutput); xmlOutput.flush(); xmlOutput.close(); output.close(); return output.toString(getCharset(build)); }
public XMLOutput createXMLOutput(Writer writer, boolean escapeText) { StaplerResponse rsp = Stapler.getCurrentResponse(); String ct = rsp!=null ? rsp.getContentType() : "?"; if (ct != null && !ct.startsWith("text/html")) return XMLOutput.createXMLOutput(writer, escapeText); return HTMLWriterOutput.create(writer, escapeText); }
public void testOutputData() throws Exception { setUpScript("outputData.jelly"); Script script = getJelly().compileScript(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); XMLOutput ouput = XMLOutput.createXMLOutput(bos); script.run(getJellyContext(),ouput); ouput.flush(); assertEquals("[string]",bos.toString().trim()); } }
public void testOutputGood() throws Exception { setUpScript("outputGood.jelly"); Script script = getJelly().compileScript(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); script.run(getJellyContext(),XMLOutput.createXMLOutput(bos)); assertEquals("<html></html>x",bos.toString()); }
public void testOutputBad() throws Exception { setUpScript("outputBad.jelly"); Script script = getJelly().compileScript(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); script.run(getJellyContext(),XMLOutput.createXMLOutput(bos)); assertEquals("<html></html>",bos.toString()); }
public void testOutputBadGood() throws Exception { setUpScript("outputBad.jelly"); Script script = getJelly().compileScript(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); XMLOutput ouput = XMLOutput.createXMLOutput(bos); script.run(getJellyContext(),ouput); ouput.flush(); assertEquals("<html></html>",bos.toString()); }