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

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package jgl;
  5.  
  6. /**
  7.  * BinaryCompose is a binary function object that returns the result of executing
  8.  * three operations in a specific sequence.
  9.  * <p>
  10.  * @see jgl.UnaryCompose
  11.  * @version 1.1
  12.  * @author ObjectSpace, Inc.
  13.  */
  14.  
  15. public final class BinaryCompose implements BinaryFunction
  16.   {
  17.   BinaryFunction myFunction1;
  18.   UnaryFunction myFunction2;
  19.   UnaryFunction myFunction3;
  20.  
  21.   /**
  22.    * Construct myself with a single binary function object and two unary function objects.
  23.    * @param function1 The single binary function object.
  24.    * @param function2 The first unary function object.
  25.    * @param function3 The second unary function object.
  26.    */
  27.   public BinaryCompose( BinaryFunction function1, UnaryFunction function2, UnaryFunction function3 )
  28.     {
  29.     myFunction1 = function1;
  30.     myFunction2 = function2;
  31.     myFunction3 = function3;
  32.     }
  33.  
  34.   /**
  35.    * Perform my unary functions on each operand and then return the result of applying 
  36.    * my binary function object to these results.
  37.    * @param first The first operand.
  38.    * @param second The second operand.
  39.    * @return function1( function2( first ), function3( second ) )
  40.    */
  41.   public Object execute( Object first, Object second )
  42.     {
  43.     return myFunction1.execute( myFunction2.execute( first ), myFunction3.execute( second ) );
  44.     }
  45.   }
  46.