home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Extras / OSpace / jgl.exe / jgl_2_0 / src / COM / objectspace / jgl / Print.java < prev    next >
Encoding:
Java Source  |  1997-03-14  |  1.1 KB  |  49 lines

  1. // Copyright(c) 1996,1997 ObjectSpace, Inc.
  2. // Portions Copyright(c) 1995, 1996 Hewlett-Packard Company.
  3.  
  4. package COM.objectspace.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 COM.objectspace.jgl.OutputStreamIterator
  13.  * @version 2.0.2
  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.