You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by to...@apache.org on 2006/11/07 14:31:49 UTC

svn commit: r472102 - /myfaces/core/trunk/api/src/main/java/javax/faces/convert/

Author: tomsp
Date: Tue Nov  7 05:31:48 2006
New Revision: 472102

URL: http://svn.apache.org/viewvc?view=rev&rev=472102
Log:
MYFACES-1419 reverted due to JSF 1.1 incompatibility

Removed:
    myfaces/core/trunk/api/src/main/java/javax/faces/convert/AbstractConverter.java
Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/convert/BigIntegerConverter.java
    myfaces/core/trunk/api/src/main/java/javax/faces/convert/BooleanConverter.java
    myfaces/core/trunk/api/src/main/java/javax/faces/convert/ByteConverter.java
    myfaces/core/trunk/api/src/main/java/javax/faces/convert/CharacterConverter.java
    myfaces/core/trunk/api/src/main/java/javax/faces/convert/DateTimeConverter.java
    myfaces/core/trunk/api/src/main/java/javax/faces/convert/DoubleConverter.java
    myfaces/core/trunk/api/src/main/java/javax/faces/convert/FloatConverter.java
    myfaces/core/trunk/api/src/main/java/javax/faces/convert/IntegerConverter.java
    myfaces/core/trunk/api/src/main/java/javax/faces/convert/LongConverter.java
    myfaces/core/trunk/api/src/main/java/javax/faces/convert/ShortConverter.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/convert/BigIntegerConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/convert/BigIntegerConverter.java?view=diff&rev=472102&r1=472101&r2=472102
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/convert/BigIntegerConverter.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/convert/BigIntegerConverter.java Tue Nov  7 05:31:48 2006
@@ -15,6 +15,8 @@
  */
 package javax.faces.convert;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
 import java.math.BigInteger;
 
 /**
@@ -23,21 +25,66 @@
  * @author Thomas Spiegl (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class BigIntegerConverter extends AbstractConverter {
-	private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.BigIntegerConverter.CONVERSION";
+public class BigIntegerConverter
+        implements Converter
+{
+    private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.BigIntegerConverter.CONVERSION";
 
-	public static final String CONVERTER_ID = "javax.faces.BigInteger";
+    // FIELDS
+    public static final String CONVERTER_ID = "javax.faces.BigInteger";
+
+    // CONSTRUCTORS
+    public BigIntegerConverter()
+    {
+    }
+
+    // METHODS
+    public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+        if (value != null)
+        {
+            value = value.trim();
+            if (value.length() > 0)
+            {
+                try
+                {
+                    return new BigInteger(value.trim());
+                }
+                catch (NumberFormatException e)
+                {
+                    throw new ConverterException(_MessageUtils.getErrorMessage(facesContext,
+                                                                               CONVERSION_MESSAGE_ID,
+                                                                               new Object[]{uiComponent.getId(),value}), e);
+                }
+            }
+        }
+        return null;
+    }
+
+    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+        if (value == null)
+        {
+            return "";
+        }
+        if (value instanceof String)
+        {
+            return (String)value;
+        }
+        try
+        {
+            return ((BigInteger)value).toString();
+        }
+        catch (Exception e)
+        {
+            throw new ConverterException(e);
+        }
+    }
 
-	// Methods implementation
-	protected Object getAsObject(String value) {
-		return new BigInteger(value);
-	}
-
-	protected String getAsString(Object value) {
-		return ((BigInteger) value).toString();
-	}
-
-	protected String getConversionMessageId() {
-		return CONVERSION_MESSAGE_ID;
-	}
 }

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/convert/BooleanConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/convert/BooleanConverter.java?view=diff&rev=472102&r1=472101&r2=472102
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/convert/BooleanConverter.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/convert/BooleanConverter.java Tue Nov  7 05:31:48 2006
@@ -15,27 +15,74 @@
  */
 package javax.faces.convert;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
 /**
  * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
  *
  * @author Thomas Spiegl (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class BooleanConverter extends AbstractConverter {
-	private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.BooleanConverter.CONVERSION";
+public class BooleanConverter
+        implements Converter
+{
+    private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.BooleanConverter.CONVERSION";
+
+    // FIELDS
+    public static final String CONVERTER_ID = "javax.faces.Boolean";
+
+    // CONSTRUCTORS
+    public BooleanConverter()
+    {
+    }
+
+    // METHODS
+    public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+        if (value != null)
+        {
+            value = value.trim();
+            if (value.length() > 0)
+            {
+                try
+                {
+                    return Boolean.valueOf(value);
+                }
+                catch (Exception e)
+                {
+                    throw new ConverterException(_MessageUtils.getErrorMessage(facesContext,
+                                                                               CONVERSION_MESSAGE_ID,
+                                                                               new Object[]{value,uiComponent.getId()}), e);
+                }
+            }
+        }
+        return null;
+    }
 
-	public static final String CONVERTER_ID = "javax.faces.Boolean";
+    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
 
-	// Methods implementation
-	protected Object getAsObject(String value) {
-		return Boolean.valueOf(value);
-	}
-
-	protected String getAsString(Object value) {
-		return ((Boolean) value).toString();
-	}
-
-	protected String getConversionMessageId() {
-		return CONVERSION_MESSAGE_ID;
-	}
+        if (value == null)
+        {
+            return "";
+        }
+        if (value instanceof String)
+        {
+            return (String)value;
+        }
+        try
+        {
+            return ((Boolean)value).toString();
+        }
+        catch (Exception e)
+        {
+            throw new ConverterException(e);
+        }
+    }
 }

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/convert/ByteConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/convert/ByteConverter.java?view=diff&rev=472102&r1=472101&r2=472102
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/convert/ByteConverter.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/convert/ByteConverter.java Tue Nov  7 05:31:48 2006
@@ -15,27 +15,75 @@
  */
 package javax.faces.convert;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
 /**
  * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
  *
  * @author Thomas Spiegl (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class ByteConverter extends AbstractConverter {
-	private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.ByteConverter.CONVERSION";
+public class ByteConverter
+        implements Converter
+{
+    private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.ByteConverter.CONVERSION";
+
+    // FIELDS
+    public static final String CONVERTER_ID = "javax.faces.Byte";
+
+    // CONSTRUCTORS
+    public ByteConverter()
+    {
+    }
+
+    // METHODS
+    public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+        if (value != null)
+        {
+            value = value.trim();
+            if (value.length() > 0)
+            {
+                try
+                {
+                    return Byte.valueOf(value);
+                }
+                catch (NumberFormatException e)
+                {
+                    throw new ConverterException(_MessageUtils.getErrorMessage(facesContext,
+                                                                               CONVERSION_MESSAGE_ID,
+                                                                               new Object[]{value,uiComponent.getId()}), e);
+                }
+            }
+        }
+        return null;
+    }
+
+    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
 
-	public static final String CONVERTER_ID = "javax.faces.Byte";
+        if (value == null)
+        {
+            return "";
+        }
+        if (value instanceof String)
+        {
+            return (String)value;
+        }
+        try
+        {
+            return Byte.toString(((Number)value).byteValue());
+        }
+        catch (Exception e)
+        {
+            throw new ConverterException(e);
+        }
 
-	// Methods implementation
-	protected Object getAsObject(String value) {
-		return Byte.valueOf(value);
-	}
-
-	protected String getAsString(Object value) {
-		return Byte.toString(((Number) value).byteValue());
-	}
-
-	protected String getConversionMessageId() {
-		return CONVERSION_MESSAGE_ID;
-	}
+    }
 }

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/convert/CharacterConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/convert/CharacterConverter.java?view=diff&rev=472102&r1=472101&r2=472102
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/convert/CharacterConverter.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/convert/CharacterConverter.java Tue Nov  7 05:31:48 2006
@@ -15,26 +15,64 @@
  */
 package javax.faces.convert;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
 /**
  * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
  *
  * @author Thomas Spiegl (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class CharacterConverter extends AbstractConverter {
-	// FIELDS
-	public static final String CONVERTER_ID = "javax.faces.Character";
-
-	// Methods implementation
-	protected Object getAsObject(String value) {
-		return new Character(value.charAt(0));
-	}
-
-	protected String getAsString(Object value) {
-		return ((Character) value).toString();
-	}
-
-	protected String getConversionMessageId() {
-		return null;
-	}
+public class CharacterConverter
+        implements Converter
+{
+    // FIELDS
+    public static final String CONVERTER_ID = "javax.faces.Character";
+
+    // CONSTRUCTORS
+    public CharacterConverter()
+    {
+    }
+
+    // METHODS
+    public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+        if (value != null)
+        {
+            value = value.trim();
+            if (value.length() > 0)
+            {
+                return new Character(value.charAt(0));
+            }
+        }
+        return null;
+    }
+
+    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+        if (value == null)
+        {
+            return "";
+        }
+        if (value instanceof String)
+        {
+            return (String)value;
+        }
+        try
+        {
+            return ((Character)value).toString();
+        }
+        catch (Exception e)
+        {
+            throw new ConverterException(e);
+        }
+    }
+
 }

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/convert/DateTimeConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/convert/DateTimeConverter.java?view=diff&rev=472102&r1=472101&r2=472102
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/convert/DateTimeConverter.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/convert/DateTimeConverter.java Tue Nov  7 05:31:48 2006
@@ -30,7 +30,7 @@
  * @author Thomas Spiegl (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class DateTimeConverter extends AbstractConverter implements StateHolder {
+public class DateTimeConverter implements Converter, StateHolder {
 	// API field
 	public static final String CONVERTER_ID = "javax.faces.DateTime";
 
@@ -47,19 +47,57 @@
 	private String _type;
 	private boolean _transient;
 
-	// Methods implementation
-	protected Object getAsObject(String value) throws Exception {
-		return prepareDateFormat().parse(value);
-	}
-
-	protected String getAsString(Object value) {
-		return prepareDateFormat().format(value);
-	}
+    public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException {
+        if (context == null) {
+            throw new NullPointerException("facesContext");
+        }
+        if (component == null) {
+            throw new NullPointerException("uiComponent");
+        }
+
+        if (value == null) {
+            return null;
+        }
+
+        String trimmedValue = value.trim();
+        if (trimmedValue.length() == 0) {
+            return null;
+        }
+
+        try {
+            return prepareDateFormat().parse(trimmedValue);
+        } catch (Exception e) {
+            throw new ConverterException(_MessageUtils.getErrorMessage(context, getConversionMessageId(),
+                    getMessageArguments(component, value)), e);
+        }
+    }
+
+    public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException {
+        if (context == null) {
+            throw new NullPointerException("facesContext");
+        }
+        if (component == null) {
+            throw new NullPointerException("uiComponent");
+        }
+
+        if (value == null) {
+            return "";
+        }
+        if (value instanceof String) {
+            return (String) value;
+        }
+
+        try {
+            return prepareDateFormat().format(value);
+        } catch (Exception e) {
+            throw new ConverterException(e);
+        }
+    }
 
 	protected String getConversionMessageId() {
 		return CONVERSION_MESSAGE_ID;
 	}
-	
+
 	protected Object[] getMessageArguments(UIComponent component, String value) {
 		return new Object[] {value, component.getId()};
 	}
@@ -68,15 +106,15 @@
 		DateFormat format = getDateFormat();
 		// format cannot be lenient (JSR-127)
 		format.setLenient(false);
-		
+
 		TimeZone tz = getTimeZone();
 		if (tz != null) {
 			format.setTimeZone(tz);
 		}
-		
+
 		return format;
 	}
-	
+
 	private DateFormat getDateFormat() {
 		if(_pattern != null) {
 			try {
@@ -85,14 +123,14 @@
 				throw new ConverterException("Invalid pattern", iae);
 			}
 		}
-		
+
 		return Type.getType(getType()).getFormatter(calcDateStyle(), calcTimeStyle(), getLocale());
 	}
 
 	private int calcDateStyle() {
 		return Style.getStyleFormat(getDateStyle());
 	}
-	
+
 	private int calcTimeStyle() {
 		return Style.getStyleFormat(getTimeStyle());
 	}
@@ -181,50 +219,50 @@
 		//TODO: validate type
 		_type = type;
 	}
-	
+
 	private static class Style {
-		
+
 		private static final Style DEFAULT = new Style("default", DateFormat.DEFAULT);
 		private static final Style MEDIUM = new Style("medium", DateFormat.MEDIUM);
 		private static final Style SHORT = new Style("short", DateFormat.SHORT);
 		private static final Style LONG = new Style("long", DateFormat.LONG);
 		private static final Style FULL = new Style("full", DateFormat.FULL);
-		
+
 		private static final Style[] values = new Style[] {DEFAULT, MEDIUM, SHORT, LONG, FULL};
-		
+
 		public static Style getStyle(String name) {
 			for(int i = 0;i < values.length;i++) {
 				if(values[i]._name.equals(name)) {
 					return values[i];
 				}
 			}
-			
+
 			throw new ConverterException("invalid style '" + name + "'");
 		}
-		
+
 		private static int getStyleFormat(String name) {
 			return getStyle(name).getFormat();
 		}
-		
+
 		private String _name;
 		private int _format;
-		
+
 		private Style(String name, int format) {
 			this._name = name;
 			this._format = format;
 		}
-		
+
 		public String getName() {
 			return _name;
 		}
-		
+
 		public int getFormat() {
 			return _format;
 		}
 	}
-	
+
 	private abstract static class Type {
-		
+
 		private static final Type DATE = new Type("date") {
 			public DateFormat getFormatter(int dateStyle, int timeStyle, Locale locale) {
 				return DateFormat.getDateInstance(dateStyle, locale);
@@ -240,7 +278,7 @@
 				return DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale);
 			}
 		};
-		
+
 		private static final Type[] values = new Type[] {DATE, TIME, BOTH};
 
 		public static Type getType(String name) {
@@ -249,20 +287,20 @@
 					return values[i];
 				}
 			}
-			
+
 			throw new ConverterException("invalid type '" + name + "'");
 		}
-		
+
 		private String _name;
-		
+
 		private Type(String name) {
 			this._name = name;
 		}
-		
+
 		public String getName() {
 			return _name;
 		}
-		
+
 		public abstract DateFormat getFormatter(int dateStyle, int timeStyle, Locale locale);
 	}
 }

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/convert/DoubleConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/convert/DoubleConverter.java?view=diff&rev=472102&r1=472101&r2=472102
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/convert/DoubleConverter.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/convert/DoubleConverter.java Tue Nov  7 05:31:48 2006
@@ -15,28 +15,77 @@
  */
 package javax.faces.convert;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
 /**
  * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
  *
  * @author Thomas Spiegl (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class DoubleConverter extends AbstractConverter {
+public class DoubleConverter
+        implements Converter
+{
+    // API FIELDS
 	// the wrong string javax.faces.DoubleTime is required to be compatible with JSF RI and its TCK tests
-	public static final String CONVERTER_ID = "javax.faces.DoubleTime";
+    public static final String CONVERTER_ID = "javax.faces.DoubleTime";
+
+
+    private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.DoubleConverter.CONVERSION";
+
+
+    // CONSTRUCTORS
+    public DoubleConverter()
+    {
+    }
+
+    // METHODS
+    public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+        if (value != null)
+        {
+            value = value.trim();
+            if (value.length() > 0)
+            {
+                try
+                {
+                    return Double.valueOf(value);
+                }
+                catch (NumberFormatException e)
+                {
+                    throw new ConverterException(_MessageUtils.getErrorMessage(facesContext,
+                                                                               CONVERSION_MESSAGE_ID,
+                                                                               new Object[]{uiComponent.getId(),value}), e);
+                }
+            }
+        }
+        return null;
+    }
 
-	private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.DoubleConverter.CONVERSION";
+    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
 
-	// Methods implementation
-	protected Object getAsObject(String value) {
-		return Double.valueOf(value);
-	}
-
-	protected String getAsString(Object value) {
-		return Double.toString(((Number) value).doubleValue());
-	}
-
-	protected String getConversionMessageId() {
-		return CONVERSION_MESSAGE_ID;
-	}
+        if (value == null)
+        {
+            return "";
+        }
+        if (value instanceof String)
+        {
+            return (String)value;
+        }
+        try
+        {
+            return Double.toString(((Number)value).doubleValue());
+        }
+        catch (Exception e)
+        {
+            throw new ConverterException(e);
+        }
+    }
 }

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/convert/FloatConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/convert/FloatConverter.java?view=diff&rev=472102&r1=472101&r2=472102
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/convert/FloatConverter.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/convert/FloatConverter.java Tue Nov  7 05:31:48 2006
@@ -15,27 +15,74 @@
  */
 package javax.faces.convert;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
 /**
  * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
  *
  * @author Thomas Spiegl (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class FloatConverter extends AbstractConverter {
-	private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.FloatConverter.CONVERSION";
+public class FloatConverter
+        implements Converter
+{
+    private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.FloatConverter.CONVERSION";
+
+    // FIELDS
+    public static final String CONVERTER_ID = "javax.faces.Float";
+
+    // CONSTRUCTORS
+    public FloatConverter()
+    {
+    }
+
+    // METHODS
+    public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+        if (value != null)
+        {
+            value = value.trim();
+            if (value.length() > 0)
+            {
+                try
+                {
+                    return Float.valueOf(value);
+                }
+                catch (NumberFormatException e)
+                {
+                    throw new ConverterException(_MessageUtils.getErrorMessage(facesContext,
+                                                                               CONVERSION_MESSAGE_ID,
+                                                                               new Object[]{uiComponent.getId(),value}), e);
+                }
+            }
+        }
+        return null;
+    }
 
-	public static final String CONVERTER_ID = "javax.faces.Float";
+    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
 
-	// Methods implementation
-	protected Object getAsObject(String value) {
-		return Float.valueOf(value);
-	}
-
-	protected String getAsString(Object value) {
-		return Float.toString(((Number) value).floatValue());
-	}
-
-	protected String getConversionMessageId() {
-		return CONVERSION_MESSAGE_ID;
-	}
+        if (value == null)
+        {
+            return "";
+        }
+        if (value instanceof String)
+        {
+            return (String)value;
+        }
+        try
+        {
+            return Float.toString(((Number)value).floatValue());
+        }
+        catch (Exception e)
+        {
+            throw new ConverterException(e);
+        }
+    }
 }

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/convert/IntegerConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/convert/IntegerConverter.java?view=diff&rev=472102&r1=472101&r2=472102
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/convert/IntegerConverter.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/convert/IntegerConverter.java Tue Nov  7 05:31:48 2006
@@ -15,27 +15,74 @@
  */
 package javax.faces.convert;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
 /**
  * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
  *
  * @author Thomas Spiegl (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class IntegerConverter extends AbstractConverter {
-	private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.IntegerConverter.CONVERSION";
+public class IntegerConverter
+        implements Converter
+{
+    private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.IntegerConverter.CONVERSION";
+
+    // FIELDS
+    public static final String CONVERTER_ID = "javax.faces.Integer";
+
+    // CONSTRUCTORS
+    public IntegerConverter()
+    {
+    }
+
+    // METHODS
+    public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+        if (value != null)
+        {
+            value = value.trim();
+            if (value.length() > 0)
+            {
+                try
+                {
+                    return Integer.valueOf(value);
+                }
+                catch (NumberFormatException e)
+                {
+                    throw new ConverterException(_MessageUtils.getErrorMessage(facesContext,
+                                                                               CONVERSION_MESSAGE_ID,
+                                                                               new Object[]{uiComponent.getId(),value}), e);
+                }
+            }
+        }
+        return null;
+    }
 
-	public static final String CONVERTER_ID = "javax.faces.Integer";
+    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
 
-	// Methods implementation
-	protected Object getAsObject(String value) {
-		return Integer.valueOf(value);
-	}
-
-	protected String getAsString(Object value) {
-		return Integer.toString(((Number) value).intValue());
-	}
-
-	protected String getConversionMessageId() {
-		return CONVERSION_MESSAGE_ID;
-	}
+        if (value == null)
+        {
+            return "";
+        }
+        if (value instanceof String)
+        {
+            return (String)value;
+        }
+        try
+        {
+            return Integer.toString(((Number)value).intValue());
+        }
+        catch (Exception e)
+        {
+            throw new ConverterException(e);
+        }
+    }
 }

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/convert/LongConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/convert/LongConverter.java?view=diff&rev=472102&r1=472101&r2=472102
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/convert/LongConverter.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/convert/LongConverter.java Tue Nov  7 05:31:48 2006
@@ -15,27 +15,74 @@
  */
 package javax.faces.convert;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
 /**
  * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
- * 
+ *
  * @author Thomas Spiegl (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class LongConverter extends AbstractConverter {
-	private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.LongConverter.CONVERSION";
+public class LongConverter
+        implements Converter
+{
+    private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.LongConverter.CONVERSION";
+
+    // FIELDS
+    public static final String CONVERTER_ID = "javax.faces.Long";
+
+    // CONSTRUCTORS
+    public LongConverter()
+    {
+    }
+
+    // METHODS
+    public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+        if (value != null)
+        {
+            value = value.trim();
+            if (value.length() > 0)
+            {
+                try
+                {
+                    return Long.valueOf(value);
+                }
+                catch (NumberFormatException e)
+                {
+                    throw new ConverterException(_MessageUtils.getErrorMessage(facesContext,
+                                                                               CONVERSION_MESSAGE_ID,
+                                                                               new Object[]{uiComponent.getId(),value}), e);
+                }
+            }
+        }
+        return null;
+    }
 
-	public static final String CONVERTER_ID = "javax.faces.Long";
+    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
 
-	// Methods implementation
-	protected Object getAsObject(String value) {
-		return Long.valueOf(value);
-	}
-
-	protected String getAsString(Object value) {
-		return Long.toString(((Number) value).longValue());
-	}
-
-	protected String getConversionMessageId() {
-		return CONVERSION_MESSAGE_ID;
-	}
+        if (value == null)
+        {
+            return "";
+        }
+        if (value instanceof String)
+        {
+            return (String)value;
+        }
+        try
+        {
+            return Long.toString(((Number)value).longValue());
+        }
+        catch (Exception e)
+        {
+            throw new ConverterException(e);
+        }
+    }
 }

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/convert/ShortConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/convert/ShortConverter.java?view=diff&rev=472102&r1=472101&r2=472102
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/convert/ShortConverter.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/convert/ShortConverter.java Tue Nov  7 05:31:48 2006
@@ -15,27 +15,74 @@
  */
 package javax.faces.convert;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
 /**
  * see Javadoc of <a href="http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/index.html">JSF Specification</a>
  *
  * @author Thomas Spiegl (latest modification by $Author$)
  * @version $Revision$ $Date$
  */
