Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.Script


    /** Use this method to access the script.
     * @throws JellyException If the script has been GC'd.
     */
    public Script script() throws JellyTagException {
        Script script = (Script) reference.get();
       
        if (script == null) {
            throw new JellyTagException("Attempt to use a script that has been garbage collected.");
        }
       
View Full Code Here


       
        if (bodyScript instanceof ScriptBlock) {
            ScriptBlock scriptBlock = (ScriptBlock) bodyScript;
            List scriptList = scriptBlock.getScriptList();
            for (Iterator iter = scriptList.iterator(); iter.hasNext(); ) {
                Script script = (Script) iter.next();
                if (script instanceof StaticTagScript) {
                    return true;
                }
            }
        }
View Full Code Here

                    XMLOutput.createXMLOutput(System.out);

            Jelly jelly = new Jelly();
            jelly.setScript(scriptFile);

            Script script = jelly.compileScript();

            // add the system properties and the command line arguments
            JellyContext context = jelly.getJellyContext();
            context.setVariable("args", args);
            context.setVariable("commandLine", cmdLine);
            script.run(context, output);

            // now lets wait for all threads to close
            Runtime.getRuntime().addShutdownHook(new Thread() {
                    public void run() {
                        try {
View Full Code Here

     */
    public void trimWhitespace() {
        List list = getScriptList();
        int size = list.size();
        if ( size > 0 ) {
            Script script = (Script) list.get(0);
            if ( script instanceof TextScript ) {
                TextScript textScript = (TextScript) script;
                textScript.trimStartWhitespace();
            }
            if ( size > 1 ) {
View Full Code Here

    // Script interface
    //-------------------------------------------------------------------------
    public Script compile() throws JellyException {
        int size = list.size();
        if (size == 1) {
            Script script = (Script) list.get(0);
            return script.compile();
        }
        // now compile children
        for (int i = 0; i < size; i++) {
            Script script = (Script) list.get(i);
            list.set(i, script.compile());
        }
        return this;
    }
View Full Code Here

            Script script = scripts[i];
            script.run(context, output);
        }
*/
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            Script script = (Script) iter.next();
            script.run(context, output);
        }
    }
View Full Code Here

     * In this case, trim all elements, removing any that are empty text.
     */
    public void trimWhitespace() {
        List list = getScriptList();
        for ( int i = list.size() - 1; i >= 0; i-- ) {
            Script script = (Script) list.get(i);
            if ( script instanceof TextScript ) {
                TextScript textScript = (TextScript) script;
                String text = textScript.getText();
                text = text.trim();
                if ( text.length() == 0 ) {
View Full Code Here

        }
        else {
            parseBody(output);
        }

        Script script = getJellyParser().getScript();
        if (var != null) {
            context.setVariable(var, script);
        }
        else {
            // invoke the script
            script.run(context, output);
        }
    }
View Full Code Here

    public Tag createTag(String name, Attributes attributes)
        throws JellyException {

        Object value = templates.get(name);
        if ( value instanceof Script ) {
            Script template = (Script) value;
            return new DynamicTag(template);
        }
        else if ( value instanceof TagFactory ) {
            TagFactory factory = (TagFactory) value;
            return factory.createTag(name, attributes);
View Full Code Here

        super(name);
    }
   
    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());
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.jelly.Script

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.