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/betwixt/src/java/org/apache/commons/betwixt/digester AddDefaultsRule.java TextRule.java XMLIntrospectorHelper.java
Date Sun, 13 Jul 2003 21:28:10 GMT
rdonkin     2003/07/13 14:28:10

  Modified:    betwixt/src/java/org/apache/commons/betwixt/digester
                        AddDefaultsRule.java TextRule.java
                        XMLIntrospectorHelper.java
  Log:
  Added support for simple reading of beans with mixed content. Patch submitted by Aslak Hellesoy.
  
  Revision  Changes    Path
  1.7       +24 -11    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AddDefaultsRule.java	7 Jan 2003 22:32:57 -0000	1.6
  +++ AddDefaultsRule.java	13 Jul 2003 21:28:10 -0000	1.7
  @@ -66,10 +66,11 @@
   import java.beans.PropertyDescriptor;
   import java.util.Set;
   
  -import org.apache.commons.betwixt.AttributeDescriptor;
  -import org.apache.commons.betwixt.ElementDescriptor;
   import org.apache.commons.betwixt.NodeDescriptor;
  +import org.apache.commons.betwixt.Descriptor;
  +import org.apache.commons.betwixt.ElementDescriptor;
   import org.apache.commons.betwixt.XMLBeanInfo;
  +import org.apache.commons.betwixt.AttributeDescriptor;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.xml.sax.Attributes;
  @@ -115,9 +116,8 @@
                           if ( procesedProperties.contains( name ) ) {
                               continue;
                           }
  -                        NodeDescriptor nodeDescriptor = XMLIntrospectorHelper.createDescriptor(

  -                            descriptor, attributesForPrimitives, getXMLIntrospector()
  -                        );
  +                        Descriptor nodeDescriptor = getXMLIntrospector().createDescriptor(
  +                                    descriptor, attributesForPrimitives);
                           if ( nodeDescriptor != null ) {
                               addDescriptor( nodeDescriptor );
                           }
  @@ -138,7 +138,7 @@
   
       // Implementation methods
       //-------------------------------------------------------------------------    
  -    
  +   
       /**
       * Add a desciptor to the top object on the Digester stack.
       * 
  @@ -146,8 +146,21 @@
       * @throws SAXException if the parent for the addDefaults element is not a <element>

       * or if the top object on the stack is not a <code>XMLBeanInfo</code> or
a 
       * <code>ElementDescriptor</code>
  +    * @deprecated replaced {@link #addDescriptor( Descriptor )} 
       */
       protected void addDescriptor( NodeDescriptor nodeDescriptor ) throws SAXException {
  +        addDescriptor( (Descriptor) nodeDescriptor );
  +    }
  +      
  +    /**
  +    * Add a desciptor to the top object on the Digester stack.
  +    * 
  +    * @param nodeDescriptor add this <code>NodeDescriptor</code>. Must not
be null.
  +    * @throws SAXException if the parent for the addDefaults element is not a <element>

  +    * or if the top object on the stack is not a <code>XMLBeanInfo</code> or
a 
  +    * <code>ElementDescriptor</code>
  +    */
  +    protected void addDescriptor( Descriptor nodeDescriptor ) throws SAXException {
           Object top = digester.peek();
           if ( top instanceof XMLBeanInfo ) {
               log.warn( "It is advisable to put an <addDefaults/> element inside an
<element> tag" );
  
  
  
  1.4       +6 -1      jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/TextRule.java
  
  Index: TextRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/TextRule.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TextRule.java	11 Jun 2003 21:29:32 -0000	1.3
  +++ TextRule.java	13 Jul 2003 21:28:10 -0000	1.4
  @@ -63,6 +63,7 @@
   
   import org.apache.commons.betwixt.expression.MethodExpression;
   import org.apache.commons.betwixt.expression.ConstantExpression;
  +import org.apache.commons.betwixt.expression.MethodUpdater;
   import org.apache.commons.betwixt.TextDescriptor;
   import org.apache.commons.betwixt.ElementDescriptor;
   import org.apache.commons.betwixt.XMLBeanInfo;
  @@ -137,6 +138,10 @@
                   if ( propertyDescriptor != null ) { 
                           Method readMethod = propertyDescriptor.getReadMethod();
                           descriptor.setTextExpression( new MethodExpression( readMethod
) );
  +                        Method writeMethod = propertyDescriptor.getWriteMethod();
  +                        if (writeMethod != null) {
  +                            descriptor.setUpdater( new MethodUpdater(writeMethod));
  +                        }
                           getProcessedPropertyNameSet().add( name );
                   }
               }
  
  
  
  1.23      +3 -1      jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java
  
  Index: XMLIntrospectorHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/XMLIntrospectorHelper.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- XMLIntrospectorHelper.java	1 Jul 2003 19:09:49 -0000	1.22
  +++ XMLIntrospectorHelper.java	13 Jul 2003 21:28:10 -0000	1.23
  @@ -115,6 +115,7 @@
       }
       
   
  +
       /** 
        * Process a property. 
        * Go through and work out whether it's a loop property, a primitive or a standard.
  @@ -125,6 +126,7 @@
        * @param introspector use this <code>XMLIntrospector</code>
        * @return a correctly configured <code>NodeDescriptor</code> for the property
        * @throws IntrospectionException when bean introspection fails
  +     * @deprecated this method has been replaced by {@link XMLIntrospector#createDescriptor}
        */
       public static NodeDescriptor createDescriptor( 
           PropertyDescriptor propertyDescriptor, 
  
  
  

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


Mime
View raw message