KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > setup > util > PropertyEditorBase


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.setup.util;
10
11
12 import java.beans.PropertyEditor JavaDoc;
13 import java.beans.PropertyEditorSupport JavaDoc;
14
15 /**
16  * @author <a HREF="mailto:palber@novell.com">Polina Alber</a>
17  * Date: Apr 15, 2005; Time: 11:50:47 AM
18  * @since JBoss portal 2.0
19  * Class org.jboss.portal.setup.util.PropertyEditorBase - Base abstract PropertEditor implementation.
20  * Used as a base class for all Concrete PropertyEditor implementations.
21  */

22 public abstract class PropertyEditorBase extends PropertyEditorSupport JavaDoc implements PropertyEditor JavaDoc
23 {
24
25    private Object JavaDoc m_value = null;
26    private String JavaDoc m_strValue = null;
27    private Class JavaDoc m_class = null;
28
29    /**
30     * @see PropertyEditor#getValue()
31     */

32    public Object JavaDoc getValue()
33    {
34       return m_value;
35    }
36
37    /**
38     * @see PropertyEditor#setValue(Object)
39     */

40    public void setValue(Object JavaDoc o)
41    {
42       m_value = o;
43       m_strValue = converToString(o);
44    }
45
46    /**
47     * @see PropertyEditor#getAsText()
48     */

49    public String JavaDoc getAsText()
50    {
51       return m_strValue;
52    }
53
54    /**
55     * @see PropertyEditor#setAsText(String)
56     */

57    public void setAsText(String JavaDoc s) throws IllegalArgumentException JavaDoc
58    {
59       m_strValue = s;
60       m_value = convertToValue(s);
61    }
62
63    /**
64     * @param value - object value to be converted to a String.
65     * @return String representation of a specified value.
66     */

67    protected abstract String JavaDoc converToString(Object JavaDoc value);
68
69    /**
70     * @param strValue - string representation of a value to be converted to a String
71     * @return an Object representation of a String value.
72     */

73    protected abstract Object JavaDoc convertToValue(String JavaDoc strValue);
74
75    /**
76     * @param type - Class of an object supported by this property editor.
77     */

78    protected void setClassType(Class JavaDoc type)
79    {
80       m_class = type;
81    }
82
83
84 }
85
Popular Tags