jaxx.compiler.binding
Class DataSource

java.lang.Object
  extended by jaxx.compiler.binding.DataSource

public class DataSource
extends java.lang.Object

Represents a Java expression which fires a PropertyChangeEvent when it can be determined that its value may have changed. Events are fired on a "best effort" basis, and events may either be fired too often (the value has not actually changed) or not often enough (the value changed but no event was fired).


Field Summary
protected  java.lang.String constantId
          Constant id
protected static org.apache.commons.logging.Log log
          Logger
protected  java.util.List<JavaMethod> methods
           
 
Constructor Summary
DataSource(java.lang.String id, java.lang.String constantId, java.lang.String source, JAXXCompiler compiler, java.util.List<JavaMethod> methods)
          Creates a new data source.
 
Method Summary
protected  boolean compile()
          Compiles the data source expression and listener.
 java.lang.String getAddMemberListenerCode(DefaultObjectHandler handler, java.lang.String objectCode, java.lang.String memberName, java.lang.String propertyChangeListenerCode, JAXXCompiler compiler)
          Returns a snippet of Java code which will cause a PropertyChangeListener to be notified when the member's value changes.
 java.lang.String getObjectCode()
           
 java.lang.String getRemoveMemberListenerCode(DefaultObjectHandler handler, java.lang.String objectCode, java.lang.String memberName, java.lang.String propertyChangeListenerCode, JAXXCompiler compiler)
           
 DataListener[] getTrackers()
           
 boolean hasMethod(java.lang.String methodName)
           
 java.lang.String 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
Logger


constantId

protected final java.lang.String constantId
Constant id


methods

protected final java.util.List<JavaMethod> methods
Constructor Detail

DataSource

public DataSource(java.lang.String id,
                  java.lang.String constantId,
                  java.lang.String source,
                  JAXXCompiler compiler,
                  java.util.List<JavaMethod> methods)
Creates a new data source. After creating a DataSource, use compile() to cause it to function at runtime.

Parameters:
id - the DataSource's id
constantId - the DataSource constant id
source - the Java source code for the data source expression
compiler - the current JAXXCompiler
methods - where to store extra method to add to binding
Method Detail

getObjectCode

public java.lang.String getObjectCode()

getTrackers

public DataListener[] getTrackers()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compile

protected boolean compile()
                   throws CompilerException,
                          java.lang.IllegalStateException
Compiles the data source expression and listener. This method calls methods in JAXXCompiler to add the Java code that performs the data source setup. Adding listeners to DataSource is slightly more complicated than with ordinary classes, because DataSource only exists at compile time. You must pass in a Java expression which evaluates to a PropertyChangeListener; this expression will be compiled and evaluated at runtime to yield the DataSource's listener.

Returns:
true if the expression has dependencies, false otherwise
Throws:
CompilerException - if a compilation error occurs
java.lang.IllegalStateException - if data source was already compiled

hasMethod

public boolean hasMethod(java.lang.String methodName)

getAddMemberListenerCode

public java.lang.String getAddMemberListenerCode(DefaultObjectHandler handler,
                                                 java.lang.String objectCode,
                                                 java.lang.String memberName,
                                                 java.lang.String propertyChangeListenerCode,
                                                 JAXXCompiler compiler)
Returns a snippet of Java code which will cause a PropertyChangeListener to be notified when the member's value changes. The PropertyChangeListener is provided in the form of a Java code snippet that evaluates to a listener object.

For ordinary bound JavaBeans properties, the Java code returned is a simple call to addPropertyChangeListener. Fields and methods which do not actually fire PropertyChangeEvents when they change necessitate more complex code.

Parameters:
handler - Object handler (containts known events
objectCode - Java code which evaluates to the object to which to add the listener *@param dataBinding the name of the data binding this listener is a part of
memberName - the name of the field or method to listen to
propertyChangeListenerCode - Java code which evaluates to a PropertyChangeListener
compiler - the current JAXXCompiler
Returns:
Java code snippet which causes the listener to be added to the object

getRemoveMemberListenerCode

public java.lang.String getRemoveMemberListenerCode(DefaultObjectHandler handler,
                                                    java.lang.String objectCode,
                                                    java.lang.String memberName,
                                                    java.lang.String propertyChangeListenerCode,
                                                    JAXXCompiler compiler)


Copyright © 2008-2009 CodeLutin. All Rights Reserved.