Examples of SAXConfigurationHandler


Examples of org.apache.avalon.framework.configuration.SAXConfigurationHandler

        try {
            resolver = (org.apache.excalibur.source.SourceResolver) this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);
            Source source = null;
            try {
                source = resolver.resolveURI(configurationFile);
                SAXConfigurationHandler handler = new SAXConfigurationHandler();
                SourceUtil.toSAX(source, handler);
                config = handler.getConfiguration();
            } catch (ProcessingException se) {
                throw new ParameterException("Unable to read configuration from " + configurationFile, se);
            } catch (SAXException se) {
                throw new ParameterException("Unable to read configuration from " + configurationFile, se);
            } catch (IOException ioe) {
View Full Code Here

Examples of org.apache.avalon.framework.configuration.SAXConfigurationHandler

     *   </rawName>
     * </pre>
     */
    public void testDefaultHandling() throws Exception
    {
        SAXConfigurationHandler handler = new SAXConfigurationHandler( );

        final String rootURI = "";
        final String rootlocal = "rawName";
        final String rootraw = "rawName";
        final String childURI = "namespaceURI";
        final String childlocal = "localName";
        final String childraw = "child:" + childlocal;
        final String childvalue = "value";
        final String attqName = "attqName";
        final String attValue = "attValue";
        final String emptylocal = "emptyElement";
        final String emptyraw = emptylocal;
       
        final AttributesImpl emptyAttributes  = new AttributesImpl();

        final AttributesImpl attributes  = new AttributesImpl();
        attributes.addAttribute("",attqName,attqName,
                                "CDATA",attValue);

        final AttributesImpl childAttributes  = new AttributesImpl();
        childAttributes.addAttribute("", "child", "xmlns:child", "CDATA", childURI);

        handler.startDocument();
        handler.startPrefixMapping( "child", childURI );
        handler.startElement( rootURI, rootlocal, rootraw, attributes );
        handler.startElement( childURI,
                                childlocal,
                                childraw,
                                childAttributes );

        handler.characters( childvalue.toCharArray(), 0, childvalue.length() );
        handler.endElement( childURI, childlocal, childraw );
        handler.startElement( rootURI, emptylocal, emptyraw, emptyAttributes );
        handler.endElement( rootURI, emptylocal, emptyraw );
        handler.endElement( null, null, rootraw);
        handler.endPrefixMapping( "child" );
        handler.endDocument();

        final Configuration configuration = handler.getConfiguration();
        assertEquals( attValue, configuration.getAttribute(attqName));
        assertEquals( childvalue, configuration.getChild(childraw).getValue());
        assertEquals( "", configuration.getChild(childraw).getNamespace() );
        assertEquals( rootraw, configuration.getName());
        assertEquals( "test", configuration.getChild(emptyraw).getValue( "test" ) );
View Full Code Here

Examples of org.apache.avalon.framework.configuration.SAXConfigurationHandler

        assertEquals( "test", configuration.getChild(emptyraw).getValue( "test" ) );
    }

    public void testNamespaceHandling() throws Exception
    {
        SAXConfigurationHandler handler = new NamespacedSAXConfigurationHandler( );

        final String rootURI = "";
        final String rootlocal = "rawName";
        final String rootraw = "rawName";
        final String childURI = "namespaceURI";
        final String childlocal = "localName";
        final String childraw = "child:" + childlocal;
        final String childvalue = "value";
        final String attqName = "attqName";
        final String attValue = "attValue";

        final AttributesImpl attributes  = new AttributesImpl();
        attributes.addAttribute("",attqName,attqName,
                                "CDATA",attValue);

        final AttributesImpl childAttributes  = new AttributesImpl();
        childAttributes.addAttribute("", "child", "xmlns:child", "CDATA", childURI);

        handler.startDocument();
        handler.startPrefixMapping( "child", childURI );
        handler.startElement( rootURI, rootlocal, rootraw, attributes );
        handler.startElement( childURI,
                                childlocal,
                                childraw,
                                childAttributes );

        handler.characters( childvalue.toCharArray(), 0, childvalue.length() );
        handler.endElement( childURI, childlocal, childraw );
        handler.endElement( null, null, rootraw);
        handler.endPrefixMapping( "child" );
        handler.endDocument();

        final Configuration configuration = handler.getConfiguration();
        assertEquals( attValue, configuration.getAttribute(attqName));
        assertEquals( childvalue, configuration.getChild(childlocal).getValue());
        assertEquals( childURI, configuration.getChild(childlocal).getNamespace() );
        assertEquals( rootraw, configuration.getName());
    }
View Full Code Here

Examples of org.apache.avalon.framework.configuration.SAXConfigurationHandler

                    if (conf == null) {
                        conf = new ConfigurationHelper();
                    }

                    SAXConfigurationHandler builder = new SAXConfigurationHandler();
                    SourceUtil.parse(this.manager, resource, builder);

                    conf.lastModified = resource.getLastModified();
                    conf.configuration = builder.getConfiguration();

                    AbstractComplementaryConfigurableAction.configurations.put(resource.getURI(), conf);
                } else {
                    getLogger().debug("Using cached configuration for " + descriptor);
                }
