~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/libs/jgdi/cullconv/src/com/sun/grid/cull/Printer.java

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 *
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 *
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 *
 
9
 *
 
10
 *  Sun Industry Standards Source License Version 1.2
 
11
 *  =================================================
 
12
 *  The contents of this file are subject to the Sun Industry Standards
 
13
 *  Source License Version 1.2 (the "License"); You may not use this file
 
14
 *  except in compliance with the License. You may obtain a copy of the
 
15
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
16
 *
 
17
 *  Software provided under this License is provided on an "AS IS" basis,
 
18
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
19
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
20
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
21
 *  See the License for the specific provisions governing your rights and
 
22
 *  obligations concerning the Software.
 
23
 *
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 *
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 *
 
28
 *   All Rights Reserved.
 
29
 *
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
package com.sun.grid.cull;
 
33
 
 
34
import java.io.*;
 
35
 
 
36
/**
 
37
 *
 
38
 */
 
39
public class Printer {
 
40
   
 
41
      private final static String INDENT = "  ";
 
42
      private PrintWriter pw;
 
43
      private StringBuffer indent = new StringBuffer();
 
44
      private boolean needIndent;
 
45
      
 
46
      public Printer( File file ) throws IOException {
 
47
         this(file, false);
 
48
      }
 
49
      
 
50
      public Printer( File file, boolean append ) throws IOException {
 
51
         
 
52
         File parent = file.getParentFile();
 
53
         if( !parent.exists() ) {
 
54
            parent.mkdirs();
 
55
         }
 
56
          FileWriter fw = new FileWriter( file, append );
 
57
          pw = new PrintWriter(fw);
 
58
      }
 
59
      
 
60
      public Printer() {
 
61
         pw = new PrintWriter( System.out );
 
62
      }
 
63
      
 
64
      public void printFile(File file) throws IOException {
 
65
         
 
66
         FileReader fr = new FileReader(file);
 
67
         BufferedReader br = new BufferedReader(fr);
 
68
         
 
69
         String line = null;
 
70
         while( (line=br.readLine()) != null) {
 
71
            println(line);
 
72
         }
 
73
         flush();
 
74
      }
 
75
      
 
76
      public void print( Object obj ) {
 
77
         if( needIndent ) {
 
78
            pw.print( indent );
 
79
            needIndent = false;
 
80
         }
 
81
         pw.print( obj );
 
82
      }
 
83
      
 
84
      public void print( char c ) {
 
85
         if( needIndent ) {
 
86
            pw.print( indent );
 
87
            needIndent = false;
 
88
         }
 
89
         pw.print( c );
 
90
      }
 
91
      
 
92
      public void print(int i) {
 
93
         if( needIndent ) {
 
94
            pw.print( indent );
 
95
            needIndent = false;
 
96
         }
 
97
         pw.print( i );
 
98
      }
 
99
      
 
100
      public void print(boolean b) {
 
101
         if( needIndent ) {
 
102
            pw.print( indent );
 
103
            needIndent = false;
 
104
         }
 
105
         pw.print( b );
 
106
      }
 
107
      
 
108
      public void print(long l) {
 
109
         if( needIndent ) {
 
110
            pw.print( indent );
 
111
            needIndent = false;
 
112
         }
 
113
         pw.print( l );
 
114
      }
 
115
      
 
116
      public void println( Object obj ) {
 
117
         if( needIndent ) {
 
118
            pw.print( indent );
 
119
            needIndent = false;
 
120
         }
 
121
         pw.println(obj);
 
122
         needIndent = true;
 
123
      }
 
124
 
 
125
      public void println( char c ) {
 
126
         if( needIndent ) {
 
127
            pw.print( indent );
 
128
            needIndent = false;
 
129
         }
 
130
         pw.println(c);
 
131
         needIndent = true;
 
132
      }
 
133
      
 
134
      public void println(int i) {
 
135
         if( needIndent ) {
 
136
            pw.print( indent );
 
137
            needIndent = false;
 
138
         }
 
139
         pw.println( i );
 
140
      }
 
141
      
 
142
      public void println() {
 
143
         pw.println();
 
144
         needIndent = true;
 
145
      }
 
146
      
 
147
      public void println(boolean b) {
 
148
         if( needIndent ) {
 
149
            pw.print( indent );
 
150
            needIndent = false;
 
151
         }
 
152
         pw.println( b );
 
153
      }
 
154
 
 
155
      public void println(long l) {
 
156
         if( needIndent ) {
 
157
            pw.print( indent );
 
158
            needIndent = false;
 
159
         }
 
160
         pw.println( l );
 
161
      }
 
162
      
 
163
      public void indent() {
 
164
         indent.append( INDENT );
 
165
      }
 
166
      public void deindent() {
 
167
         indent.setLength( indent.length() - INDENT.length() );
 
168
      }
 
169
      
 
170
      public void flush() {
 
171
         pw.flush();
 
172
      }
 
173
      
 
174
      public void close() {
 
175
         pw.close();
 
176
      }
 
177
   
 
178
}