commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/digester/src/test/org/apache/commons/digester RuleTestCase.java TestRule.java
Date Mon, 11 Mar 2002 20:18:46 GMT
rdonkin     02/03/11 12:18:46

  Modified:    digester/src/java/org/apache/commons/digester Digester.java
                        Rule.java
               digester/src/test/org/apache/commons/digester
                        RuleTestCase.java TestRule.java
  Log:
  Implemented digester design improvement suggested by James Carman. Added empty constructor
and setDigester method for Rule and changed digester to call setDigester in addRule.
  
  Revision  Changes    Path
  1.48      +7 -5      jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java
  
  Index: Digester.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- Digester.java	11 Mar 2002 05:01:54 -0000	1.47
  +++ Digester.java	11 Mar 2002 20:18:44 -0000	1.48
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java,v
1.47 2002/03/11 05:01:54 craigmcc Exp $
  - * $Revision: 1.47 $
  - * $Date: 2002/03/11 05:01:54 $
  + * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java,v
1.48 2002/03/11 20:18:44 rdonkin Exp $
  + * $Revision: 1.48 $
  + * $Date: 2002/03/11 20:18:44 $
    *
    * ====================================================================
    *
  @@ -112,7 +112,7 @@
    *
    * @author Craig McClanahan
    * @author Scott Sanders
  - * @version $Revision: 1.47 $ $Date: 2002/03/11 05:01:54 $
  + * @version $Revision: 1.48 $ $Date: 2002/03/11 20:18:44 $
    */
   
   public class Digester extends DefaultHandler {
  @@ -1359,13 +1359,15 @@
   
   
       /**
  -     * Register a new Rule matching the specified pattern.
  +     * <p>Register a new Rule matching the specified pattern.
  +     * This method sets the <code>Digester</code> property on the rule.</p>
        *
        * @param pattern Element matching pattern
        * @param rule Rule to be registered
        */
       public void addRule(String pattern, Rule rule) {
   
  +        rule.setDigester(this);
           getRules().add(pattern, rule);
   
       }
  
  
  
  1.6       +21 -7     jakarta-commons/digester/src/java/org/apache/commons/digester/Rule.java
  
  Index: Rule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Rule.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Rule.java	9 Jan 2002 20:22:49 -0000	1.5
  +++ Rule.java	11 Mar 2002 20:18:44 -0000	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Rule.java,v
1.5 2002/01/09 20:22:49 sanders Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/01/09 20:22:49 $
  + * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Rule.java,v
1.6 2002/03/11 20:18:44 rdonkin Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/03/11 20:18:44 $
    *
    * ====================================================================
    *
  @@ -71,7 +71,7 @@
    * a corresponding nested pattern of XML elements has been matched.
    *
    * @author Craig McClanahan
  - * @version $Revision: 1.5 $ $Date: 2002/01/09 20:22:49 $
  + * @version $Revision: 1.6 $ $Date: 2002/03/11 20:18:44 $
    */
   
   public abstract class Rule {
  @@ -81,16 +81,22 @@
   
   
       /**
  -     * Default constructor sets only the the associated Digester.
  +     * Constructor sets the associated Digester.
        *
        * @param digester The digester with which this rule is associated
        */
       public Rule(Digester digester) {
   
           super();
  -        this.digester = digester;
  +        setDigester(digester);
   
       }
  +    
  +    /**
  +     * <p>Base constructor.
  +     * Now the digester will be set when the rule is added.</p>
  +     */
  +    public Rule() {}
   
   
       // ----------------------------------------------------- Instance Variables
  @@ -119,7 +125,15 @@
           return (this.digester);
   
       }
  -
  +    
  +    /**
  +     * Set the <code>Digester</code> with which this <code>Rule</code>
is associated.
  +     */
  +    public void setDigester(Digester digester) {
  +        
  +        this.digester = digester;
  +        
  +    }
   
       /**
        * Return the namespace URI for which this Rule is relevant, if any.
  
  
  
  1.10      +16 -4     jakarta-commons/digester/src/test/org/apache/commons/digester/RuleTestCase.java
  
  Index: RuleTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/RuleTestCase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RuleTestCase.java	23 Jan 2002 22:38:01 -0000	1.9
  +++ RuleTestCase.java	11 Mar 2002 20:18:45 -0000	1.10
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/RuleTestCase.java,v
1.9 2002/01/23 22:38:01 sanders Exp $
  - * $Revision: 1.9 $
  - * $Date: 2002/01/23 22:38:01 $
  + * $Header: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/RuleTestCase.java,v
1.10 2002/03/11 20:18:45 rdonkin Exp $
  + * $Revision: 1.10 $
  + * $Date: 2002/03/11 20:18:45 $
    *
    * ====================================================================
    *
  @@ -77,7 +77,7 @@
    *
    * @author Craig R. McClanahan
    * @author Janek Bogucki
  - * @version $Revision: 1.9 $ $Date: 2002/01/23 22:38:01 $
  + * @version $Revision: 1.10 $ $Date: 2002/03/11 20:18:45 $
    */
   
   public class RuleTestCase extends TestCase {
  @@ -504,6 +504,18 @@
   
       }
   
  +    /**
  +     * Test rule addition - this boils down to making sure that 
  +     * digester is set properly on rule addition.
  +     */
  +    public void testAddRule() {
  +        Digester digester = new Digester();
  +        TestRule rule =  new TestRule("Test");
  +        digester.addRule("/root", rule);
  +        
  +        assertEquals("Digester is not properly on rule addition.", digester, rule.getDigester());
  +
  +    }
   
       // ------------------------------------------------ Utility Support Methods
   
  
  
  
  1.7       +11 -3     jakarta-commons/digester/src/test/org/apache/commons/digester/TestRule.java
  
  Index: TestRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/TestRule.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestRule.java	23 Jan 2002 22:38:01 -0000	1.6
  +++ TestRule.java	11 Mar 2002 20:18:45 -0000	1.7
  @@ -70,7 +70,7 @@
    * at the identifier.</p>
    *
    * @author Robert Burrell Donkin
  - * @revision $Revision: 1.6 $ $Date: 2002/01/23 22:38:01 $
  + * @revision $Revision: 1.7 $ $Date: 2002/03/11 20:18:45 $
    */
   
   public class TestRule extends Rule {
  @@ -87,12 +87,20 @@
       /** Used when testing call orders */
       private List order;
   
  -
       // ----------------------------------------------------------- Constructors
   
  -
       /**
        * Base constructor.
  +     *
  +     * @param identifier Used to tell which TestRule is which
  +     */
  +    public TestRule(String identifier) {
  +        
  +        this.identifier = identifier;
  +    }
  +
  +    /**
  +     * Old fashioned constructor.
        *
        * @param digester The digester with which this rule is associated
        * @param identifier Used to tell which TestRule is which
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message