| Err |

    1   /*
    2    *  Err.java
    3    *
    4    *  Copyright (c) 1998-2001, The University of Sheffield.
    5    *
    6    *  This file is part of GATE (see http://gate.ac.uk/), and is free
    7    *  software, licenced under the GNU Library General Public License,
    8    *  Version 2, June 1991 (in the distribution as file licence.html,
    9    *  and also available at http://gate.ac.uk/gate/licence.html).
    10   *
    11   *  Cristian URSU, 29 September 2000
    12   *
    13   *  $Id: Err.java,v 1.7 2001/05/10 12:51:45 hamish Exp $
    14   */
    15
    16  package gate.util;
    17
    18  import java.io.*;
    19
    20  /** Shorthand for the <CODE> System.err.print and println</CODE>
    21    * methods.
    22    */
    23  public class Err {
    24    /** Debug flag */
    25    private static final boolean DEBUG = false;
    26
    27    /** A printwriter to delegate to */
    28    private static PrintWriter err = new PrintWriter(System.err,true);
    29
    30    /** Don't construct any of these */
    31    private Err() {}
    32
    33    /** Flush the output stream. */
    34    public static void flush() { err.flush(); }
    35
    36    /** This sets a new printWriter*/
    37    public static void setPrintWriter(PrintWriter aPrintWriter) {
    38      err = aPrintWriter;
    39    }//setPrintWriter
    40
    41    /** This sets a new printWriter*/
    42    public static PrintWriter getPrintWriter() {
    43      return err;
    44    }
    45
    46    // print() and println() methods definition
    47    ////////////////////////////////////////////////
    48
    49    /** @see java.io.PrintWriter#print(boolean) */
    50    public static void print(boolean b) {
    51      err.print(b);
    52      err.flush();
    53    }
    54
    55    /** @see java.io.PrintWriter#print(char) */
    56    public static void print(char c) {
    57      err.print(c);
    58      err.flush();
    59    }
    60
    61    /** @see java.io.PrintWriter#print(int) */
    62    public static void print(int i) {
    63      err.print(i);
    64      err.flush();
    65    }
    66
    67    /** @see java.io.PrintWriter#print(long) */
    68    public static void print(long l) {
    69      err.print(l);
    70      err.flush();
    71    }
    72
    73    /** @see java.io.PrintWriter#print(float) */
    74    public static void print(float f) {
    75      err.print(f);
    76      err.flush();
    77    }
    78
    79    /** @see java.io.PrintWriter#print(double) */
    80    public static void print(double d) {
    81      err.print(d);
    82      err.flush();
    83    }
    84
    85    /** @see java.io.PrintWriter#print(char[]) */
    86    public static void print(char s[]) {
    87      err.print(s);
    88      err.flush();
    89    }
    90
    91    /** @see java.io.PrintWriter#print(java.lang.String) */
    92    public static void print(String s) {
    93      err.print(s);
    94      err.flush();
    95    }
    96
    97    /** @see java.io.PrintWriter#print(java.lang.Object) */
    98    public static void print(Object obj) {
    99      err.print(obj);
    100     err.flush();
    101   }
    102
    103   /** @see java.io.PrintWriter#println() */
    104   public static void println() {
    105     err.println();
    106   }
    107
    108   /** @see java.io.PrintWriter#println(boolean) */
    109   public static void println(boolean x) {
    110     err.println(x);
    111   }
    112
    113   /** @see java.io.PrintWriter#println(char) */
    114   public static void println(char x) {
    115     err.println(x);
    116   }
    117
    118   /** @see java.io.PrintWriter#println(int) */
    119   public static void println(int x) {
    120     err.println(x);
    121   }
    122
    123   /** @see java.io.PrintWriter#println(long) */
    124   public static void println(long x) {
    125     err.println(x);
    126   }
    127
    128   /** @see java.io.PrintWriter#println(float) */
    129   public static void println(float x) {
    130     err.println(x);
    131   }
    132
    133   /** @see java.io.PrintWriter#println(double) */
    134   public static void println(double x) {
    135     err.println(x);
    136   }
    137
    138   /** @see java.io.PrintWriter#println(char[]) */
    139   public static void println(char x[]) {
    140     err.println(x);
    141   }
    142
    143   /** @see java.io.PrintWriter#println(java.lang.String) */
    144   public static void println(String x) {
    145     err.println(x);
    146   }
    147
    148   /** @see java.io.PrintWriter#println(java.lang.Object) */
    149   public static void println(Object x) {
    150     err.println(x);
    151   }
    152
    153   // pr and prln uses print and println so further modifications
    154   // must be done to print and println only
    155   ////////////////////////////////////////////////////////////////
    156
    157   /** @see java.io.PrintWriter#print(boolean) */
    158   public static void pr(boolean b) {
    159     print(b);
    160   }
    161
    162   /** @see java.io.PrintWriter#print(char) */
    163   public static void pr(char c) {
    164     print(c);
    165   }
    166
    167   /** @see java.io.PrintWriter#print(int) */
    168   public static void pr(int i) {
    169     print(i);
    170   }
    171
    172   /** @see java.io.PrintWriter#print(long) */
    173   public static void pr(long l) {
    174     print(l);
    175   }
    176
    177   /** @see java.io.PrintWriter#print(float) */
    178   public static void pr(float f) {
    179     print(f);
    180   }
    181
    182   /** @see java.io.PrintWriter#print(double) */
    183   public static void pr(double d) {
    184     print(d);
    185   }
    186
    187   /** @see java.io.PrintWriter#print(char[]) */
    188   public static void pr(char s[]) {
    189     print(s);
    190   }
    191
    192   /** @see java.io.PrintWriter#print(java.lang.String) */
    193   public static void pr(String s) {
    194     print(s);
    195   }
    196
    197   /** @see java.io.PrintWriter#print(java.lang.Object) */
    198   public static void pr(Object obj) {
    199     print(obj);
    200   }
    201
    202   /** @see java.io.PrintWriter#println() */
    203   public static void prln() {
    204     println();
    205   }
    206
    207   /** @see java.io.PrintWriter#println(boolean) */
    208   public static void prln(boolean x) {
    209     println(x);
    210   }
    211
    212   /** @see java.io.PrintWriter#println(char) */
    213   public static void prln(char x) {
    214     println(x);
    215   }
    216
    217   /** @see java.io.PrintWriter#println(int) */
    218   public static void prln(int x) {
    219     println(x);
    220   }
    221
    222   /** @see java.io.PrintWriter#println(long) */
    223   public static void prln(long x) {
    224     println(x);
    225   }
    226
    227   /** @see java.io.PrintWriter#println(float) */
    228   public static void prln(float x) {
    229     println(x);
    230   }
    231
    232   /** @see java.io.PrintWriter#println(double) */
    233   public static void prln(double x) {
    234     println(x);
    235   }
    236
    237   /** @see java.io.PrintWriter#println(char[]) */
    238   public static void prln(char x[]) {
    239     println(x);
    240   }
    241
    242   /** @see java.io.PrintWriter#println(java.lang.String) */
    243   public static void prln(String x) {
    244     println(x);
    245   }
    246
    247   /** @see java.io.PrintWriter#println(java.lang.Object) */
    248   public static void prln(Object x) {
    249     println(x);
    250   }
    251
    252   /** Char to pad with. */
    253   private static char padChar = ' ';
    254
    255   /** A mutator method for padChar*/
    256   public static void setPadChar(char aChar){
    257     padChar = aChar;
    258   }//setPadChar
    259
    260   /** An accesor method for padChar*/
    261   public static char getPadChar(){
    262     return padChar;
    263   }//getPadChar
    264
    265   /** Print padding followed by String s. */
    266   public static void padPr(String s, int padding) {
    267       for(int i=0; i<padding; i++)
    268                        err.print(padChar);
    269       err.print(s);
    270       err.flush();
    271   } // padPr(String,int)
    272
    273 } //Err
    274
    275

| Err |