Binding.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:3k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: Binding.java,v 1.2 2005/10/10 17:00:53 rbair Exp $
  3.  *
  4.  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
  5.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.  */
  21. package org.jdesktop.binding.swingx;
  22. import java.beans.PropertyChangeListener;
  23. import javax.swing.JComponent;
  24. import org.jdesktop.binding.DataModel;
  25. /**
  26.  * Class which binds a user-interface component to a specific element
  27.  * in a data model.  A Binding instance implements the following tasks:
  28.  * <ul>
  29.  * <li>pulls values from the data model into the UI component</li>
  30.  * <li>performs element-level validation on the value contained
  31.  *     in the UI component to determine whether it can/should be
  32.  *     pushed to the model.</li>
  33.  * <li>pushes validated values from the UI component to the data model.</li>
  34.  * </ul>
  35.  *
  36.  * @author Amy Fowler
  37.  * @version 1.0
  38.  */
  39. public interface Binding {
  40.     public static final int AUTO_VALIDATE = 0;
  41.     public static final int AUTO_VALIDATE_STRICT = 1;
  42.     public static final int AUTO_VALIDATE_NONE = 2;
  43.     public static final int UNVALIDATED = 0;
  44.     public static final int VALID = 1;
  45.     public static final int INVALID = 2;
  46.     JComponent getComponent();
  47.     DataModel getDataModel();
  48.     String getFieldName();
  49.     /**
  50.      * Pulls the value of this binding's data model element
  51.      * into its UI component.
  52.      *
  53.      * @return boolean indicating whether or not the value was pulled from the
  54.      *         data model
  55.      */
  56.     boolean pull();
  57.     /**
  58.      *
  59.      * @return boolean indicating whether or not the value contained in
  60.      *         this binding's UI component has been modified since the
  61.      *         value was last pushed or pulled
  62.      */
  63.     boolean isModified();
  64.     /**
  65.      * @return boolean indicating whether or not the value contained in
  66.      *         this binding's UI component is valid
  67.      */
  68.     boolean isValid();
  69.     int getValidState();
  70.     /**
  71.      * Returns validation error messages generated from the most
  72.      * recent element-level validation pass.
  73.      *
  74.      * @return array containing any error messages which occurred during
  75.      *         element-level validation
  76.      */
  77.     String[] getValidationErrors();
  78.     /**
  79.      * Pushes the current value contained in this binding's UI component
  80.      * to this binding's data model element.  Only valid values
  81.      * should be pushed to the model.
  82.      * @return boolean indicating whether or not the value was pushed to the
  83.      *         data model
  84.      */
  85.     boolean push();
  86.     void addPropertyChangeListener(PropertyChangeListener pcl);
  87.     void removePropertyChangeListener(PropertyChangeListener pcl);
  88.     PropertyChangeListener[] getPropertyChangeListeners();
  89. }