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

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