org.jdesktop.swing.binding
Class AbstractBinding

java.lang.Object
  extended byorg.jdesktop.swing.binding.AbstractBinding
All Implemented Interfaces:
Binding
Direct Known Subclasses:
BooleanBinding, ComboBoxBinding, DatePickerBinding, FormBinding, ImagePanelBinding, LabelBinding, ListBinding, RadioBinding, SpinnerBinding, TextBinding

public abstract class AbstractBinding
extends Object
implements Binding

Abstract base class which implements a default mechanism for binding user-interface components to elements in a data model.


Field Summary
protected  Object cachedValue
           
protected  DataModel dataModel
           
protected  ArrayList errorList
           
protected  MetaData metaData
           
protected  boolean modified
           
protected  boolean pulling
           
protected  int validState
           
 
Fields inherited from interface org.jdesktop.swing.binding.Binding
AUTO_VALIDATE, AUTO_VALIDATE_NONE, AUTO_VALIDATE_STRICT, INVALID, UNVALIDATED, VALID
 
Constructor Summary
protected AbstractBinding(JComponent component, DataModel dataModel, String fieldName, int validationPolicy)
           
 
Method Summary
protected  void addError(String error)
           
 void addPropertyChangeListener(PropertyChangeListener pcl)
          Adds the specified property change listener to this binding object.
 void clearValidationErrors()
           
protected  String convertFromModelType(Object modelValue)
           
protected  Object convertToModelType(Object componentValue)
           
protected  boolean executeValidators(Object value)
           
abstract  JComponent getComponent()
           
protected abstract  Object getComponentValue()
           
 DataModel getDataModel()
           
 String getFieldName()
           
 PropertyChangeListener[] getPropertyChangeListeners()
           
 String[] getValidationErrors()
          Returns validation error messages generated from the most recent element-level validation pass.
 int getValidationPolicy()
           
 int getValidState()
           
 boolean isModified()
           
 boolean isValid()
           
 boolean pull()
          Pulls the value of this binding's data model element into its UI component.
 boolean push()
          Pushes the current value contained in this binding's UI component to this binding's data model element.
 void removePropertyChangeListener(PropertyChangeListener pcl)
          Removes the specified property change listener from this binding object.
protected abstract  void setComponent(JComponent component)
           
protected abstract  void setComponentValue(Object value)
           
protected  void setModified(boolean modified)
           
 void setValidationPolicy(int policy)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataModel

protected DataModel dataModel

metaData

protected MetaData metaData

cachedValue

protected Object cachedValue

errorList

protected ArrayList errorList

modified

protected boolean modified

validState

protected int validState

pulling

protected boolean pulling
Constructor Detail

AbstractBinding

protected AbstractBinding(JComponent component,
                          DataModel dataModel,
                          String fieldName,
                          int validationPolicy)
Method Detail

getDataModel

public DataModel getDataModel()
Specified by:
getDataModel in interface Binding

getFieldName

public String getFieldName()
Specified by:
getFieldName in interface Binding

setValidationPolicy

public void setValidationPolicy(int policy)

getValidationPolicy

public int getValidationPolicy()

pull

public boolean pull()
Description copied from interface: Binding
Pulls the value of this binding's data model element into its UI component.

Specified by:
pull in interface Binding
Returns:
boolean indicating whether or not the value was pulled from the data model

isModified

public boolean isModified()
Specified by:
isModified in interface Binding
Returns:
boolean indicating whether or not the value contained in this binding's UI component has been modified since the value was last pushed or pulled

setModified

protected void setModified(boolean modified)

isValid

public boolean isValid()
Specified by:
isValid in interface Binding
Returns:
boolean indicating whether or not the value contained in this binding's UI component is valid

getValidState

public int getValidState()
Specified by:
getValidState in interface Binding

convertToModelType

protected Object convertToModelType(Object componentValue)
                             throws ConversionException
Throws:
ConversionException

convertFromModelType

protected String convertFromModelType(Object modelValue)

executeValidators

protected boolean executeValidators(Object value)

getValidationErrors

public String[] getValidationErrors()
Description copied from interface: Binding
Returns validation error messages generated from the most recent element-level validation pass.

Specified by:
getValidationErrors in interface Binding
Returns:
array containing any error messages which occurred during element-level validation

clearValidationErrors

public void clearValidationErrors()

getComponent

public abstract JComponent getComponent()
Specified by:
getComponent in interface Binding

setComponent

protected abstract void setComponent(JComponent component)

getComponentValue

protected abstract Object getComponentValue()

setComponentValue

protected abstract void setComponentValue(Object value)

addError

protected void addError(String error)

push

public boolean push()
Description copied from interface: Binding
Pushes the current value contained in this binding's UI component to this binding's data model element. Only valid values should be pushed to the model.

Specified by:
push in interface Binding
Returns:
boolean indicating whether or not the value was pushed to the data model

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener pcl)
Adds the specified property change listener to this binding object.

Specified by:
addPropertyChangeListener in interface Binding
Parameters:
pcl - PropertyChangeListener object to receive events when binding properties change

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener pcl)
Removes the specified property change listener from this binding object.

Specified by:
removePropertyChangeListener in interface Binding
Parameters:
pcl - PropertyChangeListener object to receive events when binding properties change

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners()
Specified by:
getPropertyChangeListeners in interface Binding
Returns:
array containing the PropertyChangeListener objects registered on this binding object


Copyright 2004 by Sun Microsystems, Inc. All Rights Reserved.