| NumberFormatter - Handle null value and empty input [message #50144] | 
Thu, 28 February 2008 12:50  | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi, 
NumberFormatter does a good job. But I have two questions: 
1. Method NumberFormatter#setValue: 
... 
} else if ( value == null ) { 
      // Is not here: 
      // this.value = null; 
    	clearText(0, editValue.length()); 
 updateText(editValue.toString(), format(0)); 
}  
... 
Why is this.value not setted to null? 
 
2.  Method NumberFormatter#getValue, catch-Block: 
>} catch (ParseException e1) { 
> if ( zeroIntLen + zeroDecimalLen == 0  
>     && (editValue.length() == 0 || editValue.charAt(0) ==    
>               symbols.getDecimalSeparator()) ) { 
>       modified = false; 
>      value = new Integer(0); 
>			} else { 
... 
 
Why is this.value setted to Integer(0) and not to null? An empty String as  
input produces a '0'. Because of this, we have some problems in further  
calcualtions, because '0' is not the userinput and therefore produces a  
false result. When the input is an empty string, we would expect null as  
parsed Number.  
 
Thanks, 
Leo
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.26759 seconds