You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rd...@apache.org on 2004/01/20 23:59:57 UTC

cvs commit: jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester AddDefaultsRule.java

rdonkin     2004/01/20 14:59:57

  Modified:    betwixt/src/java/org/apache/commons/betwixt/digester Tag:
                        REFACTORING-BRANCH_2004-01-13 AddDefaultsRule.java
  Log:
  Added support for setting adders in betwixt file without setting properties . Patch contributed by Brian Pugh
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.9.2.4   +43 -9     jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java
  
  Index: AddDefaultsRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/AddDefaultsRule.java,v
  retrieving revision 1.9.2.3
  retrieving revision 1.9.2.4
  diff -u -r1.9.2.3 -r1.9.2.4
  --- AddDefaultsRule.java	18 Jan 2004 19:21:17 -0000	1.9.2.3
  +++ AddDefaultsRule.java	20 Jan 2004 22:59:57 -0000	1.9.2.4
  @@ -101,6 +101,45 @@
        * @throws Exception generally this will indicate an unrecoverable error 
        */
       public void begin(String name, String namespace, Attributes attributes) throws Exception {
  +        boolean addProperties = true;
  +        String addPropertiesAttributeValue = attributes.getValue("add-properties");
  +        if (addPropertiesAttributeValue != null)
  +        {
  +            addProperties = Boolean.valueOf(addPropertiesAttributeValue).booleanValue();
  +        }
  +        
  +        boolean addAdders = true;
  +        String addAddersAttributeValue = attributes.getValue("add-adders");
  +        if (addAddersAttributeValue != null)
  +        {
  +            addProperties = Boolean.valueOf(addAddersAttributeValue).booleanValue();
  +        }
  +        
  +        if (addProperties) {
  +            addDefaultProperties();
  +        }
  +        
  +        if (addAdders) {
  +            addAdders();
  +        }
  +    }
  +
  +    /**
  +     * Adds default adder methods
  +     */
  +    private void addAdders() {
  +        Class beanClass = getBeanClass();
  +        // default any addProperty() methods
  +        getXMLIntrospector().defaultAddMethods( 
  +                                            getRootElementDescriptor(), 
  +                                            beanClass );
  +    }
  +
  +    /**
  +     * Adds default property methods
  +     *
  +     */
  +    private void addDefaultProperties() {
           Class beanClass = getBeanClass();
           Set processedProperties = getProcessedPropertyNameSet();
           if ( beanClass != null ) {
  @@ -127,11 +166,6 @@
                   log.info( "Caught introspection exception", e );
               }
           }
  -        
  -        // default any addProperty() methods
  -        getXMLIntrospector().defaultAddMethods( 
  -                                            getRootElementDescriptor(), 
  -                                            beanClass );
       }
   
   
  
  
  

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