1 7 package com.sun.tools.example.debug.tty; 8 9 import java.util.*; 10 import java.text.MessageFormat ; 11 22 public class MessageOutput { 23 27 static ResourceBundle textResources; 28 29 30 private static MessageFormat messageFormat; 31 32 36 static void fatalError(String messageKey) { 37 System.err.println(); 38 System.err.println(format("Fatal error")); 39 System.err.println(format(messageKey)); 40 Env.shutdown(); 41 } 42 43 46 static String format(String key) { 47 return (textResources.getString(key)); 48 } 49 50 54 static String format(String key, String argument) { 55 return format(key, new Object [] {argument}); 56 } 57 58 61 static synchronized String format(String key, Object [] arguments) { 62 if (messageFormat == null) { 63 messageFormat = new MessageFormat (textResources.getString(key)); 64 } else { 65 messageFormat.applyPattern (textResources.getString(key)); 66 } 67 return (messageFormat.format (arguments)); 68 } 69 70 81 static void printDirectln(String line) { 82 System.out.println(line); 83 } 84 static void printDirect(String line) { 85 System.out.print(line); 86 } 87 static void printDirect(char c) { 88 System.out.print(c); 89 } 90 91 95 static void println() { 96 System.out.println(); 97 } 98 99 102 static void print(String key) { 103 System.out.print(format(key)); 104 } 105 108 static void println(String key) { 109 System.out.println(format(key)); 110 } 111 112 113 117 static void print(String key, String argument) { 118 System.out.print(format(key, argument)); 119 } 120 static void println(String key, String argument) { 121 System.out.println(format(key, argument)); 122 } 123 124 128 static void println(String key, Object [] arguments) { 129 System.out.println(format(key, arguments)); 130 } 131 132 135 static void lnprint(String key) { 136 System.out.println(); 137 System.out.print(textResources.getString(key)); 138 } 139 140 static void lnprint(String key, String argument) { 141 System.out.println(); 142 System.out.print(format(key, argument)); 143 } 144 145 static void lnprint(String key, Object [] arguments) { 146 System.out.println(); 147 System.out.print(format(key, arguments)); 148 } 149 150 153 static void printException(String key, Exception e) { 154 if (key != null) { 155 try { 156 println(key); 157 } catch (MissingResourceException mex) { 158 printDirectln(key); 159 } 160 } 161 System.out.flush(); 162 e.printStackTrace(); 163 } 164 165 static void printPrompt() { 166 ThreadInfo threadInfo = ThreadInfo.getCurrentThreadInfo(); 167 if (threadInfo == null) { 168 System.out.print 169 (MessageOutput.format("jdb prompt with no current thread")); 170 } else { 171 System.out.print 172 (MessageOutput.format("jdb prompt thread name and current stack frame", 173 new Object [] { 174 threadInfo.getThread().name(), 175 new Integer (threadInfo.getCurrentFrameIndex() + 1)})); 176 } 177 System.out.flush(); 178 } 179 } 180 | Popular Tags |