⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 doublebinding.java

📁 一个关于java 的常用工具包
💻 JAVA
字号:
package org.jutil.structure;/** * <p><b>DEPRECATED</b>A class of "components" for implementing a double binding.</p> * * <p>This is actually a lightweight version of the APSet-APElement combination * of the <a href="http://www.beedra.org">Beedra</a> framework of Jan Dockx.</p> *  * <p>The classes that are linked together should still be in the same package, * but are easier to implement using DoubleBinding. A "native" binding is more * efficient, but an optimizer could do the transformation in order to get both * the programming and the efficiency benefits.</p> * * <p>This class is typically used in the following way:</p> * *<pre><code> * public class A { *   public A() { *     $b= new DoubleBinding(this); *   } *  *   public B getB() { *     return (B)$b.getOtherEnd(); *   } *  *   public void setB(B b) { *     if (b != null) { *       $b.setOtherBinding(b.getALink()); *     } *     else { *       $b.setOtherBinding(null); *     } *   } *  *   private DoubleBinding $b; *   private String $name; * } *  * public class B { *  *   public B() { *     $a = new DoubleBinding(this); *   } *  *   public A getA() { *     return (A)$a.getOtherEnd(); *   } *  *   DoubleBinding getALink() { *     return $a; *   } *   private String $name; * } *</code></pre> * @path    $Source: /cvsroot/org-jutil/jutil.org/src/org/jutil/structure/DoubleBinding.java,v $ * @version $Revision: 1.7 $ * @date    $Date: 2002/07/21 10:30:35 $ * @state   $State: Exp $ * @author  Marko van Dooren * @release $Name:  $ * * @deprecated */public class DoubleBinding { 	/* The revision of this class */	public final static String CVS_REVISION ="$Revision: 1.7 $";/*@	 @ public invariant getObject() != null;   @ public invariant getOtherBinding() != null ==>   @                  getOtherBinding().getOtherBinding() == this;   @*/  /**   * Initialize a new unconnected DoubleBinding.   *   * @param object   *        The object on this side of the double binding   */ /*@   @ public behavior   @   @ pre object != null;   @   @ post getOtherBinding() == null;   @ post getObject() == object;   @*/  public DoubleBinding(Object object) {    _object=object;  }  /**   * Initialize a new double binding connected to the given   * other DoubleBinding.   *   * @param other   *        The DoubleBinding object to connect to.   * @param object   *        The object on this side of the double binding   */ /*@   @ public behavior   @   @ pre object != null;   @   @ post getOtherBinding() == otherBinding;   @ post otherBinding != null ==> otherBinding.getOtherBinding() == this;   @ // If <other> was connected before to another object, that other object will   @ // be disconnected.   @ post (otherBinding != null) && \old(otherBinding.getOtherBinding()) != null ==>   @      \old(otherBinding.getOtherBinding()).getOtherBinding() == null;   @ post getObject() == object;   @*/  public DoubleBinding(DoubleBinding otherBinding, Object object) {    _object=object;    setOtherBinding(otherBinding);  }  /**   * Return the object at this side of the double binding.   */  public Object getObject() {    return _object;  }		/**	 * Check whether or not this DoubleBinding is connected to another.	 */	public boolean isConnected() {		return (_otherBinding != null);  }  /**   * Return the Object at the other end of this double binding.   */ /*@   @ public behavior   @   @ post getOtherBinding() == null ==> \result == null;   @ post getOtherBinding() != null ==> \result == getOtherBinding().getObject();   @*/  public Object getOtherEnd() {    if (getOtherBinding() == null) {        return null;    }    return getOtherBinding().getObject();  }  /**   * Return the DoubleBinding object this one is connected to.   */  public DoubleBinding getOtherBinding() {    return _otherBinding;  }  /**   * Set the other end of this binding   *   * @param otherBinding   *        The new DoubleBinding object that will be connected to this.   */ /*@   @ public behavior   @   @ post getOtherBinding() == otherBinding;   @ // If this DoubleBinding was connected before, and will now be   @ // connected to another DoubleBinding, the DoubleBinding it was   @ // connected to will be disconnected.   @ post \old(getOtherBinding()) != null && \old(getOtherBinding()) != otherBinding ==>   @      \old(getOtherBinding()).getOtherBinding() == null;   @ post otherBinding != null ==> otherBinding.getOtherBinding() == this;   @ // If <other> was connected before to another object, that other object will   @ // be disconnected.   @ post otherBinding != null &&	 @      \old(otherBinding.getOtherBinding()) != null &&   @      \old(otherBinding.getOtherBinding()) != this ==>   @      \old(otherBinding.getOtherBinding()).getOtherBinding() == null;   @*/  public void setOtherBinding(DoubleBinding otherBinding) {		// only do something if we have to.		if(otherBinding != _otherBinding) {			if(_otherBinding != null) {				_otherBinding.disconnect();			}			// do this first, or we will end up in an infinite loop      // or we need to introduce yet another method.			_otherBinding=otherBinding;      // If this is the DoubleBinding on which the change was initiated, we      // need to tell the new other side to connect to us. Otherwise, that      // binding is already set up, and we do nothing.      if((otherBinding != null) && (otherBinding.getOtherBinding() != this)){          otherBinding.setOtherBinding(this);      }    }  }  /**   * Disconnect this DoubleBinding on one side/   */ /*@   @ public behavior   @   @ post ! isConnected();   @*/  private void disconnect() {    _otherBinding = null;  }  /**   * the DoubleBinding object this one is connected to.   * May be null.   */  private DoubleBinding _otherBinding;  /**   * The object at this side of the double binding.   */ /*@   @ private invariant _object != null;   @*/  private Object _object;}/*<copyright>Copyright (C) 1997-2001. This software is copyrighted by the people and entities mentioned after the "@author" tags above, on behalf of the JUTIL.ORG Project. The copyright is dated by the dates after the "@date" tags above. All rights reserved.This software is published under the terms of the JUTIL.ORG SoftwareLicense version 1.1 or later, a copy of which has been included withthis distribution in the LICENSE file, which can also be found athttp://org-jutil.sourceforge.net/LICENSE. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the JUTIL.ORG Software License for more details.For more information, please see http://org-jutil.sourceforge.net/</copyright>*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -