home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / jgl_1_1.exe / src / BindFirst.java < prev    next >
Encoding:
Java Source  |  1996-09-10  |  1.2 KB  |  43 lines

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package jgl;
  5.  
  6. /**
  7.  * BindFirst is a unary function object that allows you to apply a binary function to
  8.  * a predefined value and an operand. The reason that it's called BindFirst is that the
  9.  * predefined value is always used as the 1st parameter to the binary function.
  10.  * <p>
  11.  * @see jgl.BindSecond
  12.  * @version 1.1
  13.  * @author ObjectSpace, Inc.
  14.  */
  15.  
  16. public final class BindFirst implements UnaryFunction
  17.   {
  18.   BinaryFunction myFunction;
  19.   Object myObject;
  20.  
  21.   /**
  22.    * Construct myself with a binary function object and a predefined value.
  23.    * @param function The binary function object.
  24.    * @param value The object to use as the 1st parameter.
  25.    */
  26.   public BindFirst( BinaryFunction function, Object value )
  27.     {
  28.     myFunction = function;
  29.     myObject = value;
  30.     }
  31.  
  32.   /**
  33.    * Perform my binary function on the operand using the predefined value as the 1st
  34.    * parameter and the operand as the 2nd parameter.
  35.    * @param object The operand.
  36.    * @return function( value, object )
  37.    */
  38.   public Object execute( Object object )
  39.     {
  40.     return myFunction.execute( myObject, object );
  41.     }
  42.   }
  43.