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

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package jgl;
  5.  
  6. import java.io.PrintStream;
  7.  
  8. /**
  9.  * Print is a unary function object that prints its operand to a PrintStream followed by
  10.  * a newline.
  11.  * <p>
  12.  * @see jgl.OutputStreamIterator
  13.  * @version 1.1
  14.  * @author ObjectSpace, Inc.
  15.  */
  16.  
  17. public final class Print implements UnaryFunction
  18.   {
  19.   PrintStream my_stream;
  20.  
  21.   /**
  22.    * Construct myself to print all objects to the standard output stream, System.out.
  23.    */
  24.   public Print()
  25.     {
  26.     my_stream = System.out;
  27.     }
  28.  
  29.   /**
  30.    * Construct myself to print all objects to the specified PrintStream.
  31.    * @param stream The PrintStream.
  32.    */
  33.   public Print( PrintStream stream )
  34.     {
  35.     my_stream = stream;
  36.     }
  37.  
  38.   /**
  39.    * Print my operand to my PrintStream.
  40.    * @param object The operand.
  41.    * @return The operand.
  42.    */
  43.   public Object execute( Object object )
  44.     {
  45.     my_stream.println( object );
  46.     return object;
  47.     }
  48.   }
  49.