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