org.nuiton.guix.tags
Class DefaultTagHandler

java.lang.Object
  extended by org.nuiton.guix.tags.DefaultTagHandler
All Implemented Interfaces:
TagHandler
Direct Known Subclasses:
ApplicationHandler, PanelHandler

public abstract class DefaultTagHandler
extends java.lang.Object
implements TagHandler

Default TagHandler, containing common methods for all the tags

Author:
kmorin

Field Summary
protected  java.util.Map<java.lang.String,java.lang.String> attrMap
          Maps the common name for an attribute with its real name for the class to generate
protected  java.beans.BeanInfo beanInfo
          The JAXXBeanInfo for the beanClass.
 
Constructor Summary
DefaultTagHandler()
           
 
Method Summary
 void addProxyEventInfo(java.lang.String memberName, java.lang.Class listenerClass)
          Configures a proxy event handler which fires PropertyChangeEvents when a non-bound member is updated.
 void addProxyEventInfo(java.lang.String memberName, java.lang.Class listenerClass, java.lang.String modelName)
          Configures a proxy event handler which fires PropertyChangeEvents when a non-bound member is updated.
 void addProxyEventInfo(java.lang.String memberName, java.lang.Class listenerClass, java.lang.String modelName, java.lang.String addMethod, java.lang.String removeMethod)
          Configures a proxy event handler which fires PropertyChangeEvents when a non-bound member is updated.
protected  void configureProxyEventInfo()
          Configures the event handling for members which do not fire PropertyChangeEvent when modified.
 java.lang.String getAttrToGenerate(java.lang.String attr)
           
 java.lang.String getDefaultConstructor()
           
 java.lang.String getEventInfosAddListenerMethodName(java.lang.String methodName)
           
 java.lang.Class getEventInfosListenerClass(java.lang.String methodName)
           
 java.lang.String getEventInfosModelName(java.lang.String methodName)
           
 java.lang.String getEventInfosRemoveListenerMethodName(java.lang.String methodName)
           
 boolean hasEventInfosAboutMethod(java.lang.String methodName)
           
protected  void init()
          Performs introspection on the beanClass and stores the results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nuiton.guix.tags.TagHandler
getClassToGenerate
 

Field Detail

attrMap

protected java.util.Map<java.lang.String,java.lang.String> attrMap
Maps the common name for an attribute with its real name for the class to generate


beanInfo

protected java.beans.BeanInfo beanInfo
The JAXXBeanInfo for the beanClass.

Constructor Detail

DefaultTagHandler

public DefaultTagHandler()
Method Detail

init

protected void init()
             throws java.beans.IntrospectionException
Performs introspection on the beanClass and stores the results.

Throws:
java.beans.IntrospectionException - TODO

configureProxyEventInfo

protected void configureProxyEventInfo()
Configures the event handling for members which do not fire PropertyChangeEvent when modified. The default implementation does nothing. Subclasses should override this method to call addProxyEventInfo for each member which requires special handling.


addProxyEventInfo

public void addProxyEventInfo(java.lang.String memberName,
                              java.lang.Class listenerClass)
Configures a proxy event handler which fires PropertyChangeEvents when a non-bound member is updated. This is necessary for all fields (which cannot be bound) and for methods that are not bound property get methods. The proxy event handler will attach the specified kind of listener to the class and fire a PropertyChangeEvent whenever the listener receives any kind of event.

Even though this method can theoretically be applied to fields (in addition to methods), it would be an unusual situation in which that would actually work -- as fields cannot fire events when modified, it would be difficult to have a listener that was always notified when a field value changed.

Parameters:
memberName - the name of the field or method being proxied
listenerClass - the type of listener which receives events when the field or method is updated

addProxyEventInfo

public void addProxyEventInfo(java.lang.String memberName,
                              java.lang.Class listenerClass,
                              java.lang.String modelName)
Configures a proxy event handler which fires PropertyChangeEvents when a non-bound member is updated. This is necessary for all fields (which cannot be bound) and for methods that are not bound property get methods. This variant attaches a listener to a property of the object (such as model) and not the object itself, which is useful when there is a model that is the "real" container of the information. The proxy event handler will attach the specified kind of listener to the property's value (retrieved using the property's get method) and fire a PropertyChangeEvent whenever the listener receives any kind of event.

If the property is itself bound (typically the case with models), any updates to the property's value will cause the listener to be removed from the old property value and reattached to the new property value, as well as cause a PropertyChangeEvent to be fired.

Even though this method can theoretically be applied to fields (in addition to methods), it would be an unusual situation in which that would actually work -- as fields cannot fire events when modified, it would be difficult to have a listener that was always notified when a field value changed.

Parameters:
memberName - the name of the field or method being proxied
listenerClass - the type of listener which receives events when the field or method is updated
modelName - the JavaBeans-style name of the model property

addProxyEventInfo

public void addProxyEventInfo(java.lang.String memberName,
                              java.lang.Class listenerClass,
                              java.lang.String modelName,
                              java.lang.String addMethod,
                              java.lang.String removeMethod)
Configures a proxy event handler which fires PropertyChangeEvents when a non-bound member is updated. This is necessary for all fields (which cannot be bound) and for methods that are not bound property get methods. This variant attaches a listener to a property of the object (such as model) and not the object itself, which is useful when there is a model that is the "real" container of the information. The proxy event handler will attach the specified kind of listener to the property's value (retrieved using the property's get method) and fire a PropertyChangeEvent whenever the listener receives any kind of event.

If the property is itself bound (typically the case with models), any updates to the property's value will cause the listener to be removed from the old property value and reattached to the new property value, as well as cause a PropertyChangeEvent to be fired.

This variant of addProxyEventInfo allows the names of the methods that add and remove the event listener to be specified, in cases where the names are not simply add<listenerClassName> and remove<listenerClassName>.

Even though this method can theoretically be applied to fields (in addition to methods), it would be an unusual situation in which that would actually work -- as fields cannot fire events when modified, it would be difficult to have a listener that was always notified when a field value changed.

Parameters:
memberName - the name of the field or method being proxied
listenerClass - the type of listener which receives events when the field or method is updated
modelName - the JavaBeans-style name of the model property
addMethod - add method name
removeMethod - remove method name

hasEventInfosAboutMethod

public boolean hasEventInfosAboutMethod(java.lang.String methodName)
Specified by:
hasEventInfosAboutMethod in interface TagHandler

getEventInfosListenerClass

public java.lang.Class getEventInfosListenerClass(java.lang.String methodName)
Specified by:
getEventInfosListenerClass in interface TagHandler

getEventInfosAddListenerMethodName

public java.lang.String getEventInfosAddListenerMethodName(java.lang.String methodName)
Specified by:
getEventInfosAddListenerMethodName in interface TagHandler

getEventInfosRemoveListenerMethodName

public java.lang.String getEventInfosRemoveListenerMethodName(java.lang.String methodName)
Specified by:
getEventInfosRemoveListenerMethodName in interface TagHandler

getEventInfosModelName

public java.lang.String getEventInfosModelName(java.lang.String methodName)
Specified by:
getEventInfosModelName in interface TagHandler

getAttrToGenerate

public java.lang.String getAttrToGenerate(java.lang.String attr)
Specified by:
getAttrToGenerate in interface TagHandler

getDefaultConstructor

public java.lang.String getDefaultConstructor()
Specified by:
getDefaultConstructor in interface TagHandler


Copyright © 2009 CodeLutin. All Rights Reserved.