Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: openjava/tools/DebugOut.java


1   /*
2    * DebugOut.java 1.0
3    *
4    * This class manages imported classes with statement
5    * "import foo.Bar;" and "import foo.*;".
6    *
7    * Apr 7, 1998
8    *  
9    * @version 1.0 last updated: Apr 7, 1998
10   * @author  Michiaki Tatsubori
11   */
12  package openjava.tools;
13  
14  
15  import java.io.PrintStream;
16  
17  
18  /**
19   * The DebugOut class is used to print something in debugging.
20   * No instance should be allocate and this class should be used statically.
21   *
22   * <p>This class implements most methods of public printing methods
23   * found in java.io.PrintWriter, as static methods.
24   *
25   * @version   1.0a1, 98/04/10
26   * @author  Michiaki Tatsubori
27   * @since  JDK1.1
28   * @see         openjava.ptree.NonLeaf
29   */
30  public final class DebugOut
31  {
32      private static int debugLevel = 0;
33  
34      public static void setDebugLevel( int level ) {
35    debugLevel = level;
36      }
37  
38      /**
39       * for debug
40       */
41      protected static PrintStream out = System.err;
42    
43      /** Flush the stream. */
44      public static void flush() {
45          if (debugLevel > 2)  out.flush();
46      }
47    
48      /** Close the stream. */
49      public static void close() {
50          if (debugLevel > 2)  out.close();
51      }
52  
53      /**
54       * Flush the stream and check its error state.  Errors are cumulative;
55       * once the stream encounters an error, this routine will return true on
56       * all successive calls.
57       *
58       * @return True if the print stream has encountered an error, either on
59       * the underlying output stream or during a format conversion.
60       */
61      public static boolean checkError() {
62    return out.checkError();
63      }
64    
65      /* Methods that do not terminate lines */
66    
67      /** Print a boolean. */
68      public static void print( boolean b ) {
69          if (debugLevel > 2)  out.print( b );
70      }
71    
72      /** Print a character. */
73      public static void print( char c ) {
74          if (debugLevel > 2)  out.print( c );
75      }
76    
77      /** Print an integer. */
78      public static void print( int i ) {
79          if (debugLevel > 2)  out.print( i );
80      }
81    
82      /** Print a long. */
83      public static void print( long l ) {
84          if (debugLevel > 2)  out.print( l );
85      }
86    
87      /** Print a float. */
88      public static void print( float f ) {
89          if (debugLevel > 2)  out.print( f );
90      }
91    
92      /** Print a double. */
93      public static void print( double d ) {
94          if (debugLevel > 2)  out.print( d );
95      }
96    
97      /** Print an array of chracters. */
98      public static void print( char s[] ) {
99          if (debugLevel > 2)  out.print( s );
100     }
101   
102     /** Print a String. */
103     public static void print( String s ) {
104         if (debugLevel > 2)  out.print( s );
105     }
106   
107     /** Print an object. */
108     public static void print( Object obj ) {
109         if (debugLevel > 2)  out.print( obj );
110     }
111   
112     /* Methods that do terminate lines */
113   
114     /** Finish the line. */
115     public static void println() {
116         if (debugLevel > 2)  out.println();
117     }
118   
119     /** Print a boolean, and then finish the line. */
120     public static void println( boolean x ) {
121         if (debugLevel > 2)  out.println( x );
122     }
123   
124     /** Print a character, and then finish the line. */
125     public static void println( char x ) {
126         if (debugLevel > 2)  out.println( x );
127     }
128   
129     /** Print an integer, and then finish the line. */
130     public static void println( int x ) {
131         if (debugLevel > 2)  out.println( x );
132     }
133   
134     /** Print a long, and then finish the line. */
135     public static void println( long x ) {
136         if (debugLevel > 2)  out.println( x );
137     }
138   
139     /** Print a float, and then finish the line. */
140     public static void println( float x ) {
141         if (debugLevel > 2)  out.println( x );
142     }
143   
144     /** Print a double, and then finish the line. */
145     public static void println( double x ) {
146         if (debugLevel > 2)  out.println( x );
147     }
148   
149     /** Print an array of characters, and then finish the line. */
150     public static void println( char x[] ) {
151         if (debugLevel > 2)  out.println( x );
152     }
153   
154     /** Print a String, and then finish the line. */
155     public static void println( String x ) {
156         if (debugLevel > 2)  out.println( x );
157     }
158   
159     /** Print an Object, and then finish the line. */
160     public static void println( Object x ) {
161         if (debugLevel > 2)  out.println( x );
162     }
163   
164 }
165 
166 
167