-public class ShortConverter extends AbstractConverter {
-	private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.ShortConverter.CONVERSION";
+public class ShortConverter
+        implements Converter
+{
+    private static final String CONVERSION_MESSAGE_ID = "javax.faces.convert.ShortConverter.CONVERSION";
+
+    // FIELDS
+    public static final String CONVERTER_ID = "javax.faces.Short";
+
+    // CONSTRUCTORS
+    public ShortConverter()
+    {
+    }
+
+    // METHODS
+    public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+        if (value != null)
+        {
+            value = value.trim();
+            if (value.length() > 0)
+            {
+                try
+                {
+                    return Short.valueOf(value);
+                }
+                catch (NumberFormatException e)
+                {
+                    throw new ConverterException(_MessageUtils.getErrorMessage(facesContext,
+                                                                               CONVERSION_MESSAGE_ID,
+                                                                               new Object[]{uiComponent.getId(),value}), e);
+                }
+            }
+        }
+        return null;
+    }
 
-	public static final String CONVERTER_ID = "javax.faces.Short";
+    public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object value)
+    {
+        if (facesContext == null) throw new NullPointerException("facesContext");
+        if (uiComponent == null) throw new NullPointerException("uiComponent");
 
-	// Methods implementation
-	protected Object getAsObject(String value) {
-		return Short.valueOf(value);
-	}
-
-	protected String getAsString(Object value) {
-		return Short.toString(((Number) value).shortValue());
-	}
-
-	protected String getConversionMessageId() {
-		return CONVERSION_MESSAGE_ID;
-	}
+        if (value == null)
+        {
+            return "";
+        }
+        if (value instanceof String)
+        {
+            return (String)value;
+        }
+        try
+        {
+            return Short.toString(((Number)value).shortValue());
+        }
+        catch (Exception e)
+        {
+            throw new ConverterException(e);
+        }
+    }
 }