rdonkin 2004/07/14 14:38:17 Modified: betwixt/src/java/org/apache/commons/betwixt BeanProperty.java IntrospectionConfiguration.java XMLIntrospector.java betwixt/src/java/org/apache/commons/betwixt/digester XMLIntrospectorHelper.java Log: New strategy to replace primitives. More work needed before move to simple types is finished but this is a step in the right direction. Revision Changes Path 1.8 +5 -2 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/BeanProperty.java Index: BeanProperty.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/BeanProperty.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- BeanProperty.java 4 Jul 2004 16:59:14 -0000 1.7 +++ BeanProperty.java 14 Jul 2004 21:38:17 -0000 1.8 @@ -29,6 +29,7 @@ import org.apache.commons.betwixt.expression.Updater; import org.apache.commons.betwixt.strategy.NameMapper; import org.apache.commons.betwixt.strategy.SimpleTypeMapper; +import org.apache.commons.betwixt.strategy.TypeBindingStrategy; import org.apache.commons.logging.Log; /** @@ -178,8 +179,10 @@ //TODO this big conditional should be replaced with subclasses based // on the type - //TODO replace with simple type support - if ( XMLIntrospectorHelper.isPrimitiveType( getPropertyType() ) ) { + //TODO complete simple type implementation + TypeBindingStrategy.BindingType bindingType + = configuration.getTypeBindingStrategy().bindingType( getPropertyType() ) ; + if ( bindingType.equals( TypeBindingStrategy.BindingType.PRIMITIVE ) ) { descriptor = createDescriptorForPrimitive( configuration, 1.3 +25 -4 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/IntrospectionConfiguration.java Index: IntrospectionConfiguration.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/IntrospectionConfiguration.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- IntrospectionConfiguration.java 13 Jun 2004 21:32:45 -0000 1.2 +++ IntrospectionConfiguration.java 14 Jul 2004 21:38:17 -0000 1.3 @@ -24,6 +24,7 @@ import org.apache.commons.betwixt.strategy.PluralStemmer; import org.apache.commons.betwixt.strategy.SimpleTypeMapper; import org.apache.commons.betwixt.strategy.StandardSimpleTypeMapper; +import org.apache.commons.betwixt.strategy.TypeBindingStrategy; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -77,10 +78,11 @@ /** Prefix naming strategy */ private NamespacePrefixMapper prefixMapper = new NamespacePrefixMapper(); - /** Binding strategy for simple types */ + /** Mapping strategy for simple types */ private SimpleTypeMapper simpleTypeMapper = new StandardSimpleTypeMapper(); - - + /** Binding strategy for Java type */ + private TypeBindingStrategy typeBindingStrategy = TypeBindingStrategy.DEFAULT; + /** * Gets the <code>ClassNormalizer</code> strategy. * This is used to determine the Class to be introspected @@ -300,4 +302,23 @@ simpleTypeMapper = mapper; } + /** + * Gets the <code>TypeBindingStrategy</code> to be used + * to determine the binding for Java types. + * @return the <code>TypeBindingStrategy</code> to be used, + * not null + */ + public TypeBindingStrategy getTypeBindingStrategy() { + return typeBindingStrategy; + } + + /** + * Sets the <code>TypeBindingStrategy</code> to be used + * to determine the binding for Java types. + * @param typeBindingStrategy the <code>TypeBindingStrategy</code> to be used, + * not null + */ + public void setTypeBindingStrategy(TypeBindingStrategy typeBindingStrategy) { + this.typeBindingStrategy = typeBindingStrategy; + } } 1.31 +7 -3 jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java Index: XMLIntrospector.java =================================================================== RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/XMLIntrospector.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- XMLIntrospector.java 4 Jul 2004 16:59:14 -0000 1.30 +++ XMLIntrospector.java 14 Jul 2004 21:38:17 -0000 1.31 @@ -46,6 +46,7 @@ import org.apache.commons.betwixt.strategy.DefaultPluralStemmer; import org.apache.commons.betwixt.strategy.NameMapper; import org.apache.commons.betwixt.strategy.PluralStemmer; +import org.apache.commons.betwixt.strategy.TypeBindingStrategy; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -1180,13 +1181,16 @@ /** * Is this class a primitive? - * TODO: this method will probably be removed when primitive types + * TODO: this method will probably be deprecated when primitive types * are subsumed into the simple type concept * @param type the Class to test * @return true for primitive types */ public boolean isPrimitiveType(Class type) { - return XMLIntrospectorHelper.isPrimitiveType(type); + TypeBindingStrategy.BindingType bindingType + = configuration.getTypeBindingStrategy().bindingType( type ) ; + boolean result = (bindingType.equals(TypeBindingStrategy.BindingType.PRIMITIVE)); + return result; } @@ -1277,7 +1281,7 @@ /** @see BeanType#isPrimitiveType */ public boolean isPrimitiveType() { - return XMLIntrospectorHelper.isPrimitiveType( beanClass ); + return XMLIntrospector.this.isPrimitiveType( beanClass ); } /** @see BeanType#isLoopType */ 1.32 +1 -0 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.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- XMLIntrospectorHelper.java 4 Jul 2004 16:40:49 -0000 1.31 +++ XMLIntrospectorHelper.java 14 Jul 2004 21:38:17 -0000 1.32 @@ -573,6 +573,7 @@ * type can be varied. * @param type is this <code>Class<code> a primitive type? * @return true for primitive types + * @deprecated replaced by [EMAIL PROTECTED] org.apache.commons.betwixt.strategy.TypeBindingStrategy} */ public static boolean isPrimitiveType(Class type) { if ( type == null ) {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]