alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Commons Digester example source code file (TestRuleSet.java)

This example Commons Digester source code file (TestRuleSet.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Commons Digester tags/keywords

override, override, rulesetbase, rulesetbase, string, string, testruleset, testruleset

The Commons Digester TestRuleSet.java source code

/* $Id: TestRuleSet.java 992060 2010-09-02 19:09:47Z simonetripodi $
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package org.apache.commons.digester;


/**
 * RuleSet that mimics the rules set used for Employee and Address creation,
 * optionally associated with a particular namespace URI.
 *
 * @author Craig R. McClanahan
 * @version $Revision: 992060 $ $Date: 2010-09-02 21:09:47 +0200 (Thu, 02 Sep 2010) $
 */

public class TestRuleSet extends RuleSetBase {


    // ----------------------------------------------------------- Constructors


    /**
     * Construct an instance of this RuleSet with default values.
     */
    public TestRuleSet() {

        this(null, null);

    }


    /**
     * Construct an instance of this RuleSet associated with the specified
     * prefix, associated with no namespace URI.
     *
     * @param prefix Matching pattern prefix (must end with '/') or null.
     */
    public TestRuleSet(String prefix) {

        this(prefix, null);

    }


    /**
     * Construct an instance of this RuleSet associated with the specified
     * prefix and namespace URI.
     *
     * @param prefix Matching pattern prefix (must end with '/') or null.
     * @param namespaceURI The namespace URI these rules belong to
     */
    public TestRuleSet(String prefix, String namespaceURI) {

        super();
        if (prefix == null)
            this.prefix = "";
        else
            this.prefix = prefix;
        this.namespaceURI = namespaceURI;

    }


    // ----------------------------------------------------- Instance Variables


    /**
     * The prefix for each matching pattern added to the Digester instance,
     * or an empty String for no prefix.
     */
    protected String prefix = null;


    // --------------------------------------------------------- Public Methods


    /**
     * Add the set of Rule instances defined in this RuleSet to the
     * specified <code>Digester instance, associating them with
     * our namespace URI (if any).  This method should only be called
     * by a Digester instance.
     *
     * @param digester Digester instance to which the new Rule instances
     *  should be added.
     */
    @Override
    public void addRuleInstances(Digester digester) {

        digester.addObjectCreate(prefix + "employee", Employee.class);
        digester.addSetProperties(prefix + "employee");
        digester.addObjectCreate("employee/address",
                "org.apache.commons.digester.Address");
        digester.addSetProperties(prefix + "employee/address");
        digester.addSetNext(prefix + "employee/address",
                "addAddress");

    }
    

}

Other Commons Digester examples (source code examples)

Here is a short list of links related to this Commons Digester TestRuleSet.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.