home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / prosrc.bin / Out.java < prev    next >
Encoding:
Java Source  |  1998-03-18  |  5.1 KB  |  205 lines

  1. /*
  2.  * Copyright (c) 1997 Krumel & Associates, Inc. All Rights Reserved.
  3.  *
  4.  * www.krumel.com - controls@krumel.com
  5.  *
  6.  * Permission is given to the buyer of this package for one software
  7.  * developer to use this software on one CPU (one workstation) and to make
  8.  * one backup copy.  You may uitilize and/or modify this class for use in your
  9.  * projects.  You may distribute or sell any executable which results from
  10.  * using this code in yur application, except a utility or class of similar
  11.  * nature to this product.  You may distribute this product in compiled
  12.  * form only, but soley to be used with your cmpiled executable product
  13.  * for the puposes of dynamic loading. You may NOT redistribute the source
  14.  * code in any form or make it accessible through a network or other
  15.  * distribution media to others. Please refer to the file "copyright.html"
  16.  * for further important copyright and licensing information.
  17.  *
  18.  * The source code is the confidential and proprietary information
  19.  * of Krumel & Associates, Inc. ("Confidential Information").  You shall
  20.  * not disclose such Confidential Information and shall use it only in
  21.  * accordance with the terms of the license agreement you entered into
  22.  * with Krumel & Associates, Inc..
  23.  
  24.  * KRUMEL & ASSOCIATES MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
  25.  * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
  26.  * NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  27.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. KRUMEL & ASSOCIATES SHALL NOT
  28.  * BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING,
  29.  * MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  30.  */
  31.  
  32. package symantec.itools.db.awt.genutil;
  33.  
  34. import java.io.*;
  35.  
  36. public class Out {
  37.     public static String sep = ", ";
  38.     PrintStream ps;
  39.  
  40.     public static final Out std = new Out(System.out);
  41.     public static final Out err = new Out(System.err);
  42.  
  43.     public Out(PrintStream p) {
  44.         ps = p;
  45.     }
  46.  
  47.     public Out println() {
  48.         ps.println();
  49.         return this;
  50.     }
  51.  
  52.     public Out print(String s) {
  53.         ps.print(s);
  54.         return this;
  55.     }
  56.  
  57.     public Out print(Object o) {
  58.         ps.print(o);
  59.         return this;
  60.     }
  61.  
  62.     public Out println(Object o) {
  63.         ps.println(o);
  64.         return this;
  65.     }
  66.  
  67.     public Out print(String s, int w) {
  68.         ps.print(s);
  69.         space(s.length() - w);
  70.         return this;
  71.     }
  72.  
  73.     public Out println(String s) {
  74.         ps.println(s);
  75.         return this;
  76.     }
  77.  
  78.     public Out print(char c) {
  79.         print(c);
  80.         return this;
  81.     }
  82.  
  83.     public Out println(char c) {
  84.         ps.println(c);
  85.         return this;
  86.     }
  87.  
  88.     public Out print(long l) {
  89.         ps.print(l);
  90.         return this;
  91.     }
  92.  
  93.     public Out println(long l) {
  94.         ps.println(l);
  95.         return this;
  96.     }
  97.  
  98.     public Out print(long l, int w) {
  99.         String s = String.valueOf(l);
  100.         return print(s, w);
  101.     }
  102.  
  103.     public Out print(double d) {
  104.         ps.print(d);
  105.         return this;
  106.     }
  107.  
  108.     public Out println(double d) {
  109.         ps.println(d);
  110.         return this;
  111.     }
  112.  
  113.     public Out print(boolean b) {
  114.         ps.print(b);
  115.         return this;
  116.     }
  117.  
  118.     public Out print(boolean b, int w) {
  119.         String s = String.valueOf(b);
  120.         return print(s, w);
  121.     }
  122.  
  123.     public Out sep() {
  124.         ps.print(sep);
  125.         return this;
  126.     }
  127.  
  128.     public Out space(int i) {
  129.         if (i <= 0) { return this; }
  130.  
  131.         while(i-->0) {
  132.             ps.print(' ');
  133.         }
  134.  
  135.         return this;
  136.     }
  137.  
  138.     //static versions
  139.     public static Out print(PrintStream ps, String s) {
  140.         ps.print(s);
  141.         return new Out(ps);
  142.     }
  143.  
  144.     public static Out print(PrintStream ps, String s, int w) {
  145.         ps.print(s);
  146.         space(ps, s.length() - w);
  147.         return new Out(ps);
  148.     }
  149.  
  150.     public static Out println(PrintStream ps, String s) {
  151.         ps.print(s);
  152.         return new Out(ps);
  153.     }
  154.  
  155.     public static Out print(PrintStream ps, char c) {
  156.         ps.print(c);
  157.         return new Out(ps);
  158.     }
  159.  
  160.     public static Out println(PrintStream ps, char c) {
  161.         ps.println(c);
  162.         return new Out(ps);
  163.     }
  164.  
  165.     public static Out print(PrintStream ps, long l) {
  166.         ps.print(l);
  167.         return new Out(ps);
  168.     }
  169.  
  170.     public static Out print(PrintStream ps, long l, int w) {
  171.         String s = String.valueOf(l);
  172.  
  173.         return print(ps, s, w);
  174.     }
  175.  
  176.     public static Out print(PrintStream ps, double d) {
  177.         ps.print(d);
  178.         return new Out(ps);
  179.     }
  180.  
  181.     public static Out print(PrintStream ps, boolean b) {
  182.         ps.print(b);
  183.         return new Out(ps);
  184.     }
  185.  
  186.     public static Out print(PrintStream ps, boolean b, int w) {
  187.         String s = String.valueOf(b);
  188.         return print(ps, s, w);
  189.     }
  190.  
  191.     public static Out sep(PrintStream ps) {
  192.         ps.print(sep);
  193.         return new Out(ps);
  194.     }
  195.  
  196.     public static Out space(PrintStream ps, int i) {
  197.         if (i <= 0) { return std; }
  198.  
  199.         while(i-->0) {
  200.             ps.print(' ');
  201.         }
  202.  
  203.         return new Out(ps);
  204.     }
  205. }