Groovy Documentation

org.grails.plugin.vaadin.utils
[Groovy] Class PropertyConverter

java.lang.Object
  com.vaadin.data.util.AbstractProperty
      org.grails.plugin.vaadin.utils.PropertyConverter
All Implemented Interfaces:
Property.Viewer, Property.ValueChangeListener, Property.ReadOnlyStatusChangeListener

@SuppressWarnings("serial")
abstract class PropertyConverter
extends AbstractProperty

Copy of PropertyFormatter

However, while PropertyFormatter requires the type to be String, this class is more general-purpose, allowing any type to be converted to any type.

In fact, PropertyFormatter could easily be rewritten to subclass this class.

Also, this class allows chaining of property converters, whereas PropertyFormatter does not.

Authors:
Francis McKenzie


Property Summary
Property dataSource

Datasource that stores the actual value.

 
Constructor Summary
protected PropertyConverter()

Construct a new PropertyConverter that is not connected to any data source.

PropertyConverter(Property propertyDataSource)

Construct a new converter that is connected to given data source.

 
Method Summary
CONVERTED convert(Object value)

This method must be implemented to convert the values received from DataSource.

Property getPropertyDataSource()

Gets the current data source of the converter, if any.

Class getType()

Object getValue()

Get the converted value.

boolean isReadOnly()

Reflects the read-only status of the datasource.

void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event)

Listens for changes in the datasource.

ORIGINAL restore(Object value)

Parse object and convert it to type compatible with datasource.

void setPropertyDataSource(Property newDataSource)

Sets the specified Property as the data source for the converter.

void setReadOnly(boolean newStatus)

Sets the Property's read-only mode to the specified status.

void setValue(Object newValue)

String toString()

Get the string representation of the converted value.

void valueChange(Property.ValueChangeEvent event)

Listens for changes in the datasource.

 
Methods inherited from class AbstractProperty
toString, setReadOnly, isReadOnly, getListeners, addListener, addListener, removeListener, removeListener, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll, getValue, getType, setValue
 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Property Detail

dataSource

Property dataSource
Datasource that stores the actual value.


 
Constructor Detail

PropertyConverter

protected PropertyConverter()
Construct a new PropertyConverter that is not connected to any data source. Call setPropertyDataSource(Property) later on to attach it to a property.


PropertyConverter

PropertyConverter(Property propertyDataSource)
Construct a new converter that is connected to given data source. Calls format(Object) which can be a problem if the converter has not yet been initialized.
Parameters:
propertyDataSource - to connect this property to.


 
Method Detail

convert

CONVERTED convert(Object value)
This method must be implemented to convert the values received from DataSource. The method is required to assure that convert(restore(x)) equals x.
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:


getPropertyDataSource

Property getPropertyDataSource()
Gets the current data source of the converter, if any.
Returns:
the current data source as a Property, or null if none defined.


getType

@SuppressWarnings("unchecked")
Class getType()


getValue

Object getValue()
Get the converted value.
Returns:
If the datasource returns null, this is null. Otherwise this is CONVERTED object given by convert().


isReadOnly

@Override
boolean isReadOnly()
Reflects the read-only status of the datasource.


readOnlyStatusChange

void readOnlyStatusChange(Property.ReadOnlyStatusChangeEvent event)
Listens for changes in the datasource. This should not be called directly.


restore

ORIGINAL restore(Object value)
Parse object and convert it to type compatible with datasource. The method is required to assure that restore(convert(x)) equals x.
throws:
Exception Any type of exception can be thrown to indicate that the conversion was not successful.
Parameters:
value - This is guaranteed to be non-null object.
Returns:
Non-null value compatible with datasource.


setPropertyDataSource

void setPropertyDataSource(Property newDataSource)
Sets the specified Property as the data source for the converter.

Remember that new data sources getValue() must return objects that are compatible with convert() and restore() methods.

Parameters:
newDataSource - the new data source Property.


setReadOnly

@Override
void setReadOnly(boolean newStatus)
Sets the Property's read-only mode to the specified status.
Parameters:
newStatus - the new read-only status of the Property.


setValue

void setValue(Object newValue)


toString

@Override
String toString()
Get the string representation of the converted value.
Returns:
If the datasource returns null, this is null. Otherwise this is String given by convert().toString().


valueChange

void valueChange(Property.ValueChangeEvent event)
Listens for changes in the datasource. This should not be called directly.


 

Groovy Documentation