Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 74317 invoked from network); 2 Apr 2003 19:03:38 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 2 Apr 2003 19:03:38 -0000 Received: (qmail 28290 invoked by uid 97); 2 Apr 2003 19:05:30 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 28283 invoked from network); 2 Apr 2003 19:05:30 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 2 Apr 2003 19:05:30 -0000 Received: (qmail 74090 invoked by uid 500); 2 Apr 2003 19:03:35 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 74079 invoked by uid 500); 2 Apr 2003 19:03:35 -0000 Received: (qmail 74073 invoked from network); 2 Apr 2003 19:03:34 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 2 Apr 2003 19:03:34 -0000 Received: (qmail 50847 invoked by uid 1289); 2 Apr 2003 19:03:34 -0000 Date: 2 Apr 2003 19:03:34 -0000 Message-ID: <20030402190334.50846.qmail@icarus.apache.org> From: rdonkin@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/digester/src/java/org/apache/commons/digester AbstractRulesImpl.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N rdonkin 2003/04/02 11:03:34 Added: digester/src/java/org/apache/commons/digester AbstractRulesImpl.java Log: Added new Rule implementation based on a pluggable regex implementation. Also test case and a simple regex matching implementation Revision Changes Path 1.1 jakarta-commons/digester/src/java/org/apache/commons/digester/AbstractRulesImpl.java Index: AbstractRulesImpl.java =================================================================== /* * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/AbstractRulesImpl.java,v 1.1 2003/04/02 19:03:34 rdonkin Exp $ * $Revision: 1.1 $ * $Date: 2003/04/02 19:03:34 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Commons", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . * */ package org.apache.commons.digester; import java.util.List; /** *

AbstractRuleImpl provides basic services for Rules implementations. * Extending this class should make it easier to create a Rules implementation.

* *

AbstractRuleImpl manages the Digester * and namespaceUri properties. * If the subclass overrides {@link #registerRule} (rather than {@link #add}), * then the Digester and namespaceURI of the Rule * will be set correctly before it is passed to registerRule. * The subclass can then perform whatever it needs to do to register the rule.

* * @author Robert Burrell Donkin * @version $Revision: 1.1 $ $Date: 2003/04/02 19:03:34 $ */ abstract public class AbstractRulesImpl implements Rules { // ------------------------------------------------------------- Fields /** Digester using this Rules implementation */ private Digester digester; /** Namespace uri to assoicate with subsequent Rule's */ private String namespaceURI; // ------------------------------------------------------------- Properties /** * Return the Digester instance with which this Rules instance is * associated. */ public Digester getDigester() { return digester; } /** * Set the Digester instance with which this Rules instance is associated. * * @param digester The newly associated Digester instance */ public void setDigester(Digester digester) { this.digester = digester; } /** * Return the namespace URI that will be applied to all subsequently * added Rule objects. */ public String getNamespaceURI() { return namespaceURI; } /** * Set the namespace URI that will be applied to all subsequently * added Rule objects. * * @param namespaceURI Namespace URI that must match on all * subsequently added rules, or null for matching * regardless of the current namespace URI */ public void setNamespaceURI(String namespaceURI) { this.namespaceURI = namespaceURI; } // --------------------------------------------------------- Public Methods /** * Registers a new Rule instance matching the specified pattern. * This implementation sets the Digester and the * namespaceURI on the Rule before calling {@link #registerRule}. * * @param pattern Nesting pattern to be matched for this Rule * @param rule Rule instance to be registered */ public void add(String pattern, Rule rule) { // set up rule if (this.digester != null) { rule.setDigester(this.digester); } if (this.namespaceURI != null) { rule.setNamespaceURI(this.namespaceURI); } registerRule(pattern, rule); } /** * Register rule at given pattern. * The the Digester and namespaceURI properties of the given Rule * can be assumed to have been set properly before this method is called. * * @param pattern Nesting pattern to be matched for this Rule * @param rule Rule instance to be registered */ abstract protected void registerRule(String pattern, Rule rule); /** * Clear all existing Rule instance registrations. */ abstract public void clear(); /** * Return a List of all registered Rule instances that match the specified * nesting pattern, or a zero-length List if there are no matches. If more * than one Rule instance matches, they must be returned * in the order originally registered through the add() * method. * * @param pattern Nesting pattern to be matched * * @deprecated Call match(namespaceURI,pattern) instead. */ public List match(String pattern) { return match(namespaceURI, pattern); } /** * Return a List of all registered Rule instances that match the specified * nesting pattern, or a zero-length List if there are no matches. If more * than one Rule instance matches, they must be returned * in the order originally registered through the add() * method. * * @param namespaceURI Namespace URI for which to select matching rules, * or null to match regardless of namespace URI * @param pattern Nesting pattern to be matched */ abstract public List match(String namespaceURI, String pattern); /** * Return a List of all registered Rule instances, or a zero-length List * if there are no registered Rule instances. If more than one Rule * instance has been registered, they must be returned * in the order originally registered through the add() * method. */ abstract public List rules(); } --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org