On Tue, 2002-05-28 at 09:38, [EMAIL PROTECTED] wrote:
> jstrachan    02/05/28 06:38:27
> 
>   Modified:    betwixt/src/test/org/apache/commons/betwixt
>                         TestMavenProject.java
>                betwixt  build.xml .cvsignore
>                betwixt/src/java/org/apache/commons/betwixt
>                         XMLIntrospector.java
>                betwixt/src/java/org/apache/commons/betwixt/digester
>                         AddDefaultsRule.java RuleSupport.java
>                         XMLIntrospectorHelper.java
>   Added:       betwixt/src/java/org/apache/commons/betwixt/strategy
>                         package.html DefaultPluralStemmer.java
>                         PluralStemmer.java
>   Log:
>   Added support for a pluggable Strategy for matching plural properties with 
>singular adder methods. 
>   
>   The default implementation seems to work for Maven's immediate requirements (or at 
>least I've not found a case where it doesn't work ;-).
>   It should be easy to plugin more comprehensive / complex strategies later on.
>   
>   Right now betwixt is close to being able to round trip Maven's Project object 
>model; just need configurable extra wrapping elements around collections for 
>Turbine/Maven style XML documents.
>

Cool!!!

James can we call this version of betwixt 0.3 or something like that
instead of the 1.0-dev name. I would like to cut a little release so
that I can integrate betwixt into maven with a uniquely identified
version.

