Package com.vaadin.v7.data.util
Class PropertyFormatter<T>
- java.lang.Object
-
- com.vaadin.v7.data.util.AbstractProperty<java.lang.String>
-
- com.vaadin.v7.data.util.PropertyFormatter<T>
-
- All Implemented Interfaces:
com.vaadin.event.SerializableEventListener
,Property<java.lang.String>
,Property.ReadOnlyStatusChangeListener
,Property.ReadOnlyStatusChangeNotifier
,Property.ValueChangeListener
,Property.ValueChangeNotifier
,Property.Viewer
,java.io.Serializable
,java.util.EventListener
@Deprecated public abstract class PropertyFormatter<T> extends AbstractProperty<java.lang.String> implements Property.Viewer, Property.ValueChangeListener, Property.ReadOnlyStatusChangeListener
Deprecated.As of 7.0, replaced byConverter
Formatting proxy for aProperty
.This class can be used to implement formatting for any type of Property datasources. The idea is to connect this as proxy between UI component and the original datasource.
For example:textfield.setPropertyDataSource(new PropertyFormatter(property) { public String format(Object value) { return ((Double) value) + "000000000"; } public Object parse(String formattedValue) throws Exception { return Double.parseDouble(formattedValue); } });
adds formatter for Double-typed property that extends standard "1.0" notation with more zeroes.- Since:
- 5.3.0
- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.vaadin.v7.data.util.AbstractProperty
AbstractProperty.ReadOnlyStatusChangeEvent
-
Nested classes/interfaces inherited from interface com.vaadin.v7.data.Property
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PropertyFormatter()
Deprecated.Construct a newPropertyFormatter
that is not connected to any data source.PropertyFormatter(Property<T> propertyDataSource)
Deprecated.Construct a new formatter that is connected to given data source.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract java.lang.String
format(T value)
Deprecated.This method must be implemented to format the values received from DataSource.Property<T>
getPropertyDataSource()
Deprecated.Gets the current data source of the formatter, if any.java.lang.Class<java.lang.String>
getType()
Deprecated.Returns the type of the Property.java.lang.String
getValue()
Deprecated.Get the formatted value.boolean
isReadOnly()
Deprecated.Reflects the read-only status of the datasource.abstract T
parse(java.lang.String formattedValue)
Deprecated.Parse string and convert it to format compatible with datasource.void
readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event)
Deprecated.Listens for changes in the datasource.void
setPropertyDataSource(Property newDataSource)
Deprecated.Sets the specified Property as the data source for the formatter.void
setReadOnly(boolean newStatus)
Deprecated.Sets the Property's read-only mode to the specified status.void
setValue(java.lang.String newValue)
Deprecated.Sets the value of the Property.void
valueChange(Property.ValueChangeEvent event)
Deprecated.Listens for changes in the datasource.-
Methods inherited from class com.vaadin.v7.data.util.AbstractProperty
addListener, addListener, addReadOnlyStatusChangeListener, addValueChangeListener, fireReadOnlyStatusChange, fireValueChange, getListeners, removeListener, removeListener, removeReadOnlyStatusChangeListener, removeValueChangeListener
-
-
-
-
Constructor Detail
-
PropertyFormatter
protected PropertyFormatter()
Deprecated.Construct a newPropertyFormatter
that is not connected to any data source. CallsetPropertyDataSource(Property)
later on to attach it to a property.
-
PropertyFormatter
public PropertyFormatter(Property<T> propertyDataSource)
Deprecated.Construct a new formatter that is connected to given data source. Callsformat(Object)
which can be a problem if the formatter has not yet been initialized.- Parameters:
propertyDataSource
- to connect this property to.
-
-
Method Detail
-
getPropertyDataSource
public Property<T> getPropertyDataSource()
Deprecated.Gets the current data source of the formatter, if any.- Specified by:
getPropertyDataSource
in interfaceProperty.Viewer
- Returns:
- the current data source as a Property, or
null
if none defined.
-
setPropertyDataSource
public void setPropertyDataSource(Property newDataSource)
Deprecated.Sets the specified Property as the data source for the formatter.Remember that new data sources getValue() must return objects that are compatible with parse() and format() methods.
- Specified by:
setPropertyDataSource
in interfaceProperty.Viewer
- Parameters:
newDataSource
- the new data source Property.
-
getType
public java.lang.Class<java.lang.String> getType()
Deprecated.Description copied from interface:Property
Returns the type of the Property. The methodsgetValue
andsetValue
must be compatible with this type: one must be able to safely cast the value returned fromgetValue
to the given type and pass any variable assignable to this type as an argument tosetValue
.
-
getValue
public java.lang.String getValue()
Deprecated.Get the formatted value.
-
isReadOnly
public boolean isReadOnly()
Deprecated.Reflects the read-only status of the datasource.- Specified by:
isReadOnly
in interfaceProperty<T>
- Overrides:
isReadOnly
in classAbstractProperty<java.lang.String>
- Returns:
true
if the Property is in read-only mode,false
if it's not
-
format
public abstract java.lang.String format(T value)
Deprecated.This method must be implemented to format the values received from DataSource.- Parameters:
value
- Value object got from the datasource. This is guaranteed to be non-null and of the type compatible with getType() of the datasource.- Returns:
-
parse
public abstract T parse(java.lang.String formattedValue) throws java.lang.Exception
Deprecated.Parse string and convert it to format compatible with datasource. The method is required to assure that parse(format(x)) equals x.- Parameters:
formattedValue
- This is guaranteed to be non-null string.- Returns:
- Non-null value compatible with datasource.
- Throws:
java.lang.Exception
- Any type of exception can be thrown to indicate that the conversion was not succesful.
-
setReadOnly
public void setReadOnly(boolean newStatus)
Deprecated.Sets the Property's read-only mode to the specified status.- Specified by:
setReadOnly
in interfaceProperty<T>
- Overrides:
setReadOnly
in classAbstractProperty<java.lang.String>
- Parameters:
newStatus
- the new read-only status of the Property.
-
setValue
public void setValue(java.lang.String newValue) throws Property.ReadOnlyException
Deprecated.Description copied from interface:Property
Sets the value of the Property.Implementing this functionality is optional. If the functionality is missing, one should declare the Property to be in read-only mode and throw
Note : Since Vaadin 7.0, setting the value of a non-String property as a String is no longer supported.Property.ReadOnlyException
in this function.- Specified by:
setValue
in interfaceProperty<T>
- Parameters:
newValue
- New value of the Property. This should be assignable to the type returned by getType- Throws:
Property.ReadOnlyException
- if the object is in read-only mode
-
valueChange
public void valueChange(Property.ValueChangeEvent event)
Deprecated.Listens for changes in the datasource. This should not be called directly.- Specified by:
valueChange
in interfaceProperty.ValueChangeListener
- Parameters:
event
- value change event object
-
readOnlyStatusChange
public void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event)
Deprecated.Listens for changes in the datasource. This should not be called directly.- Specified by:
readOnlyStatusChange
in interfaceProperty.ReadOnlyStatusChangeListener
- Parameters:
event
- Read-only status change event object
-
-