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 AlphaBean.java BetaBean.java Nameable.java Test4.xml RuleTestCase.java
Date Wed, 20 Mar 2002 20:28:28 GMT
rdonkin     02/03/20 12:28:28

  Modified:    digester RELEASE-NOTES.txt
               digester/src/java/org/apache/commons/digester Digester.java
                        SetNextRule.java SetRootRule.java SetTopRule.java
               digester/src/test/org/apache/commons/digester
                        RuleTestCase.java
  Added:       digester/src/test/org/apache/commons/digester AlphaBean.java
                        BetaBean.java Nameable.java Test4.xml
  Log:
  Added support for the more flexible method matching provided by MethodUtils.invokeMethod.
It is possible that in some (relative obscure) circumstances, the extra precision of the original
method is required and so a property has been added which allows the user to choose which
one to use. More flexible method matching is enabled by default (there is a slight possibility
that some existing code will be broken by this). Also created test cases.
  
  Revision  Changes    Path
  1.3       +7 -1      jakarta-commons/digester/RELEASE-NOTES.txt
  
  Index: RELEASE-NOTES.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/RELEASE-NOTES.txt,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RELEASE-NOTES.txt	12 Jan 2002 22:48:21 -0000	1.2
  +++ RELEASE-NOTES.txt	20 Mar 2002 20:28:28 -0000	1.3
  @@ -1,4 +1,4 @@
  -$Id: RELEASE-NOTES.txt,v 1.2 2002/01/12 22:48:21 sanders Exp $
  +$Id: RELEASE-NOTES.txt,v 1.3 2002/03/20 20:28:28 rdonkin Exp $
   
                             Commons Digester Package
                                   Version 1.2
  @@ -23,6 +23,12 @@
     will allow the Digester user to plug in their logging system.  Check out the
     Commons logging package for more information.
   
  +* More Flexible Method Matching. SetRootRule, SetNextRule and SetTopRule now 
  +  support more flexible method matching. This means that a matching method is
  +  more likely to be found but in some very specific circumstances it is possible
  +  that it will be less precise that the old matching method. The old behaviour 
  +  can be enabled by setting the ExactMatch property to true. See the java doc 
  +  comments for more details.
   
   BUG FIXES:
   
  
  
  
  1.49      +33 -4     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.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- Digester.java	11 Mar 2002 20:18:44 -0000	1.48
  +++ Digester.java	20 Mar 2002 20:28:28 -0000	1.49
  @@ -1,7 +1,7 @@
   /*
  - * $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 $
  + * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/Digester.java,v
1.49 2002/03/20 20:28:28 rdonkin Exp $
  + * $Revision: 1.49 $
  + * $Date: 2002/03/20 20:28:28 $
    *
    * ====================================================================
    *
  @@ -112,7 +112,7 @@
    *
    * @author Craig McClanahan
    * @author Scott Sanders
  - * @version $Revision: 1.48 $ $Date: 2002/03/11 20:18:44 $
  + * @version $Revision: 1.49 $ $Date: 2002/03/20 20:28:28 $
    */
   
   public class Digester extends DefaultHandler {
  @@ -1693,6 +1693,35 @@
   
       }
   
  +
  +    /**
  +     * Add {@link SetRootRule} with the specified parameters.
  +     *
  +     * @param pattern Element matching pattern
  +     * @param methodName Method name to call on the root object
  +     */
  +    public void addSetRoot(String pattern, String methodName) {
  +
  +        addRule(pattern,
  +                new SetRootRule(this, methodName));
  +
  +    }
  +
  +
  +    /**
  +     * Add {@link SetRootRule} with the specified parameters.
  +     *
  +     * @param pattern Element matching pattern
  +     * @param methodName Method name to call on the root object
  +     * @param paramType Java class name of the expected parameter type
  +     */
  +    public void addSetRoot(String pattern, String methodName,
  +                           String paramType) {
  +
  +        addRule(pattern,
  +                new SetRootRule(this, methodName, paramType));
  +
  +    }
   
       /**
        * Add a "set properties" rule for the specified parameters.
  
  
  
  1.12      +64 -8     jakarta-commons/digester/src/java/org/apache/commons/digester/SetNextRule.java
  
  Index: SetNextRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/SetNextRule.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SetNextRule.java	23 Jan 2002 21:25:22 -0000	1.11
  +++ SetNextRule.java	20 Mar 2002 20:28:28 -0000	1.12
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/SetNextRule.java,v
1.11 2002/01/23 21:25:22 sanders Exp $
  - * $Revision: 1.11 $
  - * $Date: 2002/01/23 21:25:22 $
  + * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/SetNextRule.java,v
1.12 2002/03/20 20:28:28 rdonkin Exp $
  + * $Revision: 1.12 $
  + * $Date: 2002/03/20 20:28:28 $
    *
    * ====================================================================
    *
  @@ -71,13 +71,18 @@
   
   
   /**
  - * Rule implementation that calls a method on the (top-1) (parent)
  + * <p>Rule implementation that calls a method on the (top-1) (parent)
    * object, passing the top object (child) as an argument.  It is
  - * commonly used to establish parent-child relationships.
  + * commonly used to establish parent-child relationships.</p>
  + *
  + * <p>This rule now supports more flexible method matching by default.
  + * It is possible that this may break (some) code 
  + * written against release 1.1.1 or earlier.
  + * See {@link #isExactMatch()} for more details.</p> 
    *
    * @author Craig McClanahan
    * @author Scott Sanders
  - * @version $Revision: 1.11 $ $Date: 2002/01/23 21:25:22 $
  + * @version $Revision: 1.12 $ $Date: 2002/03/20 20:28:28 $
    */
   
   public class SetNextRule extends Rule {
  @@ -135,11 +140,53 @@
        */
       protected String paramType = null;
   
  +    /**
  +     * Should we use exact matching? Default is no.
  +     */
  +    protected boolean useExactMatch = false;
   
       // --------------------------------------------------------- Public Methods
   
   
       /**
  +     * <p>Is exact matching being used?</p>
  +     *
  +     * <p>This rule uses <code>org.apache.commons.beanutils.MethodUtils</code>

  +     * to introspect the relevent objects so that the right method can be called.
  +     * Originally, <code>MethodUtils.invokeExactMethod</code> was used.
  +     * This matches methods very strictly 
  +     * and so may not find a matching method when one exists.
  +     * This is still the behaviour when exact matching is enabled.</p>
  +     *
  +     * <p>When exact matching is disabled, <code>MethodUtils.invokeMethod</code>
is used.
  +     * This method finds more methods but is less precise when there are several methods

  +     * with correct signatures.
  +     * So, if you want to choose an exact signature you might need to enable this property.</p>
  +     *
  +     * <p>The default setting is to disable exact matches.</p>
  +     *
  +     * @return true iff exact matching is enabled
  +     * @since Digester Release 1.1.1
  +     */
  +    public boolean isExactMatch() {
  +    
  +        return useExactMatch;
  +    }
  +    
  +    /**
  +     * <p>Set whether exact matching is enabled.</p>
  +     *
  +     * <p>See {@link #isExactMatch()}.</p>
  +     *
  +     * @param useExactMatch should this rule use exact method matching
  +     * @since Digester Release 1.1.1
  +     */    
  +    public void setExactMatch(boolean useExactMatch) {
  +
  +        this.useExactMatch = useExactMatch;
  +    }
  +
  +    /**
        * Process the end of this element.
        */
       public void end() throws Exception {
  @@ -167,9 +214,18 @@
           } else {
               paramTypes[0] = child.getClass();
           }
  -        MethodUtils.invokeExactMethod(parent, methodName,
  +        
  +        if (useExactMatch) {
  +        
  +            MethodUtils.invokeExactMethod(parent, methodName,
                   new Object[]{ child }, paramTypes);
  -
  +                
  +        } else {
  +        
  +            MethodUtils.invokeMethod(parent, methodName,
  +                new Object[]{ child }, paramTypes);
  +        
  +        }
       }
   
   
  
  
  
  1.4       +66 -7     jakarta-commons/digester/src/java/org/apache/commons/digester/SetRootRule.java
  
  Index: SetRootRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/SetRootRule.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SetRootRule.java	23 Jan 2002 21:25:22 -0000	1.3
  +++ SetRootRule.java	20 Mar 2002 20:28:28 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/SetRootRule.java,v
1.3 2002/01/23 21:25:22 sanders Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/01/23 21:25:22 $
  + * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/SetRootRule.java,v
1.4 2002/03/20 20:28:28 rdonkin Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/03/20 20:28:28 $
    *
    * ====================================================================
    *
  @@ -71,11 +71,17 @@
   
   
   /**
  - * Rule implementation that calls a method on the root object on the stack,
  + * <p>Rule implementation that calls a method on the root object on the stack,
    * passing the top object (child) as an argument.
  + * It is important to remember that this rule acts on <code>end</code>.</p>
  + *
  + * <p>This rule now supports more flexible method matching by default.
  + * It is possible that this may break (some) code 
  + * written against release 1.1.1 or earlier.
  + * See {@link #isExactMatch()} for more details.</p>
    *
    * @author Scott Sanders
  - * @version $Revision: 1.3 $ $Date: 2002/01/23 21:25:22 $
  + * @version $Revision: 1.4 $ $Date: 2002/03/20 20:28:28 $
    */
   
   public class SetRootRule extends Rule {
  @@ -132,12 +138,56 @@
        * The Java class name of the parameter type expected by the method.
        */
       protected String paramType = null;
  +    
  +    /**
  +     * Should we use exact matching? Default is no.
  +     */
  +    protected boolean useExactMatch = false;
   
   
       // --------------------------------------------------------- Public Methods
   
   
       /**
  +     * <p>Is exact matching being used?</p>
  +     *
  +     * <p>This rule uses <code>org.apache.commons.beanutils.MethodUtils</code>

  +     * to introspect the relevent objects so that the right method can be called.
  +     * Originally, <code>MethodUtils.invokeExactMethod</code> was used.
  +     * This matches methods very strictly 
  +     * and so may not find a matching method when one exists.
  +     * This is still the behaviour when exact matching is enabled.</p>
  +     *
  +     * <p>When exact matching is disabled, <code>MethodUtils.invokeMethod</code>
is used.
  +     * This method finds more methods but is less precise when there are several methods

  +     * with correct signatures.
  +     * So, if you want to choose an exact signature you might need to enable this property.</p>
  +     *
  +     * <p>The default setting is to disable exact matches.</p>
  +     *
  +     * @return true iff exact matching is enabled
  +     * @since Digester Release 1.1.1
  +     */
  +    public boolean isExactMatch() {
  +    
  +        return useExactMatch;
  +    }
  +    
  +    
  +    /**
  +     * <p>Set whether exact matching is enabled.</p>
  +     *
  +     * <p>See {@link #isExactMatch()}.</p>
  +     *
  +     * @param useExactMatch should this rule use exact method matching
  +     * @since Digester Release 1.1.1
  +     */
  +    public void setExactMatch(boolean useExactMatch) {
  +
  +        this.useExactMatch = useExactMatch;
  +    }
  +
  +    /**
        * Process the end of this element.
        */
       public void end() throws Exception {
  @@ -165,9 +215,18 @@
           } else {
               paramTypes[0] = child.getClass();
           }
  -        MethodUtils.invokeExactMethod(parent, methodName,
  +        
  +        if (useExactMatch) {
  +        
  +            MethodUtils.invokeExactMethod(parent, methodName,
                   new Object[]{ child }, paramTypes);
  -
  +                
  +        } else {
  +        
  +            MethodUtils.invokeMethod(parent, methodName,
  +                new Object[]{ child }, paramTypes);
  +        
  +        }
       }
   
   
  
  
  
  1.13      +65 -8     jakarta-commons/digester/src/java/org/apache/commons/digester/SetTopRule.java
  
  Index: SetTopRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/SetTopRule.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SetTopRule.java	27 Jan 2002 00:52:06 -0000	1.12
  +++ SetTopRule.java	20 Mar 2002 20:28:28 -0000	1.13
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/SetTopRule.java,v
1.12 2002/01/27 00:52:06 craigmcc Exp $
  - * $Revision: 1.12 $
  - * $Date: 2002/01/27 00:52:06 $
  + * $Header: /home/cvs/jakarta-commons/digester/src/java/org/apache/commons/digester/SetTopRule.java,v
1.13 2002/03/20 20:28:28 rdonkin Exp $
  + * $Revision: 1.13 $
  + * $Date: 2002/03/20 20:28:28 $
    *
    * ====================================================================
    *
  @@ -71,13 +71,18 @@
   
   
   /**
  - * Rule implementation that calls a "set parent" method on the top (child)
  - * object, passing the (top-1) (parent) object as an argument.
  + * <p>Rule implementation that calls a "set parent" method on the top (child)
  + * object, passing the (top-1) (parent) object as an argument.</p>
  + *
  + * <p>This rule now supports more flexible method matching by default.
  + * It is possible that this may break (some) code 
  + * written against release 1.1.1 or earlier.
  + * See {@link #isExactMatch()} for more details.</p>
    *
    * @author Craig McClanahan
    * @author Scott Sanders
    * @author Janek Bogucki
  - * @version $Revision: 1.12 $ $Date: 2002/01/27 00:52:06 $
  + * @version $Revision: 1.13 $ $Date: 2002/03/20 20:28:28 $
    */
   
   public class SetTopRule extends Rule {
  @@ -134,11 +139,53 @@
        * The Java class name of the parameter type expected by the method.
        */
       protected String paramType = null;
  +    
  +    /**
  +     * Should we use exact matching? Default is no.
  +     */
  +    protected boolean useExactMatch = false;
   
   
       // --------------------------------------------------------- Public Methods
   
  +    /**
  +     * <p>Is exact matching being used?</p>
  +     *
  +     * <p>This rule uses <code>org.apache.commons.beanutils.MethodUtils</code>

  +     * to introspect the relevent objects so that the right method can be called.
  +     * Originally, <code>MethodUtils.invokeExactMethod</code> was used.
  +     * This matches methods very strictly 
  +     * and so may not find a matching method when one exists.
  +     * This is still the behaviour when exact matching is enabled.</p>
  +     *
  +     * <p>When exact matching is disabled, <code>MethodUtils.invokeMethod</code>
is used.
  +     * This method finds more methods but is less precise when there are several methods

  +     * with correct signatures.
  +     * So, if you want to choose an exact signature you might need to enable this property.</p>
  +     *
  +     * <p>The default setting is to disable exact matches.</p>
  +     *
  +     * @return true iff exact matching is enabled
  +     * @since Digester Release 1.1.1
  +     */
  +    public boolean isExactMatch() {
  +    
  +        return useExactMatch;
  +    }
  +    
  +    /**
  +     * <p>Set whether exact matching is enabled.</p>
  +     *
  +     * <p>See {@link #isExactMatch()}.</p>
  +     *
  +     * @param useExactMatch should this rule use exact method matching
  +     * @since Digester Release 1.1.1
  +     */
  +    public void setExactMatch(boolean useExactMatch) {
   
  +        this.useExactMatch = useExactMatch;
  +    }
  +    
       /**
        * Process the end of this element.
        */
  @@ -147,6 +194,7 @@
           // Identify the objects to be used
           Object child = digester.peek(0);
           Object parent = digester.peek(1);
  +        
           if (digester.log.isDebugEnabled()) {
               if (child == null) {
                   digester.log.debug("[SetTopRule]{" + digester.match +
  @@ -167,9 +215,18 @@
           } else {
               paramTypes[0] = parent.getClass();
           }
  -        MethodUtils.invokeExactMethod(child, methodName,
  -                new Object[]{ parent }, paramTypes);
   
  +        if (useExactMatch) {
  +        
  +            MethodUtils.invokeExactMethod(child, methodName,
  +                new Object[]{ parent }, paramTypes);
  +                
  +        } else {
  +        
  +            MethodUtils.invokeMethod(child, methodName,
  +                new Object[]{ parent }, paramTypes);
  +        
  +        }
       }
   
   
  
  
  
  1.11      +82 -5     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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- RuleTestCase.java	11 Mar 2002 20:18:45 -0000	1.10
  +++ RuleTestCase.java	20 Mar 2002 20:28:28 -0000	1.11
  @@ -1,7 +1,7 @@
   /*
  - * $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 $
  + * $Header: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/RuleTestCase.java,v
1.11 2002/03/20 20:28:28 rdonkin Exp $
  + * $Revision: 1.11 $
  + * $Date: 2002/03/20 20:28:28 $
    *
    * ====================================================================
    *
  @@ -66,6 +66,8 @@
   import java.io.IOException;
   import java.io.InputStream;
   
  +import java.util.ArrayList;
  +
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
  @@ -77,7 +79,7 @@
    *
    * @author Craig R. McClanahan
    * @author Janek Bogucki
  - * @version $Revision: 1.10 $ $Date: 2002/03/11 20:18:45 $
  + * @version $Revision: 1.11 $ $Date: 2002/03/20 20:28:28 $
    */
   
   public class RuleTestCase extends TestCase {
  @@ -516,6 +518,82 @@
           assertEquals("Digester is not properly on rule addition.", digester, rule.getDigester());
   
       }
  +    
  +
  +    public void testSetNext() throws Exception {
  +        Digester digester = new Digester();
  +        digester.setRules(new ExtendedBaseRules());
  +        digester.setValidating(false);
  +        
  +        
  +        digester.addObjectCreate("!*/b", BetaBean.class);
  +        digester.addObjectCreate("!*/a", AlphaBean.class);
  +        digester.addObjectCreate("root", ArrayList.class);
  +        digester.addSetProperties("!*");
  +        digester.addSetNext("!*/b/?", "setChild");
  +        digester.addSetNext("!*/a/?", "setChild");
  +        digester.addSetNext("!root/?", "add");
  +        ArrayList root = (ArrayList) digester.parse(getInputStream("Test4.xml"));
  +        
  +        assertEquals("Wrong array size", 2, root.size());
  +        AlphaBean one = (AlphaBean) root.get(0);
  +        assertTrue(one.getChild() instanceof BetaBean);
  +        BetaBean two = (BetaBean) one.getChild();
  +        assertEquals("Wrong name (1)", two.getName() , "TWO");
  +        assertTrue(two.getChild() instanceof AlphaBean);
  +        AlphaBean three = (AlphaBean) two.getChild(); 
  +        assertEquals("Wrong name (2)", three.getName() , "THREE");       
  +        BetaBean four = (BetaBean) root.get(1);
  +        assertEquals("Wrong name (3)", four.getName() , "FOUR");
  +        assertTrue(four.getChild() instanceof BetaBean);
  +        BetaBean five = (BetaBean) four.getChild(); 
  +        assertEquals("Wrong name (4)", five.getName() , "FIVE");               
  +        
  +    }
  +    
  +    
  +    public void testSetTop() throws Exception {
  +        Digester digester = new Digester();
  +        digester.setRules(new ExtendedBaseRules());
  +        digester.setValidating(false);
  +        
  +        
  +        digester.addObjectCreate("!*/b", BetaBean.class);
  +        digester.addObjectCreate("!*/a", AlphaBean.class);
  +        digester.addObjectCreate("root", ArrayList.class);
  +        digester.addSetProperties("!*");
  +        digester.addSetTop("!*/b/?", "setParent");
  +        digester.addSetTop("!*/a/?", "setParent");
  +        digester.addSetRoot("!*/a", "add");
  +        digester.addSetRoot("!*/b", "add");
  +        ArrayList root = (ArrayList) digester.parse(getInputStream("Test4.xml"));
  +        
  +        assertEquals("Wrong array size", 5, root.size());
  +        
  +        // note that the array is in popped order (rather than pushed)
  +        
  +        Object obj = root.get(1);
  +        assertTrue("TWO should be a BetaBean", obj instanceof BetaBean);
  +        BetaBean two = (BetaBean) obj;
  +        assertNotNull("Two's parent should not be null", two.getParent());
  +        assertEquals("Wrong name (1)", "TWO", two.getName());
  +        assertEquals("Wrong name (2)", "ONE", two.getParent().getName() );
  +        
  +        obj = root.get(0);
  +        assertTrue("THREE should be an AlphaBean", obj instanceof AlphaBean);
  +        AlphaBean three = (AlphaBean) obj;
  +        assertNotNull("Three's parent should not be null", three.getParent());
  +        assertEquals("Wrong name (3)", "THREE", three.getName());
  +        assertEquals("Wrong name (4)", "TWO", three.getParent().getName());
  +        
  +        obj = root.get(3);
  +        assertTrue("FIVE should be a BetaBean", obj instanceof BetaBean);
  +        BetaBean five = (BetaBean) obj;
  +        assertNotNull("Five's parent should not be null", five.getParent());
  +        assertEquals("Wrong name (5)", "FIVE", five.getName());
  +        assertEquals("Wrong name (6)", "FOUR", five.getParent().getName());
  +
  +    }
   
       // ------------------------------------------------ Utility Support Methods
   
  @@ -580,6 +658,5 @@
                   office.getZipCode());
   
       }
  -
   
   }
  
  
  
  1.1                  jakarta-commons/digester/src/test/org/apache/commons/digester/AlphaBean.java
  
  Index: AlphaBean.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/AlphaBean.java,v
1.1 2002/03/20 20:28:28 rdonkin Exp $
   * $Revision: 1.1 $
   * $Date: 2002/03/20 20:28:28 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.digester;
  
  public class AlphaBean implements Nameable {
      private String name = "ALPHA";
      
      private Nameable child;
      private Nameable parent;
  
      public AlphaBean() {}
      
      public AlphaBean(String name) {
          setName(name);
      }
      
      public String getName() {
          return name;
      }
      
      public void setName(String name) {
          this.name = name;
      }
  
      public void setParent(Nameable parent) {
          this.parent = parent;
      }
      
      public Nameable getParent() {
          return parent;
      }
      
      public void setChild(Nameable child) {
          this.child = child;
      }
  
      public Nameable getChild() {
          return child;
      }
      
      public String toString()
      {
          return "[AlphaBean] name=" + name + " child=" + child;
      }
  }
  
  
  
  1.1                  jakarta-commons/digester/src/test/org/apache/commons/digester/BetaBean.java
  
  Index: BetaBean.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/BetaBean.java,v
1.1 2002/03/20 20:28:28 rdonkin Exp $
   * $Revision: 1.1 $
   * $Date: 2002/03/20 20:28:28 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.digester;
  
  public class BetaBean implements Nameable {
      private String name = "BETA";
      
      private Nameable child;
      private Nameable parent;
  
      public BetaBean() {}
      
      public String getName() {
          return name;
      }
      
      public void setName(String name) {
          this.name = name;
      }
      
      public void setParent(Nameable parent) {
          this.parent = parent;
      }
      
      public Nameable getParent() {
          return parent;
      }
      
      public void setChild(Nameable child) {
          this.child = child;
      }
      
      public Nameable getChild() {
          return child;
      }
      
      public String toString()
      {
          return "[BetaBean] name=" + name + " child=" + child;
      }
  }
  
  
  
  1.1                  jakarta-commons/digester/src/test/org/apache/commons/digester/Nameable.java
  
  Index: Nameable.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/Nameable.java,v
1.1 2002/03/20 20:28:28 rdonkin Exp $
   * $Revision: 1.1 $
   * $Date: 2002/03/20 20:28:28 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.digester;
  
  /**
   * Interface used for testing.
   */
  public interface Nameable  {
      String getName();    
      void setName(String name);
  }
  
  
  
  1.1                  jakarta-commons/digester/src/test/org/apache/commons/digester/Test4.xml
  
  Index: Test4.xml
  ===================================================================
  <?xml version="1.0"?>
  <root>
      <a name="ONE">
          <b name="TWO">
              <a name="THREE"/>
          </b>
      </a>
      <b name="FOUR">
          <b name="FIVE"/>
      </b>
  </root>
  
  

--
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