src/share/classes/com/sun/tools/javap/BasicWriter.java

changeset 283
cd0630109de5
parent 54
eaf608c64fec
child 348
743f17b55b44
equal deleted inserted replaced
282:fc634a593812 283:cd0630109de5
42 */ 42 */
43 public class BasicWriter { 43 public class BasicWriter {
44 protected BasicWriter(Context context) { 44 protected BasicWriter(Context context) {
45 lineWriter = LineWriter.instance(context); 45 lineWriter = LineWriter.instance(context);
46 out = context.get(PrintWriter.class); 46 out = context.get(PrintWriter.class);
47 messages = context.get(Messages.class);
48 if (messages == null)
49 throw new AssertionError();
47 } 50 }
48 51
49 protected void print(String s) { 52 protected void print(String s) {
50 lineWriter.print(s); 53 lineWriter.print(s);
51 } 54 }
86 protected String report(String msg) { 89 protected String report(String msg) {
87 out.println("Error: " + msg); // i18n? 90 out.println("Error: " + msg); // i18n?
88 return "???"; 91 return "???";
89 } 92 }
90 93
94 protected String space(int w) {
95 if (w < spaces.length && spaces[w] != null)
96 return spaces[w];
97
98 StringBuilder sb = new StringBuilder();
99 for (int i = 0; i < w; i++)
100 sb.append(" ");
101
102 String s = sb.toString();
103 if (w < spaces.length)
104 spaces[w] = s;
105
106 return s;
107 }
108
109 private String[] spaces = new String[80];
110
91 private LineWriter lineWriter; 111 private LineWriter lineWriter;
92 private PrintWriter out; 112 private PrintWriter out;
113 protected Messages messages;
93 114
94 private static class LineWriter { 115 private static class LineWriter {
95 static LineWriter instance(Context context) { 116 static LineWriter instance(Context context) {
96 LineWriter instance = context.get(LineWriter.class); 117 LineWriter instance = context.get(LineWriter.class);
97 if (instance == null) 118 if (instance == null)

mercurial