KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > adwt > editor > NumberEditor


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 JavaDoc clazz = Number JavaDoc.class;
21
22
23    /** Constructor */
24    public NumberEditor()
25    {
26       this.value = new Integer JavaDoc(0);
27    }
28
29
30    /**
31     * Getter for the asText attribute
32     *
33     * @return The value
34     */

35    public String JavaDoc getAsText()
36    {
37       return value.toString();
38    }
39
40
41    /**
42     * Setter for the asText attribute
43     *
44     * @param s The new value
45     */

46    public void setAsText(String JavaDoc s)
47    {
48       if (this.clazz.equals(Integer JavaDoc.class))
49       {
50          this.value = new Integer JavaDoc(s);
51       }
52       else if (this.clazz.equals(Float JavaDoc.class))
53       {
54          this.value = new Float JavaDoc(s);
55       }
56       else if (this.clazz.equals(Double JavaDoc.class))
57       {
58          this.value = new Double JavaDoc(s);
59       }
60       else if (this.clazz.equals(Byte JavaDoc.class))
61       {
62          this.value = new Byte JavaDoc(s);
63       }
64       else if (this.clazz.equals(Short JavaDoc.class))
65       {
66          this.value = new Short JavaDoc(s);
67       }
68       else if (this.clazz.equals(Long JavaDoc.class))
69       {
70          this.value = new Long JavaDoc(s);
71       }
72       this.firePropertyChange();
73    }
74
75
76    /**
77     * Setter for the value attribute
78     *
79     * @param object The new value value
80     */

81    public void setValue(Object JavaDoc object)
82    {
83       super.setValue(object);
84       this.clazz = object.getClass();
85    }
86 }
87
88
Popular Tags