Java 类net.sf.jasperreports.engine.component.XmlDigesterConfigurer 实例源码

项目:jasperreports    文件:JRXmlDigesterFactory.java   
protected static void addComponentRules(JasperReportsContext jasperReportsContext, Digester digester)
{
    digester.addFactoryCreate("*/componentElement", JRComponentElementFactory.class.getName());
    digester.addSetNext("*/componentElement", "addElement", JRDesignElement.class.getName());

    Collection<ComponentsBundle> components = ComponentsEnvironment.getInstance(jasperReportsContext).getBundles();
    for (Iterator<ComponentsBundle> it = components.iterator(); it.hasNext();)
    {
        ComponentsBundle componentsBundle = it.next();
        ComponentsXmlParser xmlParser = componentsBundle.getXmlParser();
        digester.setRuleNamespaceURI(xmlParser.getNamespace());

        XmlDigesterConfigurer configurer = xmlParser.getDigesterConfigurer();
        if (configurer != null)
        {
            configurer.configureDigester(digester);
        }

        digester.setRuleNamespaceURI(xmlParser.getNamespace());
        for (Iterator<String> namesIt = componentsBundle.getComponentNames().iterator(); 
                namesIt.hasNext();)
        {
            String componentName = namesIt.next();
            digester.addRule("*/componentElement/" + componentName, 
                    JRComponentRule.newInstance());
        }
    }

    digester.setRuleNamespaceURI(JRXmlConstants.JASPERREPORTS_NAMESPACE);
}
项目:jasperreports    文件:JRXmlDigesterFactory.java   
protected static void addPartComponentRules(JasperReportsContext jasperReportsContext, Digester digester)
{
    digester.addFactoryCreate("*/part", JRPartFactory.class.getName());
    digester.addRule("*/part", new UuidPropertyRule("uuid", "UUID"));
    digester.addSetNext("*/part", "addPart", JRPart.class.getName());

    addExpressionRules(digester, "*/part/" + JRXmlConstants.ELEMENT_partNameExpression, "setPartNameExpression");

    Collection<PartComponentsBundle> components = PartComponentsEnvironment.getInstance(jasperReportsContext).getBundles();
    for (Iterator<PartComponentsBundle> it = components.iterator(); it.hasNext();)
    {
        PartComponentsBundle componentsBundle = it.next();
        ComponentsXmlParser xmlParser = componentsBundle.getXmlParser();
        digester.setRuleNamespaceURI(xmlParser.getNamespace());

        XmlDigesterConfigurer configurer = xmlParser.getDigesterConfigurer();
        if (configurer != null)
        {
            configurer.configureDigester(digester);
        }

        digester.setRuleNamespaceURI(xmlParser.getNamespace());
        for (Iterator<String> namesIt = componentsBundle.getComponentNames().iterator(); 
                namesIt.hasNext();)
        {
            String componentName = namesIt.next();
            digester.addRule("*/part/" + componentName, 
                    JRPartComponentRule.newInstance());
        }
    }

    digester.setRuleNamespaceURI(JRXmlConstants.JASPERREPORTS_NAMESPACE);
}