JBoss Common Beans 1.1.0.Final-redhat-1

org.jboss.common.beans.property
Class PropertyEditorSupport<T>

java.lang.Object
  extended by java.beans.PropertyEditorSupport
      extended by org.jboss.common.beans.property.PropertyEditorSupport<T>
All Implemented Interfaces:
PropertyEditor
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 PropertyEditorSupport
implements PropertyEditor<T>

Author:
Carlo de Wolf, baranowb

Constructor Summary
PropertyEditorSupport(Class<T> type)
          Creates PropertyEditorSupport instance.
PropertyEditorSupport(Class<T> type, Object source)
          Creates PropertyEditorSupport instance.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 void addPropertyChangeListener(PropertyChangeListener<T> listener)
          Adds a listener for the value change.
 void firePropertyChange(T oldValue, T newValue)
           
 String getAsText()
          Gets the property value as text.
protected  Class<T> getType()
           
 T getValue()
          Gets the property value.
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 void removePropertyChangeListener(PropertyChangeListener<T> listener)
          Removes a listener for the value change.
abstract  void setAsText(String text)
          Set the property value by parsing a given String.
 void setValue(Object value)
          Set (or change) the object that is to be edited.
 
Methods inherited from class java.beans.PropertyEditorSupport
firePropertyChange, getCustomEditor, getJavaInitializationString, getSource, getTags, isPaintable, paintValue, setSource, supportsCustomEditor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyEditorSupport

public PropertyEditorSupport(Class<T> type)
Creates PropertyEditorSupport instance. Requires T class to enforce runtime type checks.


PropertyEditorSupport

public PropertyEditorSupport(Class<T> type,
                             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 a PropertyChangeEvent on all registered PropertyChangeListeners, specifying the null value for the property name and itself as the source.

Parameters:
listener - the PropertyChangeListener to add

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface PropertyEditor
Overrides:
addPropertyChangeListener in class PropertyEditorSupport

getAsText

public String getAsText()
Description copied from interface: PropertyEditor
Gets the property value as text.

Specified by:
getAsText in interface PropertyEditor
Overrides:
getAsText in class 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 interface PropertyEditor
Overrides:
getValue in class 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.

Parameters:
listener - the PropertyChangeListener to remove

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Specified by:
removePropertyChangeListener in interface PropertyEditor
Overrides:
removePropertyChangeListener in class PropertyEditorSupport

setValue

public void setValue(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 interface PropertyEditor
Overrides:
setValue in class 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.

firePropertyChange

public void firePropertyChange(T oldValue,
                               T newValue)

getType

protected Class<T> getType()

setAsText

public abstract void setAsText(String text)
                        throws 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 interface PropertyEditor
Overrides:
setAsText in class PropertyEditorSupport
Parameters:
text - The string to be parsed.
Throws:
IllegalArgumentException

JBoss Common Beans 1.1.0.Final-redhat-1

Copyright © 2013 JBoss by Red Hat. All Rights Reserved.