jaxx.tags
Class DefaultComponentHandler

java.lang.Object
  extended by jaxx.tags.DefaultObjectHandler
      extended by jaxx.tags.DefaultComponentHandler
All Implemented Interfaces:
TagHandler
Direct Known Subclasses:
EnumEditorHandler, JCheckBoxHandler, JComboBoxHandler, JInternalFrameHandler, JListHandler, JMenuHandler, JPopupMenuHandler, JProgressBarHandler, JRadioButtonHandler, JScrollPaneHandler, JSliderHandler, JSpinnerHandler, JSplitPaneHandler, JTabbedPaneHandler, JTextComponentHandler, JToolBarHandler, JTreeHandler, JWindowHandler, LocaleEditorHandler, TableHandler

public class DefaultComponentHandler
extends DefaultObjectHandler


Field Summary
protected static org.apache.commons.logging.Log log
          log
 
Fields inherited from class jaxx.tags.DefaultObjectHandler
jaxxBeanInfo, objectMap
 
Constructor Summary
DefaultComponentHandler(ClassDescriptor beanClass)
           
 
Method Summary
protected  void closeComponent(CompiledObject object, org.w3c.dom.Element tag, JAXXCompiler compiler)
           
 void compileFirstPass(org.w3c.dom.Element tag, JAXXCompiler compiler)
          Performs the first pass of compilation on an XML tag from a JAXX source file.
 void compileSecondPass(org.w3c.dom.Element tag, JAXXCompiler compiler)
          Performs the second pass of compilation on an XML tag from a JAXX source file.
protected  void configureProxyEventInfo()
          Configures the event handling for members which do not fire PropertyChangeEvent when modified.
protected  int constantValue(java.lang.String key, java.lang.String value)
          Maps string values onto integers, so that int-valued enumeration properties can be specified by strings.
 java.lang.String getContainerDelegate()
           
 java.lang.String getGetPropertyCode(java.lang.String id, java.lang.String name, JAXXCompiler compiler)
          Returns a snippet of Java code which will retrieve an object property at runtime.
 ClassDescriptor getPropertyType(CompiledObject object, java.lang.String propertyName, JAXXCompiler compiler)
          Returns the type of the named property.
 java.lang.String getSetPropertyCode(java.lang.String id, java.lang.String name, java.lang.String valueCode, JAXXCompiler compiler)
          Returns a snippet of Java code which will set an object property at runtime.
protected  void init()
          Performs introspection on the beanClass and stores the results.
 boolean isContainer()
          Returns true if this component can contain other components.
 boolean isPropertyInherited(java.lang.String property)
           
protected  void openComponent(CompiledObject object, org.w3c.dom.Element tag, JAXXCompiler compiler)
           
protected  void scanAttributesForDependencies(org.w3c.dom.Element tag, JAXXCompiler compiler)
          Scans all attributes for any dependency classes and adds them to the current compilation set.
 void setAttribute(CompiledObject object, java.lang.String propertyName, java.lang.String stringValue, boolean inline, JAXXCompiler compiler)
          Set a single property on an object.
protected  void setDefaults(CompiledObject object, org.w3c.dom.Element tag, JAXXCompiler compiler)
          Initializes the default settings of the object, prior to setting its attribute values.
 
Methods inherited from class jaxx.tags.DefaultObjectHandler
addEventHandler, addProxyEventInfo, addProxyEventInfo, addProxyEventInfo, addProxyEventInfo, applyStylesheets, compileChildrenFirstPass, compileChildrenSecondPass, compileChildTagFirstPass, compileChildTagSecondPass, convertFromString, createCompiledObject, getAddMemberListenerCode, getApplyPropertyOrDataBindingCode, getAttributeComparator, getAttributeOrdering, getBeanClass, getJAXXBeanInfo, getJAXXBeanInfo, getMemberDependencies, getRemoveMemberListenerCode, isEventHandlerName, isMemberBound, registerCompiledObject, setAttributes, setProperty, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
log