View Full Code Here

Examples of org.apache.avalon.framework.configuration.SAXConfigurationHandler

        // Read the builtin languages definition file
        Configuration builtin;
        try {
            Source source = this.resolver.resolveURI( xconfURL );
            try {
                SAXConfigurationHandler handler = new SAXConfigurationHandler();
                SourceUtil.toSAX( this.manager, source, null, handler);
                builtin = handler.getConfiguration();
            } finally {
                this.resolver.release( source );
            }
        } catch(Exception e) {
            String msg = "Error while reading " + xconfURL + ": " + e.getMessage();
View Full Code Here

Examples of org.apache.avalon.framework.configuration.SAXConfigurationHandler

                    if (conf == null) {
                        conf = new ConfigurationHelper();
                    }

                    SAXConfigurationHandler builder = new SAXConfigurationHandler();
                    SourceUtil.toSAX(source, builder);

                    conf.lastModified = source.getLastModified();
                    conf.configuration = builder.getConfiguration();

                    FormValidatorHelper.cacheConfiguration(source.getURI(), conf);
                } else {
                    logger.debug("Using cached configuration for " + descriptor);
                }
View Full Code Here

Examples of org.apache.avalon.framework.configuration.SAXConfigurationHandler

        try {
            resolver = (org.apache.excalibur.source.SourceResolver) this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);
            Source source = null;
            try {
                source = resolver.resolveURI(configurationFile);
                SAXConfigurationHandler handler = new SAXConfigurationHandler();
                SourceUtil.toSAX(source, handler);
                config = handler.getConfiguration();
            } catch (ProcessingException se) {
                throw new ParameterException("Unable to read configuration from " + configurationFile, se);
            } catch (SAXException se) {
                throw new ParameterException("Unable to read configuration from " + configurationFile, se);
            } catch (IOException ioe) {
View Full Code Here

Examples of org.apache.avalon.framework.configuration.SAXConfigurationHandler

  /**
   * @return
   */
  private Configuration readRefreshJobConfiguration() {
    SAXConfigurationHandler b = new SAXConfigurationHandler();
    try {
        SourceUtil.toSAX(this.manager, this.writeSource, this.writeSource.getMimeType(), b);
    } catch (Exception ignore) {
        this.getLogger().warn("Unable to read configuration from " + this.writeSource.getURI());
    }
    final Configuration conf = b.getConfiguration();
    return conf;
  }
View Full Code Here

Examples of org.apache.avalon.framework.configuration.SAXConfigurationHandler

        Configuration configuration = null;
        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);

            parser = (SAXParser) this.manager.lookup(SAXParser.ROLE);
            SAXConfigurationHandler confighandler = new SAXConfigurationHandler();

            source = resolver.resolveURI(this.file);
            parser.parse(new InputSource(source.getInputStream()),confighandler);
            configuration = confighandler.getConfiguration();

        } finally {
            if (source != null) {
                resolver.release(source);
            }
View Full Code Here

Examples of org.codehaus.dna.impl.SAXConfigurationHandler

    }

    public void testCreateConfigurationWithAttributes()
        throws Exception
    {
        final SAXConfigurationHandler handler = new SAXConfigurationHandler();
        final String qName = "myElement";
        final AttributesImpl attributes = new AttributesImpl();
        attributes.addAttribute( "", "", "key", "CDATA", "value" );
        handler.startElement( "", "", qName, attributes );
        handler.endElement( "", "", qName );
        final Configuration configuration = handler.getConfiguration();
        assertEquals( "configuration.name", qName, configuration.getName() );
        assertEquals( "configuration.location", "", configuration.getLocation() );
        assertEquals( "configuration.path", "", configuration.getPath() );
        final String[] names = configuration.getAttributeNames();
        assertEquals( "names.length", 1, names.length );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.