org.viewaframework.binding.core
Class BasicBeanAdapter<T>

java.lang.Object
  extended by org.viewaframework.binding.core.BasicBeanAdapter<T>
Type Parameters:
T -
All Implemented Interfaces:
Adapter<T>, BeanAdapter<T>, Observable
Direct Known Subclasses:
LazyBeanAdapter

public class BasicBeanAdapter<T>
extends Object
implements BeanAdapter<T>

Default implementation of BeanAdapter

Author:
Mario Garcia

Constructor Summary
BasicBeanAdapter()
          Default constructor
BasicBeanAdapter(T source)
          Constructor that receives a JavaBean object as parameter
BasicBeanAdapter(T source, String name)
          Constructor that receives a JavaBean object as parameter, and a name for monitoring purposes
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          This method adds listeners registering all modifications made to registered properties.
 boolean equals(Object object)
           
 void firePropertyChange(PropertyChangeEvent evt)
          Fires an event of a specific property
 String getName()
          Returns the name of the adapter
 List<PropertyChangeListener> getPropertyChangeListeners()
          Returns a list of PropertyChangeListener objects
 Class<?> getPropertyClass(String propertyName)
          Returns the class of the property name passed as parameter
 T getSource()
          Returns the source this adapter is taken care of
<U> U
getValue(Class<U> clazz, String propertyName)
          Returns the value of the desired property with the type passed as parameter
<U> List<U>
getValueList(Class<U> clazz, String propertyName)
          Returs the property value as a List
<K,V> Map<K,V>
getValueMap(Class<K> clazzKey, Class<V> clazzValue, String propertyName)
          Returns the value as a java.util.Map
<U> Set<U>
getValueSet(Class<U> clazz, String propertyName)
          Returns the value as a java.util.Set
 String getValueString(String propertyName)
          Returns the string representation of the property
 int hashCode()
           
 boolean isSync(Adapter<T> src)
          Returns true if the current object is synchronized with the object passed as parameter
 void removePropertyChangeListener(PropertyChangeListener listener)
          This method removes listeners registering all modifications made to registered properties.
 void setName(String name)
          Sets the name of the adapter
 void setSource(T source)
          Sets the source object
<V> BasicBeanAdapter<T>
setValue(Class<V> clazz, String propertyName, V value)
          Sets the property value
 BasicBeanAdapter<T> setValue(String propertyName, Object value)
          Sets the property value
 void sync(Adapter<T> value)
          Synchronizes all values of the current bean with the bean passed as parameter.
 void sync(Adapter<T> src, Property srcProperty, Property dstProperty)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicBeanAdapter

public BasicBeanAdapter()
Default constructor


BasicBeanAdapter

public BasicBeanAdapter(T source)
Constructor that receives a JavaBean object as parameter

Parameters:
target -

BasicBeanAdapter

public BasicBeanAdapter(T source,
                        String name)
Constructor that receives a JavaBean object as parameter, and a name for monitoring purposes

Parameters:
source -
name -
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: Observable
This method adds listeners registering all modifications made to registered properties.

Specified by:
addPropertyChangeListener in interface Observable

equals

public boolean equals(Object object)
Overrides:
equals in class Object

firePropertyChange

public void firePropertyChange(PropertyChangeEvent evt)
Description copied from interface: Observable
Fires an event of a specific property

Specified by:
firePropertyChange in interface Observable
Parameters:
evt - Triggered event

getName

public String getName()
Description copied from interface: Adapter
Returns the name of the adapter

Specified by:
getName in interface Adapter<T>
Returns:
The name of the adapter

getPropertyChangeListeners

public List<PropertyChangeListener> getPropertyChangeListeners()
Description copied from interface: Observable
Returns a list of PropertyChangeListener objects

Specified by:
getPropertyChangeListeners in interface Observable
Returns:
PropertyChangeListener list

getPropertyClass

public Class<?> getPropertyClass(String propertyName)
Description copied from interface: BeanAdapter
Returns the class of the property name passed as parameter

Specified by:
getPropertyClass in interface BeanAdapter<T>
Parameters:
propertyName - The name of the property
Returns:
the type of the property

getSource

public T getSource()
Description copied from interface: Adapter
Returns the source this adapter is taken care of

Specified by:
getSource in interface Adapter<T>
Returns:

getValue

public <U> U getValue(Class<U> clazz,
                      String propertyName)
Description copied from interface: BeanAdapter
Returns the value of the desired property with the type passed as parameter

Specified by:
getValue in interface BeanAdapter<T>
Type Parameters:
U - returned object
Parameters:
clazz - the desired type
propertyName - the property name
Returns:
the property value

getValueList

public <U> List<U> getValueList(Class<U> clazz,
                                String propertyName)
Description copied from interface: BeanAdapter
Returs the property value as a List

Specified by:
getValueList in interface BeanAdapter<T>
Returns:

getValueMap

public <K,V> Map<K,V> getValueMap(Class<K> clazzKey,
                                  Class<V> clazzValue,
                                  String propertyName)
Description copied from interface: BeanAdapter
Returns the value as a java.util.Map

Specified by:
getValueMap in interface BeanAdapter<T>
Returns:

getValueSet

public <U> Set<U> getValueSet(Class<U> clazz,
                              String propertyName)
Description copied from interface: BeanAdapter
Returns the value as a java.util.Set

Specified by:
getValueSet in interface BeanAdapter<T>
Returns:

getValueString

public String getValueString(String propertyName)
Description copied from interface: BeanAdapter
Returns the string representation of the property

Specified by:
getValueString in interface BeanAdapter<T>
Returns:

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isSync

public boolean isSync(Adapter<T> src)
Description copied from interface: Adapter
Returns true if the current object is synchronized with the object passed as parameter

Specified by:
isSync in interface Adapter<T>
Parameters:
src - The reference object
Returns:
true if both are synchronized

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Description copied from interface: Observable
This method removes listeners registering all modifications made to registered properties.

Specified by:
removePropertyChangeListener in interface Observable

setName

public void setName(String name)
Description copied from interface: Adapter
Sets the name of the adapter

Specified by:
setName in interface Adapter<T>

setSource

public void setSource(T source)
Description copied from interface: Adapter
Sets the source object

Specified by:
setSource in interface Adapter<T>

setValue

public <V> BasicBeanAdapter<T> setValue(Class<V> clazz,
                                        String propertyName,
                                        V value)
Description copied from interface: BeanAdapter
Sets the property value

Specified by:
setValue in interface BeanAdapter<T>
Returns:

setValue

public BasicBeanAdapter<T> setValue(String propertyName,
                                    Object value)
Description copied from interface: BeanAdapter
Sets the property value

Specified by:
setValue in interface BeanAdapter<T>

sync

public void sync(Adapter<T> value)
Description copied from interface: Adapter
Synchronizes all values of the current bean with the bean passed as parameter.

Specified by:
sync in interface Adapter<T>

sync

public void sync(Adapter<T> src,
                 Property srcProperty,
                 Property dstProperty)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010. All Rights Reserved.