Constructor Detail

DefaultComponentHandler

public DefaultComponentHandler(ClassDescriptor beanClass)
Method Detail

init

protected void init()
             throws java.beans.IntrospectionException
Description copied from class: DefaultObjectHandler
Performs introspection on the beanClass and stores the results.

Overrides:
init in class DefaultObjectHandler
Throws:
java.beans.IntrospectionException - TODO

configureProxyEventInfo

protected void configureProxyEventInfo()
Description copied from class: DefaultObjectHandler
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.

Overrides:
configureProxyEventInfo in class DefaultObjectHandler

setDefaults

protected void setDefaults(CompiledObject object,
                           org.w3c.dom.Element tag,
                           JAXXCompiler compiler)
                    throws CompilerException
Description copied from class: DefaultObjectHandler
Initializes the default settings of the object, prior to setting its attribute values. The default implementation does nothing.

Overrides:
setDefaults in class DefaultObjectHandler
Parameters:
object - the object to initialize
tag - the tag being compiled
compiler - the current JAXXCompiler
Throws:
CompilerException

compileFirstPass

public void compileFirstPass(org.w3c.dom.Element tag,
                             JAXXCompiler compiler)
                      throws CompilerException,
                             java.io.IOException
Description copied from interface: TagHandler
Performs the first pass of compilation on an XML tag from a JAXX source file. TagHandler implementations affect the generated .java file by calling methods in the JAXXCompiler.

Specified by:
compileFirstPass in interface TagHandler
Overrides:
compileFirstPass in class DefaultObjectHandler
Parameters:
tag - the XML tag to compile
compiler - the active JAXXCompiler
Throws:
CompilerException - if a compilation error occurs
java.io.IOException - if an I/O error occurs

compileSecondPass

public void compileSecondPass(org.w3c.dom.Element tag,
                              JAXXCompiler compiler)
                       throws CompilerException,
                              java.io.IOException
Description copied from interface: TagHandler
Performs the second pass of compilation on an XML tag from a JAXX source file. TagHandler implementations affect the generated .java file by calling methods in the JAXXCompiler.

Specified by:
compileSecondPass in interface TagHandler
Overrides:
compileSecondPass in class DefaultObjectHandler
Parameters:
tag - the XML tag to compile
compiler - the active JAXXCompiler
Throws:
CompilerException - if a compilation error occurs
java.io.IOException - if an I/O error occurs

openComponent

protected void openComponent(CompiledObject object,
                             org.w3c.dom.Element tag,
                             JAXXCompiler compiler)
                      throws CompilerException
Throws:
CompilerException

closeComponent

protected void closeComponent(CompiledObject object,
                              org.w3c.dom.Element tag,
                              JAXXCompiler compiler)
                       throws CompilerException
Throws:
CompilerException

isPropertyInherited

public boolean isPropertyInherited(java.lang.String property)
                            throws UnsupportedAttributeException
Overrides:
isPropertyInherited in class DefaultObjectHandler
Parameters:
property - property name to test
Returns:
true if the specified property should be inherited by child components when specified via CSS.
Throws:
UnsupportedAttributeException - ?

getPropertyType

public ClassDescriptor getPropertyType(CompiledObject object,
                                       java.lang.String propertyName,
                                       JAXXCompiler compiler)
                                throws CompilerException
Description copied from class: DefaultObjectHandler
Returns the type of the named property. This is the return type of the property's get method; for instance JLabel's text property is a String.

Overrides:
getPropertyType in class DefaultObjectHandler
Parameters:
object - the object being compiled
propertyName - the simple JavaBeans-style name of the property
compiler - the current JAXXCompiler
Returns:
the property's type
Throws:
CompilerException - if the type cannot be determined

getGetPropertyCode