>   Revision  Changes    Path
>   1.2       +21 -0     
>jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/TestMavenProject.java
>   
>   Index: TestMavenProject.java
>   ===================================================================
>   RCS file: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/TestMavenProject.java,v
>   retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- TestMavenProject.java   28 May 2002 11:49:29 -0000      1.1
>   +++ TestMavenProject.java   28 May 2002 13:38:26 -0000      1.2
>   @@ -68,6 +68,7 @@
>    import java.io.StringWriter;
>    import java.io.Writer;
>    import java.net.URL;
>   +import java.util.List;
>    
>    import junit.framework.Test;
>    import junit.framework.TestCase;
>   @@ -77,6 +78,8 @@
>    import org.apache.commons.betwixt.io.BeanReader;
>    import org.apache.commons.betwixt.io.BeanWriter;
>    
>   +import org.apache.maven.project.Dependency;
>   +import org.apache.maven.project.Developer;
>    import org.apache.maven.project.Project;
>    
>    import org.apache.commons.logging.Log;
>   @@ -112,6 +115,9 @@
>            // create a BeanReader
>            BeanReader reader = new BeanReader();
>            
>   +        // set elements for attributes to true
>   +        reader.getXMLIntrospector().setAttributesForPrimitives(false);
>   +        
>            // #### remove the need to name the element, via a lower-case-naming 
>strategy
>            reader.registerBeanClass( "project", Project.class );
>    
>   @@ -123,6 +129,21 @@
>            assertEquals( "commons-betwixt", project.getId() );
>            assertEquals( "org.apache.commons.betwixt", project.getPackage() );
>            assertEquals( "jakarta.apache.org", project.getSiteAddress() );
>   +        
>   +        List developers = project.getDevelopers();
>   +        assertTrue( "Found at least one developer", developers.size() > 0 );
>   +        
>   +        Developer developer = (Developer) developers.get(0);
>   +        assertEquals( "James Strachan", developer.getName() );
>   +        assertEquals( "[EMAIL PROTECTED]", developer.getEmail() );
>   +        
>   +        List dependencies = project.getDependencies();
>   +        assertTrue( "Found at least one dependency", dependencies.size() > 0 );
>   +        
>   +        Dependency dependency = (Dependency) dependencies.get(0);
>   +        assertEquals( "commons-logging", dependency.getName() );
>   +        assertEquals( "required", dependency.getType() );
>   +        
>        }        
>            
>    /*        
>   
>   
>   
>   1.1                  
>jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/strategy/package.html
>   
>   Index: package.html
>   ===================================================================
>   <html>
>   <head>
>   </head>
>   <body>
>   
>     <p>This package contains a variety of plugin Strategy patterns that can be used 
>to customize the
>     default behaviour.of the XMLIntrospector
>     </p>
>     
>   </body>
>   </html>
>   
>   
>   
>   1.1                  
>jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/strategy/DefaultPluralStemmer.java
>   
>   Index: DefaultPluralStemmer.java
>   ===================================================================
>   /*
>    * $Header: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/NodeDescriptor.java,v
> 1.8 2002/05/17 15:24:09 jstrachan Exp $
>    * $Revision: 1.8 $
>    * $Date: 2002/05/17 15:24:09 $
>    *
>    * ====================================================================
>    *
>    * 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 [EMAIL PROTECTED]
>    *
>    * 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/>.
>    * 
>    * $Id: NodeDescriptor.java,v 1.8 2002/05/17 15:24:09 jstrachan Exp $
>    */
>   package org.apache.commons.betwixt.strategy;
>   
>   /** 
>    * A default implementation of the plural name stemmer which
>    * uses a simple starts-with algorithm and then tests for some common
>    * english plural/singular patterns.
>    * 
>    * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
>    * @version $Revision: 1.8 $
>    */
>   public class DefaultPluralStemmer implements PluralStemmer {
>   
>       /**
>        * @return true if the given plural name matches the singular name
>        */
>       public boolean isPluralNameFor(String pluralName, String singularName) {
>           if ( pluralName.startsWith( singularName ) ) {
>               return true;
>           }
>           
>           // test for common english singlular/plural endings
>           if ( pluralName.endsWith( "ies" ) && singularName.endsWith( "y" ) ) {
>               String pluralStart = pluralName.substring(0, pluralName.length() - 3 
>); 
>               String singularStart = singularName.substring(0, singularName.length() 
>- 1 ); 
>               if ( pluralStart.equals( singularStart ) ) {
>                   return true;
>               }
>           }
>   
>           // None of the tests detected a plural
>           return false;
>       }
>   
>   }
>   
>   
>   
>   1.1                  
>jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/strategy/PluralStemmer.java
>   
>   Index: PluralStemmer.java
>   ===================================================================
>   /*
>    * $Header: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/NodeDescriptor.java,v
> 1.8 2002/05/17 15:24:09 jstrachan Exp $
>    * $Revision: 1.8 $
>    * $Date: 2002/05/17 15:24:09 $
>    *
>    * ====================================================================
>    *
>    * 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 [EMAIL PROTECTED]
>    *
>    * 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/>.
>    * 
>    * $Id: NodeDescriptor.java,v 1.8 2002/05/17 15:24:09 jstrachan Exp $
>    */
>   package org.apache.commons.betwixt.strategy;
>   
>   /** 
>    * A plugin Strategy pattern for detecting matching singular and plural
>    * names on bean properties. When composite properties (such as properties
>    * of type Collection, List, Iterator, Enumeration) are used we need to
>    * match the adder-method, which typically uses a singular name.
>    * This interface allows a variety of different implementations to be used.
>    * 
>    * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
>    * @version $Revision: 1.8 $
>    */
>   public interface PluralStemmer {
>   
>       /**
>        * @return true if the given plural name matches the singular name
>        */
>       boolean isPluralNameFor(String pluralName, String singularName);
>   
>   }
>   
>   
>   
>   1.18      +4 -4      jakarta-commons-sandbox/betwixt/build.xml
>   
>   Index: build.xml
>   ===================================================================
>   RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/build.xml,v
>   retrieving revision 1.17
>   retrieving revision 1.18
>   diff -u -r1.17 -r1.18
>   --- build.xml       28 May 2002 11:49:29 -0000      1.17
>   +++ build.xml       28 May 2002 13:38:26 -0000      1.18
>   @@ -1,6 +1,6 @@
>    <?xml version="1.0"?>
>    
>   -<!-- $Id: build.xml,v 1.17 2002/05/28 11:49:29 jstrachan Exp $ -->
>   +<!-- $Id: build.xml,v 1.18 2002/05/28 13:38:26 jstrachan Exp $ -->
>    <project name="betwixt" default="maven:jar" basedir=".">
>    
>    
>   @@ -247,14 +247,14 @@
>       </target>
>    
>       <target name="test.maven"
>   -      description="Runs the RSS round trip unit tests">
>   +      description="Runs the Maven unit test">
>       <property name="maven.testcase" 
>value="org.apache.commons.betwixt.TestMavenProject"/>   
>       <maven-ant antfile="${maven.home}/plugins/test/build.xml" 
>target="run-singletest"/>
>       </target>
>    
>    
>   -   <target name="test.maven2" depends="compile.tests" 
>   -      description="Runs the RSS round trip unit tests">
>   +   <target name="test.maven.debug" depends="compile.tests" 
>   +      description="Runs the Maven unit test, with debugging on">
>        <java classname="org.apache.commons.betwixt.TestMavenProject" fork="yes">
>          <classpath refid="test.classpath"/>
>          <sysproperty key="org.apache.commons.logging.simplelog.defaultlog" 
>value="debug"/>
>   
>   
>   
>   1.3       +1 -0      jakarta-commons-sandbox/betwixt/.cvsignore
>   
>   Index: .cvsignore
>   ===================================================================
>   RCS file: /home/cvs/jakarta-commons-sandbox/betwixt/.cvsignore,v
>   retrieving revision 1.2
>   retrieving revision 1.3
>   diff -u -r1.2 -r1.3
>   --- .cvsignore      22 May 2002 18:13:40 -0000      1.2
>   +++ .cvsignore      28 May 2002 13:38:26 -0000      1.3
>   @@ -4,3 +4,4 @@
>    velocity.log
>    .project
>    
>   +foo.txt
>   
>   
>   
>   1.23      +47 -9     
>jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java
>   
>   Index: XMLIntrospector.java
>   ===================================================================
>   RCS file: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v
>   retrieving revision 1.22
>   retrieving revision 1.23
>   diff -u -r1.22 -r1.23
>   --- XMLIntrospector.java    17 May 2002 15:24:09 -0000      1.22
>   +++ XMLIntrospector.java    28 May 2002 13:38:26 -0000      1.23
>   @@ -1,7 +1,7 @@
>    /*
>   - * $Header: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v
> 1.22 2002/05/17 15:24:09 jstrachan Exp $
>   - * $Revision: 1.22 $
>   - * $Date: 2002/05/17 15:24:09 $
>   + * $Header: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v
> 1.23 2002/05/28 13:38:26 jstrachan Exp $
>   + * $Revision: 1.23 $
>   + * $Date: 2002/05/28 13:38:26 $
>     *
>     * ====================================================================
>     *
>   @@ -57,7 +57,7 @@
>     * information on the Apache Software Foundation, please see
>     * <http://www.apache.org/>.
>     * 
>   - * $Id: XMLIntrospector.java,v 1.22 2002/05/17 15:24:09 jstrachan Exp $
>   + * $Id: XMLIntrospector.java,v 1.23 2002/05/28 13:38:26 jstrachan Exp $
>     */
>    package org.apache.commons.betwixt;
>    
>   @@ -91,6 +91,8 @@
>    import org.apache.commons.betwixt.expression.StringExpression;
>    import org.apache.commons.betwixt.digester.XMLBeanInfoDigester;
>    import org.apache.commons.betwixt.digester.XMLIntrospectorHelper;
>   +import org.apache.commons.betwixt.strategy.DefaultPluralStemmer;
>   +import org.apache.commons.betwixt.strategy.PluralStemmer;
>    
>    /** <p><code>XMLIntrospector</code> an introspector of beans to create a 
>XMLBeanInfo instance.</p>
>      *
>   @@ -100,20 +102,28 @@
>      * Later requests for the same class will return the cached value.</p>
>      *
>      * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
>   -  * @version $Revision: 1.22 $
>   +  * @version $Revision: 1.23 $
>      */
>    public class XMLIntrospector {
>    
>   +    /** Log used for logging (Doh!) */    
>   +    protected Log log = LogFactory.getLog( XMLIntrospector.class );
>   +    
>        /** should attributes or elements be used for primitive types */
>        private boolean attributesForPrimitives = false;
>   -    /** Log used for logging (Doh!) */
>   -    protected Log log = LogFactory.getLog( XMLIntrospector.class );
>   +    
>        /** Maps classes to <code>XMLBeanInfo</code>'s */
>        protected HashMap cacheXMLBeanInfos = new HashMap();
>   +    
>        /** Is <code>XMLBeanInfo</code> caching enabled? */
>        boolean cachingEnabled = true;
>   +    
>        /** Digester used to parse the XML descriptor files */
>        private XMLBeanInfoDigester digester;
>   +    
>   +    /** The strategy used to detect matching singular and plural properties */
>   +    private PluralStemmer pluralStemmer;
>   +    
>        /** Base constructor */
>        public XMLIntrospector() {
>        }
>   @@ -261,10 +271,14 @@
>            answer.setElementDescriptor( elementDescriptor );        
>            
>            // default any addProperty() methods
>   -        XMLIntrospectorHelper.defaultAddMethods( elementDescriptor, beanClass );
>   +        XMLIntrospectorHelper.defaultAddMethods( this, elementDescriptor, 
>beanClass );
>            
>            return answer;
>        }
>   +
>   +
>   +    // Properties
>   +    //-------------------------------------------------------------------------   
>     
>        
>        /** Should attributes (or elements) be used for primitive types.
>         */
>   @@ -277,9 +291,33 @@
>            this.attributesForPrimitives = attributesForPrimitives;
>        }
>    
>   +    /** 
>   +     * @return the strategy used to detect matching singular and plural 
>properties 
>   +     */
>   +    public PluralStemmer getPluralStemmer() {
>   +        if ( pluralStemmer == null ) {
>   +            pluralStemmer = createPluralStemmer();
>   +        }
>   +        return pluralStemmer;
>   +    }
>   +    
>   +    /** 
>   +     * Sets the strategy used to detect matching singular and plural properties 
>   +     */
>   +    public void setPluralStemmer(PluralStemmer pluralStemmer) {
>   +        this.pluralStemmer = pluralStemmer;
>   +    }
>   +
>        
>        // Implementation methods
>   -    //-------------------------------------------------------------------------   
> 
>   +    //-------------------------------------------------------------------------   
>     
>   +    
>   +    /** 
>   +     * A Factory method to lazily create a new strategy to detect matching 
>singular and plural properties 
>   +     */
>   +    protected PluralStemmer createPluralStemmer() {
>   +        return new DefaultPluralStemmer();
>   +    }
>        
>        /** 
>         * Attempt to lookup the XML descriptor for the given class using the
>   
>   
>   
>   1.5       +6 -6      
>jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java
>   
>   Index: AddDefaultsRule.java
>   ===================================================================
>   RCS file: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java,v
>   retrieving revision 1.4
>   retrieving revision 1.5
>   diff -u -r1.4 -r1.5
>   --- AddDefaultsRule.java    17 May 2002 15:24:12 -0000      1.4
>   +++ AddDefaultsRule.java    28 May 2002 13:38:26 -0000      1.5
>   @@ -1,7 +1,7 @@
>    /*
>   - * $Header: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java,v
> 1.4 2002/05/17 15:24:12 jstrachan Exp $
>   - * $Revision: 1.4 $
>   - * $Date: 2002/05/17 15:24:12 $
>   + * $Header: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java,v
> 1.5 2002/05/28 13:38:26 jstrachan Exp $
>   + * $Revision: 1.5 $
>   + * $Date: 2002/05/28 13:38:26 $
>     *
>     * ====================================================================
>     *
>   @@ -57,7 +57,7 @@
>     * information on the Apache Software Foundation, please see
>     * <http://www.apache.org/>.
>     * 
>   - * $Id: AddDefaultsRule.java,v 1.4 2002/05/17 15:24:12 jstrachan Exp $
>   + * $Id: AddDefaultsRule.java,v 1.5 2002/05/28 13:38:26 jstrachan Exp $
>     */
>    package org.apache.commons.betwixt.digester;
>    
>   @@ -87,7 +87,7 @@
>      * to the current element.</p>
>      *
>      * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
>   -  * @version $Revision: 1.4 $
>   +  * @version $Revision: 1.5 $
>      */
>    public class AddDefaultsRule extends RuleSupport {
>    
>   @@ -138,7 +138,7 @@
>            }
>            
>            // default any addProperty() methods
>   -        XMLIntrospectorHelper.defaultAddMethods( getRootElementDescriptor(), 
>beanClass );
>   +        XMLIntrospectorHelper.defaultAddMethods( getXMLIntrospector(), 
>getRootElementDescriptor(), beanClass );
>        }
>    
>    
>   
>   
>   
>   1.3       +9 -5      
>jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/RuleSupport.java
>   
>   Index: RuleSupport.java
>   ===================================================================
>   RCS file: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/RuleSupport.java,v
>   retrieving revision 1.2
>   retrieving revision 1.3
>   diff -u -r1.2 -r1.3
>   --- RuleSupport.java        17 May 2002 15:24:12 -0000      1.2
>   +++ RuleSupport.java        28 May 2002 13:38:26 -0000      1.3
>   @@ -1,7 +1,7 @@
>    /*
>   - * $Header: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/RuleSupport.java,v
> 1.2 2002/05/17 15:24:12 jstrachan Exp $
>   - * $Revision: 1.2 $
>   - * $Date: 2002/05/17 15:24:12 $
>   + * $Header: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/RuleSupport.java,v
> 1.3 2002/05/28 13:38:26 jstrachan Exp $
>   + * $Revision: 1.3 $
>   + * $Date: 2002/05/28 13:38:26 $
>     *
>     * ====================================================================
>     *
>   @@ -57,7 +57,7 @@
>     * information on the Apache Software Foundation, please see
>     * <http://www.apache.org/>.
>     * 
>   - * $Id: RuleSupport.java,v 1.2 2002/05/17 15:24:12 jstrachan Exp $
>   + * $Id: RuleSupport.java,v 1.3 2002/05/28 13:38:26 jstrachan Exp $
>     */
>    package org.apache.commons.betwixt.digester;
>    
>   @@ -89,7 +89,7 @@
>      * helper methods.</p>
>      *
>      * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
>   -  * @version $Revision: 1.2 $
>   +  * @version $Revision: 1.3 $
>      */
>    public class RuleSupport extends Rule {
>    
>   @@ -106,6 +106,10 @@
>        //-------------------------------------------------------------------------   
> 
>        protected XMLBeanInfoDigester getXMLInfoDigester() {
>            return (XMLBeanInfoDigester) getDigester();
>   +    }
>   +    
>   +    protected XMLIntrospector getXMLIntrospector() {
>   +        return getXMLInfoDigester().getXMLIntrospector();
>        }
>        
>        protected Class getBeanClass() {
>   
>   
>   
>   1.5       +17 -13    
>jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java
>   
>   Index: XMLIntrospectorHelper.java
>   ===================================================================
>   RCS file: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java,v
>   retrieving revision 1.4
>   retrieving revision 1.5
>   diff -u -r1.4 -r1.5
>   --- XMLIntrospectorHelper.java      17 May 2002 15:24:12 -0000      1.4
>   +++ XMLIntrospectorHelper.java      28 May 2002 13:38:26 -0000      1.5
>   @@ -1,7 +1,7 @@
>    /*
>   - * $Header: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java,v
> 1.4 2002/05/17 15:24:12 jstrachan Exp $
>   - * $Revision: 1.4 $
>   - * $Date: 2002/05/17 15:24:12 $
>   + * $Header: 
>/home/cvs/jakarta-commons-sandbox/betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java,v
> 1.5 2002/05/28 13:38:26 jstrachan Exp $
>   + * $Revision: 1.5 $
>   + * $Date: 2002/05/28 13:38:26 $
>     *
>     * ====================================================================
>     *
>   @@ -57,7 +57,7 @@
>     * information on the Apache Software Foundation, please see
>     * <http://www.apache.org/>.
>     * 
>   - * $Id: XMLIntrospectorHelper.java,v 1.4 2002/05/17 15:24:12 jstrachan Exp $
>   + * $Id: XMLIntrospectorHelper.java,v 1.5 2002/05/28 13:38:26 jstrachan Exp $
>     */
>    package org.apache.commons.betwixt.digester;
>    
>   @@ -86,18 +86,20 @@
>    import org.apache.commons.betwixt.ElementDescriptor;
>    import org.apache.commons.betwixt.NodeDescriptor;
>    import org.apache.commons.betwixt.XMLBeanInfo;
>   +import org.apache.commons.betwixt.XMLIntrospector;
>    import org.apache.commons.betwixt.expression.EmptyExpression;
>    import org.apache.commons.betwixt.expression.Expression;
>    import org.apache.commons.betwixt.expression.IteratorExpression;
>    import org.apache.commons.betwixt.expression.MethodExpression;
>    import org.apache.commons.betwixt.expression.MethodUpdater;
>    import org.apache.commons.betwixt.expression.StringExpression;
>   +import org.apache.commons.betwixt.strategy.PluralStemmer;
>    
>    /** <p><code>XMLIntrospectorHelper</code> a helper class for 
>      * common code shared between the digestor and introspector.</p>
>      *
>      * @author <a href="mailto:[EMAIL PROTECTED]";>James Strachan</a>
>   -  * @version $Revision: 1.4 $
>   +  * @version $Revision: 1.5 $
>      */
>    public class XMLIntrospectorHelper {
>    
>   @@ -311,7 +313,7 @@
>         * the string. This should work for most use cases. 
>         * e.g. addChild() would match the children property.
>         */
>   -    public static void defaultAddMethods( ElementDescriptor rootDescriptor, Class 
>beanClass ) {
>   +    public static void defaultAddMethods( XMLIntrospector introspector, 
>ElementDescriptor rootDescriptor, Class beanClass ) {
>            // lets iterate over all methods looking for one of the form
>            // add*(PropertyType)
>            if ( beanClass != null ) {
>   @@ -330,7 +332,7 @@
>                            // a property which starts with propertyName
>                            // and if so, we'll set a new Updater on it if there
>                            // is not one already
>   -                        ElementDescriptor descriptor = 
>findGetCollectionDescriptor( rootDescriptor, propertyName );
>   +                        ElementDescriptor descriptor = 
>findGetCollectionDescriptor( introspector, rootDescriptor, propertyName );
>                            if ( descriptor != null ) {
>                                if ( descriptor.getUpdater() == null ) {
>                                    if ( log.isDebugEnabled() ) {
>   @@ -390,16 +392,19 @@
>         * to match. e.g. if an addChild() method is detected the 
>         * descriptor for the 'children' getter property should be returned.
>         */
>   -    protected static ElementDescriptor findGetCollectionDescriptor( 
>ElementDescriptor rootDescriptor, String propertyName ) {
>   +    protected static ElementDescriptor findGetCollectionDescriptor( 
>XMLIntrospector introspector, ElementDescriptor rootDescriptor, String propertyName ) 
>{
>   +        PluralStemmer stemmer = introspector.getPluralStemmer();
>            ElementDescriptor[] children = rootDescriptor.getElementDescriptors();
>            if ( children != null ) {
>                for ( int i = 0, size = children.length; i < size; i++ ) {
>                    ElementDescriptor child = children[i];
>   -                String childPropertyName = child.getPropertyName();
>   -                if ( childPropertyName != null && childPropertyName.startsWith( 
>propertyName ) ) {
>   -                    return child;
>   +                String childPropertyName = child.getPropertyName();               
> 
>   +                if ( childPropertyName != null ) {
>   +                    if ( stemmer.isPluralNameFor(childPropertyName, propertyName) 
>) {
>   +                        return child;
>   +                    }
>                    }
>   -                ElementDescriptor answer = findGetCollectionDescriptor( child, 
>propertyName );
>   +                ElementDescriptor answer = findGetCollectionDescriptor( 
>introspector, child, propertyName );
>                    if ( answer != null ) {
>                        return answer;
>                    }
>   @@ -407,5 +412,4 @@
>            }
>            return null;
>        }
>   -    
>    }
>   
>   
>   
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
-- 
jvz.

Jason van Zyl
[EMAIL PROTECTED]

http://tambora.zenplex.org


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to