001 /*
002 * Out.java
003 *
004 * Copyright (c) 1995-2010, The University of Sheffield. See the file
005 * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
006 *
007 * This file is part of GATE (see http://gate.ac.uk/), and is free
008 * software, licenced under the GNU Library General Public License,
009 * Version 2, June 1991 (in the distribution as file licence.html,
010 * and also available at http://gate.ac.uk/gate/licence.html).
011 *
012 * Cristian URSU, 29 September 2000
013 *
014 * $Id: Out.java 12006 2009-12-01 17:24:28Z thomas_heitz $
015 */
016
017 package gate.util;
018
019 import java.io.PrintWriter;
020
021 /** Shorthand for the <CODE> System.out.print and println</CODE>
022 * methods.
023 */
024 public class Out {
025 /** Debug flag */
026 private static final boolean DEBUG = false;
027
028 /** A printwriter to delegate to */
029 private static PrintWriter out = new PrintWriter(System.out,true);
030
031 /** Don't construct any of these */
032 private Out() {}
033
034 /** Flush the output stream. */
035 public static void flush() { out.flush(); }
036
037 /** This sets a new printWriter*/
038 public static void setPrintWriter(PrintWriter aPrintWriter){
039 out = aPrintWriter;
040 }//setPrintWriter
041
042 /** This sets a new printWriter*/
043 public static PrintWriter getPrintWriter(){
044 return out;
045 }
046
047 // print() and println() methods definition
048 ////////////////////////////////////////////////
049
050 // print
051
052 /** @see java.io.PrintWriter#print(boolean) */
053 public static void print(boolean b) {
054 out.print(b);
055 out.flush();
056 }
057
058 /** @see java.io.PrintWriter#print(char) */
059 public static void print(char c) {
060 out.print(c);
061 out.flush();
062 }
063
064 /** @see java.io.PrintWriter#print(int) */
065 public static void print(int i) {
066 out.print(i);
067 out.flush();
068 }
069
070 /** @see java.io.PrintWriter#print(long) */
071 public static void print(long l) {
072 out.print(l);
073 out.flush();
074 }
075
076 /** @see java.io.PrintWriter#print(float) */
077 public static void print(float f) {
078 out.print(f);
079 out.flush();
080 }
081
082 /** @see java.io.PrintWriter#print(double) */
083 public static void print(double d) {
084 out.print(d);
085 out.flush();
086 }
087
088 /** @see java.io.PrintWriter#print(char[]) */
089 public static void print(char s[]) {
090 out.print(s);
091 out.flush();
092 }
093
094 /** @see java.io.PrintWriter#print(java.lang.String) */
095 public static void print(String s) {
096 out.print(s);
097 out.flush();
098 }
099
100 /** @see java.io.PrintWriter#print(java.lang.Object) */
101 public static void print(Object obj) {
102 out.print(obj);
103 out.flush();
104 }
105
106 // println
107
108 /** @see java.io.PrintWriter#println() */
109 public static void println() {
110 out.println();
111 }
112
113 /** @see java.io.PrintWriter#println(boolean) */
114 public static void println(boolean x) {
115 out.println(x);
116 }
117
118 /** @see java.io.PrintWriter#println(char) */
119 public static void println(char x) {
120 out.println(x);
121 }
122
123 /** @see java.io.PrintWriter#println(int) */
124 public static void println(int x) {
125 out.println(x);
126 }
127
128 /** @see java.io.PrintWriter#println(long) */
129 public static void println(long x) {
130 out.println(x);
131 }
132
133 /** @see java.io.PrintWriter#println(float) */
134 public static void println(float x) {
135 out.println(x);
136 }
137
138 /** @see java.io.PrintWriter#println(double) */
139 public static void println(double x) {
140 out.println(x);
141 }
142
143 /** @see java.io.PrintWriter#println(char[]) */
144 public static void println(char x[]) {
145 out.println(x);
146 }
147
148 /** @see java.io.PrintWriter#println(java.lang.String) */
149 public static void println(String x) {
150 out.println(x);
151 }
152
153 /** @see java.io.PrintWriter#println(java.lang.Object) */
154 public static void println(Object x) {
155 out.println(x);
156 }
157
158 // pr and prln uses print and println so further modifications
159 // must be done to print and println only
160 ////////////////////////////////////////////////////////////////
161
162 /** @see java.io.PrintWriter#print(boolean) */
163 public static void pr(boolean b) {
164 print(b);
165 }
166
167 /** @see java.io.PrintWriter#print(char) */
168 public static void pr(char c) {
169 print(c);
170 }
171
172 /** @see java.io.PrintWriter#print(int) */
173 public static void pr(int i) {
174 print(i);
175 }
176
177 /** @see java.io.PrintWriter#print(long) */
178 public static void pr(long l) {
179 print(l);
180 }
181
182 /** @see java.io.PrintWriter#print(float) */
183 public static void pr(float f) {
184 print(f);
185 }
186
187 /** @see java.io.PrintWriter#print(double) */
188 public static void pr(double d) {
189 print(d);
190 }
191
192 /** @see java.io.PrintWriter#print(char[]) */
193 public static void pr(char s[]) {
194 print(s);
195 }
196
197 /** @see java.io.PrintWriter#print(java.lang.String) */
198 public static void pr(String s) {
199 print(s);
200 }
201
202 /** @see java.io.PrintWriter#print(java.lang.Object) */
203 public static void pr(Object obj) {
204 print(obj);
205 }
206
207 /** @see java.io.PrintWriter#println() */
208 public static void prln() {
209 println();
210 }
211
212 /** @see java.io.PrintWriter#println(boolean) */
213 public static void prln(boolean x) {
214 println(x);
215 }
216
217 /** @see java.io.PrintWriter#println(char) */
218 public static void prln(char x) {
219 println(x);
220 }
221
222 /** @see java.io.PrintWriter#println(int) */
223 public static void prln(int x) {
224 println(x);
225 }
226
227 /** @see java.io.PrintWriter#println(long) */
228 public static void prln(long x) {
229 println(x);
230 }
231
232 /** @see java.io.PrintWriter#println(float) */
233 public static void prln(float x) {
234 println(x);
235 }
236
237 /** @see java.io.PrintWriter#println(double) */
238 public static void prln(double x) {
239 println(x);
240 }
241
242 /** @see java.io.PrintWriter#println(char[]) */
243 public static void prln(char x[]) {
244 println(x);
245 }
246
247 /** @see java.io.PrintWriter#println(java.lang.String) */
248 public static void prln(String x) {
249 println(x);
250 }
251
252 /** @see java.io.PrintWriter#println(java.lang.Object) */
253 public static void prln(Object x) {
254 println(x);
255 }
256
257 /** Char to pad with. */
258 private static char padChar = ' ';
259
260 /** A mutator method for padChar*/
261 public static void setPadChar(char aChar){
262 padChar = aChar;
263 }//setPadChar
264
265 /** An accesor method for padChar*/
266 public static char getPadChar(){
267 return padChar;
268 }//getPadChar
269
270 /** Print padding followed by String s. */
271 public static void padPr(String s, int padding) {
272 for(int i=0; i<padding; i++)
273 out.print(padChar);
274 out.print(s);
275 out.flush();
276 } // padPr(String,int)
277
278 } // Out
|