public java.lang.String getGetPropertyCode(java.lang.String id,
                                           java.lang.String name,
                                           JAXXCompiler compiler)
                                    throws CompilerException
Description copied from class: DefaultObjectHandler
Returns a snippet of Java code which will retrieve an object property at runtime. Typically the code is just a call to the property's get method, but it can be arbitrarily complex.

Overrides:
getGetPropertyCode in class DefaultObjectHandler
Parameters:
id - Java code for the object whose property is being retrieved
name - the name of the property to retrieve
compiler - the current JAXXCompiler
Returns:
the snippet
Throws:
CompilerException - if a compilation error occurs

getSetPropertyCode

public java.lang.String getSetPropertyCode(java.lang.String id,
                                           java.lang.String name,
                                           java.lang.String valueCode,
                                           JAXXCompiler compiler)
                                    throws CompilerException
Description copied from class: DefaultObjectHandler
Returns a snippet of Java code which will set an object property at runtime. Typically the code is just a call to the property's set method, but it can be arbitrarily complex.

Overrides:
getSetPropertyCode in class DefaultObjectHandler
Parameters:
id - Java code for the object whose property is being set
name - the name of the property to set
valueCode - Java expression representing the value to set the property to
compiler - the current JAXXCompiler
Returns:
the snippet
Throws:
CompilerException - if a compilation error occurs

setAttribute

public void setAttribute(CompiledObject object,
                         java.lang.String propertyName,
                         java.lang.String stringValue,
                         boolean inline,
                         JAXXCompiler compiler)
Description copied from class: DefaultObjectHandler
Set a single property on an object. The value may be either a simple value or contain data binding expressions. Simple values are first converted to the property's type using DefaultObjectHandler.convertFromString(java.lang.String, java.lang.String, java.lang.Class).

Overrides:
setAttribute in class DefaultObjectHandler
Parameters:
object - the object on which to set the property
propertyName - the name of the property to set
stringValue - the raw string value of the property from the XML
inline - true if the value was directly specified as an inline class tag attribute, false otherwise (a default value, specified in CSS, etc.)
compiler - the current JAXXCompiler

scanAttributesForDependencies

protected void scanAttributesForDependencies(org.w3c.dom.Element tag,
                                             JAXXCompiler compiler)
Description copied from class: DefaultObjectHandler
Scans all attributes for any dependency classes and adds them to the current compilation set. Called by compileFirstPass() (it is an error to add dependencies after pass 1 is complete).

Overrides:
scanAttributesForDependencies in class DefaultObjectHandler
Parameters:
tag - tag to scan
compiler - compiler to use

constantValue

protected int constantValue(java.lang.String key,
                            java.lang.String value)
Maps string values onto integers, so that int-valued enumeration properties can be specified by strings. For example, when passed a key of 'alignment', this method should normally map the values 'left', 'center', and 'right' onto SwingConstants.LEFT, SwingConstants.CENTER, and SwingConstants.RIGHT respectively.

You do not normally need to call this method yourself; it is invoked by DefaultObjectHandler.convertFromString(java.lang.String, java.lang.String, java.lang.Class) when an int-valued property has a value which is not a valid number. By default, this method looks at the enumerationValues value of the JAXXPropertyDescriptor.

Overrides:
constantValue in class DefaultObjectHandler
Parameters:
key - the name of the int-typed property
value - the non-numeric value that was specified for the property
Returns:
the constant integer value
Throws:
java.lang.IllegalArgumentException - if the property is an enumeration, but the value is not valid
java.lang.NumberFormatException - if the property is not an enumeration

isContainer

public boolean isContainer()
Returns true if this component can contain other components. For children to be allowed, the component must be a subclass of Container and its JAXXBeanInfo must not have the value false for its isContainer value.

Returns:
true if children are allowed

getContainerDelegate

public java.lang.String getContainerDelegate()


Copyright © 2008-2009 CodeLutin. All Rights Reserved.