Package org.apache.commons.jelly.parser

Examples of org.apache.commons.jelly.parser.XMLParser


        super(testName);
    }

    public void testArgs() throws Exception {
        InputStream in = new FileInputStream("src/test/org/apache/commons/jelly/test_args.jelly");
        XMLParser parser = new XMLParser();
        Script script = parser.parse(in);
        script = script.compile();
        log.debug("Found: " + script);
        assertTrue("Parsed a Script", script instanceof Script);
        String[] args = { "one", "two", "three" };
        JellyContext context = new JellyContext();
View Full Code Here


    {
        // FIXME: This should all be done by Jelly.
        SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setNamespaceAware( true );
        XMLReader reader = factory.newSAXParser().getXMLReader();
        XMLParser parser = new XMLParser( reader );
        parser.setContext( context );
        parser.setClassLoader( context.getClassLoader() );

        Script script = null;

        InputSource source = null;
        if ( encoding != null )
        {
            InputStreamReader isr = null;
            try
            {
                isr = new InputStreamReader( scriptInputStream, encoding );
                source = new InputSource( isr );

            }
            finally
            {
                if ( isr != null )
                {
                    try
                    {
                        isr.close();
                    }
                    catch ( IOException e )
                    {
                        LOGGER.debug( "WARNING: Cannot close stream!", e );
                    }
                    isr = null;
                }
            }

        }
        else
        {
            source = new InputSource( scriptInputStream );
        }

        if ( systemId != null )
        {
            source.setSystemId( systemId );
        }
        if ( LOGGER.isDebugEnabled() )
        {
            LOGGER.debug( "the system identifier to help resolve relative URLs : " + systemId );
        }
        script = parser.parse( source );

        script = script.compile();

        return script;
    }
View Full Code Here

        super(testName);
    }

    public void testArgs() throws Exception {
        InputStream in = new FileInputStream("src/test/org/apache/commons/jelly/test_args.jelly");
        XMLParser parser = new XMLParser();
        Script script = parser.parse(in);
        script = script.compile();
        log.debug("Found: " + script);
        assertTrue("Parsed a Script", script instanceof Script);
        String[] args = { "one", "two", "three" };
        JellyContext context = new JellyContext();
View Full Code Here

        rt.gc();

        long start = rt.totalMemory() - rt.freeMemory();
        log.info("Starting memory test with used memory of " + start);

        XMLParser parser;
        Script script;

        int outputEveryXIterations = outputEveryXIterations();

        for (int i = 0; i < count; i++) {
            scriptIStream.reset();
            parser = new XMLParser();

            script = parser.parse(scriptISource);
            script.run(jc, output);
            // PL: I don't see why but removing the clear here
            //     does make the test fail!
            //     As if the WeakHashMap wasn't weak enough...
           
View Full Code Here

    /**
     * Factory method to create a new Jelly parser
     * @return XMLParser
     */
    protected XMLParser createJellyParser() {
        XMLParser answer = new XMLParser();
        answer.setContext(context);
        return answer;
    }
View Full Code Here

    /**
     * Attempts to parse the script from the given uri using the
     * {@link #getResource} method then returns the compiled script.
     */
    public Script compileScript(String uri) throws JellyException {
        XMLParser parser = getXMLParser();
        parser.setContext(this);
        InputStream in = getResourceAsStream(uri);
        if (in == null) {
            throw new JellyException("Could not find Jelly script: " + uri);
        }
        Script script = null;
        try {
            script = parser.parse(in);
        } catch (IOException e) {
            throw new JellyException(JellyContext.BAD_PARSE, e);
        } catch (SAXException e) {
            throw new JellyException(JellyContext.BAD_PARSE, e);
        }
View Full Code Here

    /**
     * Attempts to parse the script from the given URL using the
     * {@link #getResource} method then returns the compiled script.
     */
    public Script compileScript(URL url) throws JellyException {
        XMLParser parser = getXMLParser();
        parser.setContext(this);

        Script script = null;
        try {
            script = parser.parse(url.toString());
        } catch (IOException e) {
            throw new JellyException(JellyContext.BAD_PARSE, e);
        } catch (SAXException e) {
            throw new JellyException(JellyContext.BAD_PARSE, e);
        }
View Full Code Here

    /**
     * Attempts to parse the script from the given InputSource using the
     * {@link #getResource} method then returns the compiled script.
     */
    public Script compileScript(InputSource source) throws JellyException {
        XMLParser parser = getXMLParser();
        parser.setContext(this);

        Script script = null;
        try {
            script = parser.parse(source);
        } catch (IOException e) {
            throw new JellyException(JellyContext.BAD_PARSE, e);
        } catch (SAXException e) {
            throw new JellyException(JellyContext.BAD_PARSE, e);
        }
View Full Code Here

    /**
     * @return a thread pooled XMLParser to avoid the startup overhead
     * of the XMLParser
     */
    protected XMLParser getXMLParser() {
        XMLParser parser = createXMLParser();
        return parser;
    }
View Full Code Here

    /**
     * Factory method to allow JellyContext implementations to overload how an XMLParser
     * is created - such as to overload what the default ExpressionFactory should be.
     */
    protected XMLParser createXMLParser() {
        return new XMLParser();
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.jelly.parser.XMLParser

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.