rdonkin 2004/02/21 08:58:58
Modified: betwixt/src/java/org/apache/commons/betwixt/io Tag:
REFACTORING-BRANCH_2004-01-13 BeanRuleSet.java
betwixt/src/java/org/apache/commons/betwixt/io/read Tag:
REFACTORING-BRANCH_2004-01-13 BeanBindAction.java
SimpleTypeBindAction.java
Log:
Simplifications to body text update algorithm and removed unneeded imports.
Revision Changes Path
No revision
No revision
1.16.2.6 +5 -8
jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanRuleSet.java
Index: BeanRuleSet.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanRuleSet.java,v
retrieving revision 1.16.2.5
retrieving revision 1.16.2.6
diff -u -r1.16.2.5 -r1.16.2.6
--- BeanRuleSet.java 21 Feb 2004 13:39:06 -0000 1.16.2.5
+++ BeanRuleSet.java 21 Feb 2004 16:58:58 -0000 1.16.2.6
@@ -61,19 +61,16 @@
package org.apache.commons.betwixt.io;
import java.beans.IntrospectionException;
-import java.util.Map;
import org.apache.commons.betwixt.BindingConfiguration;
import org.apache.commons.betwixt.ElementDescriptor;
-import org.apache.commons.betwixt.XMLBeanInfo;
import org.apache.commons.betwixt.XMLIntrospector;
-import org.apache.commons.betwixt.digester.XMLIntrospectorHelper;
import org.apache.commons.betwixt.expression.Context;
import org.apache.commons.betwixt.io.read.BeanBindAction;
-import org.apache.commons.betwixt.io.read.SimpleTypeBindAction;
import org.apache.commons.betwixt.io.read.MappingAction;
import org.apache.commons.betwixt.io.read.ReadConfiguration;
import org.apache.commons.betwixt.io.read.ReadContext;
+import org.apache.commons.betwixt.io.read.SimpleTypeBindAction;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.Rule;
import org.apache.commons.digester.RuleSet;
No revision
No revision
1.1.2.5 +18 -43
jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read/Attic/BeanBindAction.java
Index: BeanBindAction.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read/Attic/BeanBindAction.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- BeanBindAction.java 21 Feb 2004 16:34:57 -0000 1.1.2.4
+++ BeanBindAction.java 21 Feb 2004 16:58:58 -0000 1.1.2.5
@@ -67,7 +67,6 @@
import org.apache.commons.betwixt.ElementDescriptor;
import org.apache.commons.betwixt.TextDescriptor;
import org.apache.commons.betwixt.XMLBeanInfo;
-import org.apache.commons.betwixt.XMLIntrospector;
import org.apache.commons.betwixt.expression.Updater;
import org.apache.commons.logging.Log;
import org.xml.sax.Attributes;
@@ -86,26 +85,26 @@
public void body(String text, ReadContext context) throws Exception {
Log log = context.getLog();
// Take the first content descriptor
- ElementDescriptor pathDescriptor = context.getCurrentDescriptor();
- if (pathDescriptor == null) {
+ ElementDescriptor currentDescriptor = context.getCurrentDescriptor();
+ if (currentDescriptor == null) {
if (log.isTraceEnabled()) {
log.trace("path descriptor is null:");
}
} else {
- ElementDescriptor typeDescriptor =
- getElementDescriptor(
- pathDescriptor,
- context.getXMLIntrospector());
- TextDescriptor descriptor =
- typeDescriptor.getPrimaryBodyTextDescriptor();
- if (descriptor != null) {
+ TextDescriptor bodyTextdescriptor =
+ currentDescriptor.getPrimaryBodyTextDescriptor();
+ if (bodyTextdescriptor != null) {
if (log.isTraceEnabled()) {
log.trace("Setting mixed content for:");
- log.trace(descriptor);
+ log.trace(bodyTextdescriptor);
+ }
+ Updater updater = bodyTextdescriptor.getUpdater();
+ if (log.isTraceEnabled())
+ {
+
+ log.trace("Updating mixed content with:");
+ log.trace(updater);
}
- Updater updater = descriptor.getUpdater();
- log.trace("Updating mixed content with:");
- log.trace(updater);
if (updater != null && text != null) {
updater.update(context, text);
}
@@ -151,30 +150,6 @@
}
}
-
-
- ElementDescriptor getElementDescriptor(
- ElementDescriptor propertyDescriptor,
- XMLIntrospector introspector) {
- if (propertyDescriptor == null) {
- throw new RuntimeException("Property descriptor is null");
- }
- Class beanClass = propertyDescriptor.getSingularPropertyType();
- if (beanClass != null && !Map.class.isAssignableFrom(beanClass)) {
- try {
- XMLBeanInfo xmlInfo = introspector.introspect(beanClass);
-
- return xmlInfo.getElementDescriptor();
-
- } catch (Exception e) {
- // TODO: WORK OUT EXCEPTION HANDLING STRATEGY
- System.out.println(
- "Could not introspect class: " + beanClass + e);
- }
- }
- // could not find a better descriptor so use the one we've got
- return propertyDescriptor;
- }
/* (non-Javadoc)
* @see
org.apache.commons.betwixt.io.read.MappingAction#begin(java.lang.String,
java.lang.String, org.xml.sax.Attributes,
org.apache.commons.betwixt.io.read.ReadContext)
1.1.2.4 +5 -9
jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read/Attic/SimpleTypeBindAction.java
Index: SimpleTypeBindAction.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read/Attic/SimpleTypeBindAction.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- SimpleTypeBindAction.java 21 Feb 2004 14:39:12 -0000 1.1.2.3
+++ SimpleTypeBindAction.java 21 Feb 2004 16:58:58 -0000 1.1.2.4
@@ -61,12 +61,8 @@
*/
package org.apache.commons.betwixt.io.read;
-import java.util.List;
-
import org.apache.commons.betwixt.ElementDescriptor;
-import org.apache.commons.betwixt.XMLBeanInfo;
import org.apache.commons.betwixt.expression.Updater;
-import org.apache.commons.collections.IteratorUtils;
/**
* Action binds a simple type.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]