commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fathman, Abraham" <Abraham.Fath...@53.com>
Subject RE: Betwixt Question (Mixed Content) (Patch for reading mixed con tent)
Date Wed, 11 Jun 2003 19:45:43 GMT
Robert,

Thanks for the quick response. I think that I have solved the easy use case
that you mentioned (It works for my situation anyway).

I do have a few questions though:

1) In org.apache.commons.betwixt.XMLIntrospector line 330, should I add the
abilitiy to copy the ContentDescriptors?

2) In org.apache.commons.betwixt.digester.TextRule line 135, should we be
overriding the beanClass member variable with a local beanClass variable?

3) In org.apache.commons.betwixt.io.BeanRuleSet line 347, is that the
correct expression to make sure that we don't add duplicates? A better way
to handle it, starting at line 248, might be to just handle the
ElementDescriptors with the for loop and handle the non ElementDescriptors
(TextDescriptors) in afterwards, line 351 for example.


I have included the patch (diff -r -u -d on the src directories between the
060503-src.zip and what I changed) below.


diff -u -r -b
b/commons-betwixt/src/java/org/apache/commons/betwixt/digester/TextRule.java
commons-betwixt/src/java/org/apache/commons/betwixt/digester/TextRule.java
---
b/commons-betwixt/src/java/org/apache/commons/betwixt/digester/TextRule.java
2003-06-05 02:59:54.000000000 -0400
+++
commons-betwixt/src/java/org/apache/commons/betwixt/digester/TextRule.java
2003-06-11 14:58:48.000000000 -0400
@@ -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;
@@ -139,6 +140,8 @@
                 if ( propertyDescriptor != null ) { 
                         Method readMethod =
propertyDescriptor.getReadMethod();
                         descriptor.setTextExpression( new MethodExpression(
readMethod ) );
+                        Method writeMethod =
propertyDescriptor.getWriteMethod();
+                        descriptor.setUpdater( new MethodUpdater(
writeMethod ) );
                         getProcessedPropertyNameSet().add( name );
                 }
             }
diff -u -r -b
b/commons-betwixt/src/java/org/apache/commons/betwixt/io/BeanRuleSet.java
commons-betwixt/src/java/org/apache/commons/betwixt/io/BeanRuleSet.java
---
b/commons-betwixt/src/java/org/apache/commons/betwixt/io/BeanRuleSet.java
2003-06-05 02:59:56.000000000 -0400
+++ commons-betwixt/src/java/org/apache/commons/betwixt/io/BeanRuleSet.java
2003-06-11 15:16:59.000000000 -0400
@@ -67,6 +67,8 @@
 
 import org.apache.commons.betwixt.AttributeDescriptor;
 import org.apache.commons.betwixt.ElementDescriptor;
+import org.apache.commons.betwixt.TextDescriptor;
+import org.apache.commons.betwixt.Descriptor;
 import org.apache.commons.betwixt.XMLBeanInfo;
 import org.apache.commons.betwixt.XMLIntrospector;
 import org.apache.commons.betwixt.digester.XMLIntrospectorHelper;
@@ -243,10 +245,13 @@
             //ElementDescriptor typeDescriptor = descriptor;
     
             
-            ElementDescriptor[] childDescriptors =
typeDescriptor.getElementDescriptors();
+            Descriptor[] childDescriptors =
typeDescriptor.getContentDescriptors();
             if ( childDescriptors != null ) {
                 for ( int i = 0, size = childDescriptors.length; i < size;
i++ ) {
-                    final ElementDescriptor childDescriptor =
childDescriptors[i];
+                    if( childDescriptors[i] instanceof ElementDescriptor )
{
+
+                        final ElementDescriptor childDescriptor =
(ElementDescriptor)childDescriptors[i];
+
                     if (log.isTraceEnabled()) {
                         log.trace("Processing child " + childDescriptor);
                     }
@@ -336,8 +341,17 @@
                     } else if ( log.isTraceEnabled() ) {
                         log.trace( "No children for " + childDescriptor);
                     }
+
+                    } else {
+                        // 06/11/03 Abraham Fathman - Is this the correct
comparison?
+                        if (
currentDescriptor.getContentDescriptors().length < childDescriptors.length )
{
+                            currentDescriptor.addContentDescriptor(
childDescriptors[i] );
                 }
             }
+
+                }
+
+            }
         }
         
         /** Allows the navigation from a reference to a property object to
the 
@@ -635,6 +649,37 @@
             }
         
             /**
+             * Process the body of the element.
+             * @param text String value of the body of the element
+             */
+            public void body ( String text )
+            {
+                if ( createdBean ) {
+
+                    log.trace("text: " + text );
+
+                    Descriptor d[] = descriptor.getContentDescriptors();
+                    for( int x = 0; x < d.length; x++ ){
+                        if ( d[x] instanceof TextDescriptor ){
+                            Updater updater = d[x].getUpdater();
+
+                            log.trace( "updater: " + updater);
+
+                            if ( updater != null ) {
+                                updater.update( context, text );
+                            } else {
+                                if( log.isDebugEnabled() ) {
+                                    log.debug( "No updater for: " + d[x] +
" with: "
+                                       + " on bean: " + context.getBean()
);
+                                }
+
+                            }
+                        }
+                    }
+                }
+            }
+
+            /**
             * Process the end of this element.
             */
             public void end() {


Thanks for your help,

Abraham Fathman
eBusiness Architecture
513-534-4607


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