Package org.apache.commons.digester

Examples of org.apache.commons.digester.Rule


    // resource <f:resource f:key='images/spacer.gif' [f:data='...'] [ ... any attributes ... ] />
    pattern =ANY_PARENT+NS_PREFIX+RESOURCE_TAG;
    digestr.addObjectCreate(pattern,ResourceElement.class);
    digestr.addSetNext(pattern,CHILD_METHOD);
    {
    Rule rule = new PutAttributesRule(digestr,new String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"baseSkin",NS_PREFIX+"skin",NS_PREFIX+"context"});
    digestr.addRule(pattern,rule);
    }
    {
    SetPropertiesRule rule = new SetPropertiesRule(new String[]{NS_PREFIX+"key",NS_PREFIX+"property",NS_PREFIX+"baseSkin",NS_PREFIX+"skin",NS_PREFIX+"context"},new String[]{"value","property","baseSkin","skin","context"});   
    digestr.addRule(pattern,rule);
View Full Code Here


    private static void addParentRule(final String xp,
            final ExtendedBaseRules scxmlRules, final int parent) {
        if (parent < 1) {
            return;
        }
        scxmlRules.add(xp, new Rule() {
            // A generic version of setTopRule
            public void body(final String namespace, final String name,
                    final String text) throws Exception {
                TransitionTarget t = (TransitionTarget) getDigester().peek();
                TransitionTarget p = (TransitionTarget) getDigester().peek(
View Full Code Here

            new String[] {"event", "cond", "target"},
            new String[] {"event", "cond", "next"}));
        scxmlRules.add(xp, new SetCurrentNamespacesRule());
        scxmlRules.add(xp + XPF_TAR, new SetPropertiesRule());
        addActionRules(xp, scxmlRules, pr, customActions);
        scxmlRules.add(xp + XPF_EXT, new Rule() {
            public void end(final String namespace, final String name) {
                Transition t = (Transition) getDigester().peek(1);
                State exitState = new State();
                exitState.setFinal(true);
                t.getTargets().add(exitState);
View Full Code Here

        scxmlRules.add(xp, new SetCurrentNamespacesRule());
        addActionRules(xp, scxmlRules, pr, customActions);

        // Add <exit> custom action rule in Commons SCXML namespace
        scxmlRules.setNamespaceURI(NAMESPACE_COMMONS_SCXML);
        scxmlRules.add(xp + XPF_EXT, new Rule() {
            public void end(final String namespace, final String name) {
                Transition t = (Transition) getDigester().peek(1);
                State exitState = new State();
                exitState.setFinal(true);
                t.getTargets().add(exitState);
View Full Code Here

     * working.
     */
    private void addOldArgRules(Digester digester) {

        // Create a new rule to process args elements
        Rule rule = new Rule() {
            public void begin(String namespace, String name,
                               Attributes attributes) throws Exception {
                // Create the Arg
                Arg arg = new Arg();
                arg.setKey(attributes.getValue("key"));
View Full Code Here

    /** Sets digeseter using these Rules */
    public void setDigester(Digester digester) {
        wrappedRules.setDigester(digester);
        Iterator it = defaultRules.iterator();
        while (it.hasNext()) {
            Rule rule = (Rule) it.next();
            rule.setDigester(digester);
        }
    }
View Full Code Here

            digester.addCallMethod
              ("faces-config/validator/validator-id", "setValidatorId", 0);
            digester.addCallMethod
              ("faces-config/validator/validator-class", "setValidatorClass", 0);
           
            digester.addRule("faces-config/factory/visit-context-factory", new Rule() {
              @Override
              public void body(String namespace, String name, String text)
                  throws Exception {
                if (text != null && text.trim().length() != 0) {
                    FactoryFinder.setFactory("javax.faces.component.visit.VisitContextFactory", text.trim());
View Full Code Here

     * Gets the rule that maps the <code>name</code> element
     * associated with the option
     * @return <code>Rule</code>, not null
     */
    public Rule getNameRule() {
        return new Rule() {
            public void body(String namespace, String name, String text) {
                currentName = text;
            }           
        };
    }
View Full Code Here

     * Gets the rule that maps the <code>value</code> element
     * associated with the option
     * @return <code>Rule</code>, not null
     */
    public Rule getValueRule() {
        return new Rule() {
            public void body(String namespace, String name, String text) {
                currentValue = text;
            }           
        };
    }
View Full Code Here

                        ElementDescriptor[] desc = currentDescriptor.getElementDescriptors();
                        if (desc.length == 1) {
                            path = "*/"+desc[0].getQualifiedName();
                        }
                    }
                    Rule rule = new BeanCreateRule( childDescriptor, context, path, matchIDs);
                    addRule(path, rule);
                    continue;
                }
                if ( childDescriptor.getUpdater() != null ) {
                    if (log.isTraceEnabled()) {
                        log.trace("Element has updater "
                         + ((MethodUpdater) childDescriptor.getUpdater()).getMethod().getName());
                    }
                    if ( childDescriptor.isPrimitiveType() ) {
                        addPrimitiveTypeRule(path, childDescriptor);
                       
                    } else {
                        // add the first child to the path
                        ElementDescriptor[] grandChildren = childDescriptor.getElementDescriptors();
                        if ( grandChildren != null && grandChildren.length > 0 ) {
                            ElementDescriptor grandChild = grandChildren[0];
                            String grandChildQName = grandChild.getQualifiedName();
                            if ( grandChildQName != null && grandChildQName.length() > 0 ) {
                                if (childDescriptor.isWrapCollectionsInElement()) {
                                    path += '/' + grandChildQName;
                                   
                                } else {
                                    path = prefix + (prefix.endsWith("/")?"":"/") + grandChildQName;
                                }
                            }
                        }
                       
                        // maybe we are adding a primitve type to a collection/array
                        Class beanClass = childDescriptor.getSingularPropertyType();
                        if ( XMLIntrospectorHelper.isPrimitiveType( beanClass ) ) {
                            addPrimitiveTypeRule(path, childDescriptor);
                           
                        } else {
                            Rule rule = new BeanCreateRule(
                                                        childDescriptor,
                                                        context,
                                                        path + '/',
                                                        matchIDs );
                            addRule( path, rule );
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.