Package org.apache.commons.digester

Examples of org.apache.commons.digester.Rule


     *
     * @param path digester path where this rule will be attached
     * @param childDescriptor update this <code>ElementDescriptor</code> with the body text
     */
    protected void addPrimitiveTypeRule(String path, final ElementDescriptor childDescriptor) {
        Rule rule = new Rule() {
            public void body(String text) throws Exception {
                childDescriptor.getUpdater().update( context, text );
            }       
        };
        addRule( path, rule );
View Full Code Here


        if ((rules != null) && (rules.size() > 0)) {
            Log log = digester.getLogger();
            boolean debug = log.isDebugEnabled();
            for (int i = 0; i < rules.size(); i++) {
                try {
                    Rule rule = (Rule) rules.get(i);
                    if (debug) {
                        log.debug("  Fire begin() for " + rule);
                    }
                    rule.begin(namespace, name, list);
                } catch (Exception e) {
                    throw digester.createSAXException(e);
                } catch (Error e) {
                    throw e;
                }
View Full Code Here

        if ((rules != null) && (rules.size() > 0)) {
            Log log = digester.getLogger();
            boolean debug = log.isDebugEnabled();
            for (int i = 0; i < rules.size(); i++) {
                try {
                    Rule rule = (Rule) rules.get(i);
                    if (debug) {
                        log.debug("  Fire body() for " + rule);
                    }
                    rule.body(namespaceURI, name, text);
                } catch (Exception e) {
                    throw digester.createSAXException(e);
                } catch (Error e) {
                    throw e;
                }
View Full Code Here

            Log log = digester.getLogger();
            boolean debug = log.isDebugEnabled();
            for (int i = 0; i < rules.size(); i++) {
                int j = (rules.size() - i) - 1;
                try {
                    Rule rule = (Rule) rules.get(j);
                    if (debug) {
                        log.debug("  Fire end() for " + rule);
                    }
                    rule.end(namespaceURI, name);
                } catch (Exception e) {
                    throw digester.createSAXException(e);
                } catch (Error e) {
                    throw e;
                }
View Full Code Here

public class IncludeTest extends TestCase {

    public static class TestDigesterRuleSource implements DigesterRulesSource {
        public void getRules(Digester digester) {
            digester.addRule("bar",
                new Rule() {
                    public void body(String namespace, String name, String text) {
                        ((ArrayList) this.digester.peek()).add(text);
                    }
                });
        }
View Full Code Here

    /**
     * Factory for creating a BeanPropertySetterRule.
     */
    private class BeanPropertySetterRuleFactory extends AbstractObjectCreationFactory {
        public Object createObject(Attributes attributes) throws Exception {
            Rule beanPropertySetterRule = null;
            String propertyname = attributes.getValue("propertyname");
               
            if (propertyname == null) {
                // call the setter method corresponding to the element name.
                beanPropertySetterRule = new BeanPropertySetterRule();
View Full Code Here

    /**
     * Factory for creating a CallMethodRule.
     */
    protected class CallMethodRuleFactory extends AbstractObjectCreationFactory {
        public Object createObject(Attributes attributes) {
            Rule callMethodRule = null;
            String methodName = attributes.getValue("methodname");

            // Select which element is to be the target. Default to zero,
            // ie the top object on the stack.
            int targetOffset = 0;
View Full Code Here

            // create callparamrule
            int paramIndex = Integer.parseInt(attributes.getValue("paramnumber"));
            String attributeName = attributes.getValue("attrname");
            String fromStack = attributes.getValue("from-stack");
            String stackIndex = attributes.getValue("stack-index");
            Rule callParamRule = null;

            if (attributeName == null) {
                if (stackIndex != null) {                   
                    callParamRule = new CallParamRule(
                        paramIndex, Integer.parseInt(stackIndex));               
View Full Code Here

            int paramIndex = Integer.parseInt(attributes.getValue("paramnumber"));
            String attributeName = attributes.getValue("attrname");
            String type = attributes.getValue("type");
            String value = attributes.getValue("value");

            Rule objectParamRule = null;

            // type name is requried
            if (type == null) {
                throw new RuntimeException("Attribute 'type' is required.");
            }
View Full Code Here

    Digester digester = new Digester();
    digester.clear();
    digester.setNamespaceAware(false);
        digester.setUseContextClassLoader(false);
        digester.setValidating(false);
        digester.addRule("map/entry", new Rule() {
          /** SCXML target ID. */
          private String targetId;
          /** JSF view ID. */
          private String viewId;
            /** {@inheritDoc} */
 
View Full Code Here

TOP

Related Classes of org.apache.commons.digester.Rule

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.