|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| NumberEditor.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* EJTools, the Enterprise Java Tools
|
|
| 3 |
*
|
|
| 4 |
* Distributable under LGPL license.
|
|
| 5 |
* See terms of license at www.gnu.org.
|
|
| 6 |
*/
|
|
| 7 |
package org.ejtools.adwt.editor;
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
/**
|
|
| 11 |
* Description of the Class
|
|
| 12 |
*
|
|
| 13 |
* @author Laurent Etiemble
|
|
| 14 |
* @version $Revision: 1.5 $
|
|
| 15 |
* @todo Javadoc to complete
|
|
| 16 |
*/
|
|
| 17 |
public class NumberEditor extends GenericEditor |
|
| 18 |
{
|
|
| 19 |
/** Description of the Field */
|
|
| 20 |
protected Class clazz = Number.class; |
|
| 21 |
|
|
| 22 |
|
|
| 23 |
/** Constructor */
|
|
| 24 | 0 |
public NumberEditor()
|
| 25 |
{
|
|
| 26 | 0 |
this.value = new Integer(0); |
| 27 |
} |
|
| 28 |
|
|
| 29 |
|
|
| 30 |
/**
|
|
| 31 |
* Getter for the asText attribute
|
|
| 32 |
*
|
|
| 33 |
* @return The value
|
|
| 34 |
*/
|
|
| 35 | 0 |
public String getAsText()
|
| 36 |
{
|
|
| 37 | 0 |
return value.toString();
|
| 38 |
} |
|
| 39 |
|
|
| 40 |
|
|
| 41 |
/**
|
|
| 42 |
* Setter for the asText attribute
|
|
| 43 |
*
|
|
| 44 |
* @param s The new value
|
|
| 45 |
*/
|
|
| 46 | 0 |
public void setAsText(String s) |
| 47 |
{
|
|
| 48 | 0 |
if (this.clazz.equals(Integer.class)) |
| 49 |
{
|
|
| 50 | 0 |
this.value = new Integer(s); |
| 51 |
} |
|
| 52 | 0 |
else if (this.clazz.equals(Float.class)) |
| 53 |
{
|
|
| 54 | 0 |
this.value = new Float(s); |
| 55 |
} |
|
| 56 | 0 |
else if (this.clazz.equals(Double.class)) |
| 57 |
{
|
|
| 58 | 0 |
this.value = new Double(s); |
| 59 |
} |
|
| 60 | 0 |
else if (this.clazz.equals(Byte.class)) |
| 61 |
{
|
|
| 62 | 0 |
this.value = new Byte(s); |
| 63 |
} |
|
| 64 | 0 |
else if (this.clazz.equals(Short.class)) |
| 65 |
{
|
|
| 66 | 0 |
this.value = new Short(s); |
| 67 |
} |
|
| 68 | 0 |
else if (this.clazz.equals(Long.class)) |
| 69 |
{
|
|
| 70 | 0 |
this.value = new Long(s); |
| 71 |
} |
|
| 72 | 0 |
this.firePropertyChange();
|
| 73 |
} |
|
| 74 |
|
|
| 75 |
|
|
| 76 |
/**
|
|
| 77 |
* Setter for the value attribute
|
|
| 78 |
*
|
|
| 79 |
* @param object The new value value
|
|
| 80 |
*/
|
|
| 81 | 0 |
public void setValue(Object object) |
| 82 |
{
|
|
| 83 | 0 |
super.setValue(object);
|
| 84 | 0 |
this.clazz = object.getClass();
|
| 85 |
} |
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
|
|
||||||||||