Package org.jboss.common.beans.property
Class PropertyEditorSupport<T>
- java.lang.Object
-
- java.beans.PropertyEditorSupport
-
- org.jboss.common.beans.property.PropertyEditorSupport<T>
-
- All Implemented Interfaces:
java.beans.PropertyEditor
,PropertyEditor<T>
- Direct Known Subclasses:
AtomicBooleanEditor
,AtomicIntegerEditor
,AtomicLongEditor
,BigDecimalEditor
,BigIntegerEditor
,BooleanEditor
,ByteEditor
,CharacterEditor
,ClassEditor
,DateEditor
,DoubleEditor
,FileEditor
,FloatEditor
,GenericArrayPropertyEditor
,InetAddressEditor
,IntegerEditor
,LocaleEditor
,LongEditor
,ObjectNameEditor
,PropertiesEditor
,ShortEditor
,StringEditor
,URIEditor
,URLEditor
,XMLEditorSupport
public abstract class PropertyEditorSupport<T> extends java.beans.PropertyEditorSupport implements PropertyEditor<T>
-
-
Constructor Summary
Constructors Constructor Description PropertyEditorSupport(java.lang.Class<T> type)
Creates PropertyEditorSupport instance.PropertyEditorSupport(java.lang.Class<T> type, java.lang.Object source)
Creates PropertyEditorSupport instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
void
addPropertyChangeListener(PropertyChangeListener<T> listener)
Adds a listener for the value change.void
firePropertyChange(T oldValue, T newValue)
java.lang.String
getAsText()
Gets the property value as text.protected java.lang.Class<T>
getType()
T
getValue()
Gets the property value.void
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
void
removePropertyChangeListener(PropertyChangeListener<T> listener)
Removes a listener for the value change.abstract void
setAsText(java.lang.String text)
Set the property value by parsing a given String.void
setValue(java.lang.Object value)
Set (or change) the object that is to be edited.
-
-
-
Constructor Detail
-
PropertyEditorSupport
public PropertyEditorSupport(java.lang.Class<T> type)
Creates PropertyEditorSupport instance. Requires T class to enforce runtime type checks.
-
PropertyEditorSupport
public PropertyEditorSupport(java.lang.Class<T> type, java.lang.Object source)
Creates PropertyEditorSupport instance. Requires T class to enforce runtime type checks and a source.
-
-
Method Detail
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener<T> listener)
Description copied from interface:PropertyEditor
Adds a listener for the value change. When the property editor changes its value it should fire aPropertyChangeEvent
on all registeredPropertyChangeListener
s, specifying thenull
value for the property name and itself as the source.- Specified by:
addPropertyChangeListener
in interfacePropertyEditor<T>
- Parameters:
listener
- thePropertyChangeListener
to add
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
- Specified by:
addPropertyChangeListener
in interfacejava.beans.PropertyEditor
- Overrides:
addPropertyChangeListener
in classjava.beans.PropertyEditorSupport
-
getAsText
public java.lang.String getAsText()
Description copied from interface:PropertyEditor
Gets the property value as text.- Specified by:
getAsText
in interfacejava.beans.PropertyEditor
- Specified by:
getAsText
in interfacePropertyEditor<T>
- Overrides:
getAsText
in classjava.beans.PropertyEditorSupport
- Returns:
- The property value as a human editable string.
Returns null if the value can't be expressed as an editable string.
If a non-null value is returned, then the PropertyEditor should be prepared to parse that string back in setAsText().
-
getValue
public T getValue()
Description copied from interface:PropertyEditor
Gets the property value.- Specified by:
getValue
in interfacejava.beans.PropertyEditor
- Specified by:
getValue
in interfacePropertyEditor<T>
- Overrides:
getValue
in classjava.beans.PropertyEditorSupport
- Returns:
- The value of the property. Primitive types such as "int" will be wrapped as the corresponding object type such as "java.lang.Integer".
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener<T> listener)
Description copied from interface:PropertyEditor
Removes a listener for the value change.- Specified by:
removePropertyChangeListener
in interfacePropertyEditor<T>
- Parameters:
listener
- thePropertyChangeListener
to remove
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
- Specified by:
removePropertyChangeListener
in interfacejava.beans.PropertyEditor
- Overrides:
removePropertyChangeListener
in classjava.beans.PropertyEditorSupport
-
setValue
public void setValue(java.lang.Object value)
Description copied from interface:PropertyEditor
Set (or change) the object that is to be edited. Primitive types such as "int" must be wrapped as the corresponding object type such as "java.lang.Integer".- Specified by:
setValue
in interfacejava.beans.PropertyEditor
- Specified by:
setValue
in interfacePropertyEditor<T>
- Overrides:
setValue
in classjava.beans.PropertyEditorSupport
- Parameters:
value
- The new target object to be edited. Note that this object should not be modified by the PropertyEditor, rather the PropertyEditor should create a new object to hold any modified value.
-
getType
protected java.lang.Class<T> getType()
-
setAsText
public abstract void setAsText(java.lang.String text) throws java.lang.IllegalArgumentException
Description copied from interface:PropertyEditor
Set the property value by parsing a given String. May raise java.lang.IllegalArgumentException if either the String is badly formatted or if this kind of property can't be expressed as text.- Specified by:
setAsText
in interfacejava.beans.PropertyEditor
- Specified by:
setAsText
in interfacePropertyEditor<T>
- Overrides:
setAsText
in classjava.beans.PropertyEditorSupport
- Parameters:
text
- The string to be parsed.- Throws:
java.lang.IllegalArgumentException
-
-