You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ni...@apache.org on 2008/03/23 03:10:35 UTC
svn commit: r640131 -
/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/
Author: niallp
Date: Sat Mar 22 19:10:31 2008
New Revision: 640131
URL: http://svn.apache.org/viewvc?rev=640131&view=rev
Log:
BEANUTILS-291 - resolve one of the memory leak issues - Converters holding a reference to Class. This is an incompatible change to BeanUtils 1.8.0-BETA (but not to the previous 1.7.0 release).
The incompatible changes are:
- AbstractConverter - constructor signatures are different and getDefaultType() method is now abstract
- DateTimeConverter - now an abstract class and constructor signatures are different
- NumberConverter - now an abstract class and constructor signatures are different
Modified:
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/AbstractConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ArrayConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BooleanConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ByteConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/CalendarConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/CharacterConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ClassConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DateConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DateTimeConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DoubleConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/FileConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/FloatConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/IntegerConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/LongConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/NumberConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ShortConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlDateConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlTimeConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlTimestampConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/StringConverter.java
commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/URLConverter.java
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/AbstractConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/AbstractConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/AbstractConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/AbstractConverter.java Sat Mar 22 19:10:31 2008
@@ -64,11 +64,6 @@
private transient Log log;
/**
- * The default type this <code>Converter</code> handles.
- */
- private Class defaultType = null;
-
- /**
* Should we return the default value on conversion errors?
*/
private boolean useDefault = false;
@@ -83,29 +78,19 @@
/**
* Construct a <i>Converter</i> that throws a
* <code>ConversionException</code> if an error occurs.
- *
- * @param defaultType The default type this <code>Converter</code>
- * handles
*/
- public AbstractConverter(Class defaultType) {
- this.defaultType = defaultType;
- if (defaultType == null) {
- throw new IllegalArgumentException("Default type is missing.");
- }
+ public AbstractConverter() {
}
/**
* Construct a <i>Converter</i> that returns a default
* value if an error occurs.
*
- * @param defaultType The default type this <code>Converter</code>
- * handles
* @param defaultValue The default value to be returned
* if the value to be converted is missing or an error
* occurs converting the value.
*/
- public AbstractConverter(Class defaultType, Object defaultValue) {
- this(defaultType);
+ public AbstractConverter(Object defaultValue) {
setDefaultValue(defaultValue);
}
@@ -363,9 +348,7 @@
*
* @return The default type this <code>Converter</code> handles.
*/
- protected Class getDefaultType() {
- return defaultType;
- }
+ protected abstract Class getDefaultType();
/**
* Return the default value for conversions to the specified
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ArrayConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ArrayConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ArrayConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ArrayConverter.java Sat Mar 22 19:10:31 2008
@@ -126,6 +126,7 @@
*/
public class ArrayConverter extends AbstractConverter {
+ private Object defaultTypeInstance;
private Converter elementConverter;
private int defaultSize;
private char delimiter = ',';
@@ -145,13 +146,17 @@
* individual array elements.
*/
public ArrayConverter(Class defaultType, Converter elementConverter) {
- super(defaultType);
+ super();
+ if (defaultType == null) {
+ throw new IllegalArgumentException("Default type is missing");
+ }
if (!defaultType.isArray()) {
throw new IllegalArgumentException("Default type must be an array.");
}
if (elementConverter == null) {
throw new IllegalArgumentException("Component Converter is missing.");
}
+ this.defaultTypeInstance = Array.newInstance(defaultType.getComponentType(), 0);
this.elementConverter = elementConverter;
}
@@ -207,6 +212,15 @@
*/
public void setOnlyFirstToString(boolean onlyFirstToString) {
this.onlyFirstToString = onlyFirstToString;
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return defaultTypeInstance.getClass();
}
/**
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BigDecimalConverter.java Sat Mar 22 19:10:31 2008
@@ -41,7 +41,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public BigDecimalConverter() {
- super(BigDecimal.class, true);
+ super(true);
}
/**
@@ -53,7 +53,16 @@
* occurs converting the value.
*/
public BigDecimalConverter(Object defaultValue) {
- super(BigDecimal.class, true, defaultValue);
+ super(true, defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return BigDecimal.class;
}
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BigIntegerConverter.java Sat Mar 22 19:10:31 2008
@@ -41,7 +41,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public BigIntegerConverter() {
- super(BigInteger.class, false);
+ super(false);
}
/**
@@ -53,7 +53,16 @@
* occurs converting the value.
*/
public BigIntegerConverter(Object defaultValue) {
- super(BigInteger.class, false, defaultValue);
+ super(false, defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return BigInteger.class;
}
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BooleanConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BooleanConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BooleanConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/BooleanConverter.java Sat Mar 22 19:10:31 2008
@@ -64,7 +64,7 @@
* not one of the known true strings, nor one of the known false strings.
*/
public BooleanConverter() {
- super(Boolean.class);
+ super();
}
@@ -81,7 +81,7 @@
* in which case this constructor acts like the no-argument one.
*/
public BooleanConverter(Object defaultValue) {
- super(Boolean.class);
+ super();
if (defaultValue != NO_DEFAULT) {
setDefaultValue(defaultValue);
}
@@ -104,7 +104,7 @@
* ignored.
*/
public BooleanConverter(String[] trueStrings, String[] falseStrings) {
- super(Boolean.class);
+ super();
this.trueStrings = copyStrings(trueStrings);
this.falseStrings = copyStrings(falseStrings);
}
@@ -133,7 +133,7 @@
*/
public BooleanConverter(String[] trueStrings, String[] falseStrings,
Object defaultValue) {
- super(Boolean.class);
+ super();
this.trueStrings = copyStrings(trueStrings);
this.falseStrings = copyStrings(falseStrings);
if (defaultValue != NO_DEFAULT) {
@@ -168,6 +168,15 @@
private String[] falseStrings = {"false", "no", "n", "off", "0"};
// --------------------------------------------------------- Protected Methods
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Boolean.class;
+ }
/**
* Convert the specified input object into an output object of the
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ByteConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ByteConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ByteConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ByteConverter.java Sat Mar 22 19:10:31 2008
@@ -39,7 +39,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public ByteConverter() {
- super(Byte.class, false);
+ super(false);
}
/**
@@ -51,7 +51,16 @@
* occurs converting the value.
*/
public ByteConverter(Object defaultValue) {
- super(Byte.class, false, defaultValue);
+ super(false, defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Byte.class;
}
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/CalendarConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/CalendarConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/CalendarConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/CalendarConverter.java Sat Mar 22 19:10:31 2008
@@ -40,7 +40,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public CalendarConverter() {
- super(Calendar.class);
+ super();
}
/**
@@ -52,7 +52,16 @@
* occurs converting the value.
*/
public CalendarConverter(Object defaultValue) {
- super(Calendar.class, defaultValue);
+ super(defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Calendar.class;
}
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/CharacterConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/CharacterConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/CharacterConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/CharacterConverter.java Sat Mar 22 19:10:31 2008
@@ -34,7 +34,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public CharacterConverter() {
- super(Character.class);
+ super();
}
/**
@@ -46,7 +46,16 @@
* occurs converting the value.
*/
public CharacterConverter(Object defaultValue) {
- super(Character.class, defaultValue);
+ super(defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Character.class;
}
/**
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ClassConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ClassConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ClassConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ClassConverter.java Sat Mar 22 19:10:31 2008
@@ -38,7 +38,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public ClassConverter() {
- super(Class.class);
+ super();
}
/**
@@ -50,7 +50,16 @@
* occurs converting the value.
*/
public ClassConverter(Object defaultValue) {
- super(Class.class, defaultValue);
+ super(defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Class.class;
}
/**
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DateConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DateConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DateConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DateConverter.java Sat Mar 22 19:10:31 2008
@@ -40,7 +40,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public DateConverter() {
- super(Date.class);
+ super();
}
/**
@@ -52,7 +52,16 @@
* occurs converting the value.
*/
public DateConverter(Object defaultValue) {
- super(Date.class, defaultValue);
+ super(defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Date.class;
}
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DateTimeConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DateTimeConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DateTimeConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DateTimeConverter.java Sat Mar 22 19:10:31 2008
@@ -76,7 +76,7 @@
* @version $Revision$ $Date$
* @since 1.8.0
*/
-public class DateTimeConverter extends AbstractConverter {
+public abstract class DateTimeConverter extends AbstractConverter {
private String[] patterns;
private String displayPatterns;
@@ -90,26 +90,21 @@
/**
* Construct a Date/Time <i>Converter</i> that throws a
* <code>ConversionException</code> if an error occurs.
- *
- * @param defaultType The default type this <code>Converter</code>
- * handles
*/
- public DateTimeConverter(Class defaultType) {
- super(defaultType);
+ public DateTimeConverter() {
+ super();
}
/**
* Construct a Date/Time <i>Converter</i> that returns a default
* value if an error occurs.
*
- * @param defaultType The default type this <code>Converter</code>
- * handles
* @param defaultValue The default value to be returned
* if the value to be converted is missing or an error
* occurs converting the value.
*/
- public DateTimeConverter(Class defaultType, Object defaultValue) {
- super(defaultType, defaultValue);
+ public DateTimeConverter(Object defaultValue) {
+ super(defaultValue);
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DoubleConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DoubleConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DoubleConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/DoubleConverter.java Sat Mar 22 19:10:31 2008
@@ -39,7 +39,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public DoubleConverter() {
- super(Double.class, true);
+ super(true);
}
/**
@@ -51,7 +51,16 @@
* occurs converting the value.
*/
public DoubleConverter(Object defaultValue) {
- super(Double.class, true, defaultValue);
+ super(true, defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Double.class;
}
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/FileConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/FileConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/FileConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/FileConverter.java Sat Mar 22 19:10:31 2008
@@ -36,7 +36,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public FileConverter() {
- super(File.class);
+ super();
}
/**
@@ -48,7 +48,16 @@
* occurs converting the value.
*/
public FileConverter(Object defaultValue) {
- super(File.class, defaultValue);
+ super(defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return File.class;
}
/**
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/FloatConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/FloatConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/FloatConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/FloatConverter.java Sat Mar 22 19:10:31 2008
@@ -39,7 +39,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public FloatConverter() {
- super(Float.class, true);
+ super(true);
}
/**
@@ -51,7 +51,16 @@
* occurs converting the value.
*/
public FloatConverter(Object defaultValue) {
- super(Float.class, true, defaultValue);
+ super(true, defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Float.class;
}
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/IntegerConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/IntegerConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/IntegerConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/IntegerConverter.java Sat Mar 22 19:10:31 2008
@@ -39,7 +39,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public IntegerConverter() {
- super(Integer.class, false);
+ super(false);
}
/**
@@ -51,7 +51,16 @@
* occurs converting the value.
*/
public IntegerConverter(Object defaultValue) {
- super(Integer.class, false, defaultValue);
+ super(false, defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Integer.class;
}
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/LongConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/LongConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/LongConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/LongConverter.java Sat Mar 22 19:10:31 2008
@@ -39,7 +39,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public LongConverter() {
- super(Long.class, false);
+ super(false);
}
/**
@@ -51,7 +51,16 @@
* occurs converting the value.
*/
public LongConverter(Object defaultValue) {
- super(Long.class, false, defaultValue);
+ super(false, defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Long.class;
}
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/NumberConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/NumberConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/NumberConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/NumberConverter.java Sat Mar 22 19:10:31 2008
@@ -82,7 +82,7 @@
* @version $Revision$ $Date$
* @since 1.8.0
*/
-public class NumberConverter extends AbstractConverter {
+public abstract class NumberConverter extends AbstractConverter {
private static final Integer ZERO = new Integer(0);
private static final Integer ONE = new Integer(1);
@@ -98,12 +98,10 @@
* Construct a <b>java.lang.Number</b> <i>Converter</i>
* that throws a <code>ConversionException</code> if a error occurs.
*
- * @param defaultType The default type this <code>Converter</code>
- * handles
* @param allowDecimals Indicates whether decimals are allowed
*/
- public NumberConverter(Class defaultType, boolean allowDecimals) {
- super(defaultType);
+ public NumberConverter(boolean allowDecimals) {
+ super();
this.allowDecimals = allowDecimals;
}
@@ -111,13 +109,11 @@
* Construct a <code>java.lang.Number</code> <i>Converter</i> that returns
* a default value if an error occurs.
*
- * @param defaultType The default type this <code>Converter</code>
- * handles
* @param allowDecimals Indicates whether decimals are allowed
* @param defaultValue The default value to be returned
*/
- public NumberConverter(Class defaultType, boolean allowDecimals, Object defaultValue) {
- super(defaultType);
+ public NumberConverter(boolean allowDecimals, Object defaultValue) {
+ super();
this.allowDecimals = allowDecimals;
setDefaultValue(defaultValue);
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ShortConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ShortConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ShortConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/ShortConverter.java Sat Mar 22 19:10:31 2008
@@ -39,7 +39,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public ShortConverter() {
- super(Short.class, false);
+ super(false);
}
/**
@@ -51,7 +51,16 @@
* occurs converting the value.
*/
public ShortConverter(Object defaultValue) {
- super(Short.class, false, defaultValue);
+ super(false, defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Short.class;
}
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlDateConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlDateConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlDateConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlDateConverter.java Sat Mar 22 19:10:31 2008
@@ -41,7 +41,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public SqlDateConverter() {
- super(Date.class);
+ super();
}
/**
@@ -53,7 +53,16 @@
* occurs converting the value.
*/
public SqlDateConverter(Object defaultValue) {
- super(Date.class, defaultValue);
+ super(defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Date.class;
}
}
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlTimeConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlTimeConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlTimeConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlTimeConverter.java Sat Mar 22 19:10:31 2008
@@ -44,7 +44,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public SqlTimeConverter() {
- super(Time.class);
+ super();
}
/**
@@ -56,7 +56,16 @@
* occurs converting the value.
*/
public SqlTimeConverter(Object defaultValue) {
- super(Time.class, defaultValue);
+ super(defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Time.class;
}
/**
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlTimestampConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlTimestampConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlTimestampConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/SqlTimestampConverter.java Sat Mar 22 19:10:31 2008
@@ -44,7 +44,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public SqlTimestampConverter() {
- super(Timestamp.class);
+ super();
}
/**
@@ -56,7 +56,16 @@
* occurs converting the value.
*/
public SqlTimestampConverter(Object defaultValue) {
- super(Timestamp.class, defaultValue);
+ super(defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return Timestamp.class;
}
/**
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/StringConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/StringConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/StringConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/StringConverter.java Sat Mar 22 19:10:31 2008
@@ -50,7 +50,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public StringConverter() {
- super(String.class);
+ super();
}
/**
@@ -62,7 +62,16 @@
* occurs converting the value.
*/
public StringConverter(Object defaultValue) {
- super(String.class, defaultValue);
+ super(defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return String.class;
}
/**
Modified: commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/URLConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/URLConverter.java?rev=640131&r1=640130&r2=640131&view=diff
==============================================================================
--- commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/URLConverter.java (original)
+++ commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/converters/URLConverter.java Sat Mar 22 19:10:31 2008
@@ -35,7 +35,7 @@
* a <code>ConversionException</code> if an error occurs.
*/
public URLConverter() {
- super(URL.class);
+ super();
}
/**
@@ -47,7 +47,16 @@
* occurs converting the value.
*/
public URLConverter(Object defaultValue) {
- super(URL.class, defaultValue);
+ super(defaultValue);
+ }
+
+ /**
+ * Return the default type this <code>Converter</code> handles.
+ *
+ * @return The default type this <code>Converter</code> handles.
+ */
+ protected Class getDefaultType() {
+ return URL.class;
}
/**