1 19 package org.netbeans.api.xml.parsers; 20 21 import org.openide.ErrorManager; 22 import org.openide.util.Lookup; 23 import org.openide.util.NbBundle; 24 25 29 class Util { 30 31 32 public static final Util THIS = new Util(); 33 34 35 private Util () { 36 } 37 38 39 private String packageName; 40 41 private ErrorManager packageErrorManager; 42 43 private static final int DEBUG_SEVERITY = ErrorManager.INFORMATIONAL; 44 45 48 private final synchronized String getPackageName () { 49 if ( packageName == null ) { 50 packageName = this.getClass().getPackage().getName().intern(); 52 } 53 return packageName; 54 } 55 56 57 61 62 67 public final String getString (String key) { 68 if (key == null) throw new NullPointerException (); 69 return NbBundle.getMessage (this.getClass(), key); 70 } 71 72 78 public final String getString (String key, Object param) { 79 if (key == null) throw new NullPointerException (); 80 return NbBundle.getMessage (this.getClass(), key, param); 81 } 82 83 90 public final String getString (String key, Object param1, Object param2) { 91 if (key == null) throw new NullPointerException (); 92 return NbBundle.getMessage (this.getClass(), key, param1, param2); 93 } 94 95 100 public final char getChar (String key) { 101 if (key == null) throw new NullPointerException (); 102 return NbBundle.getMessage (this.getClass(), key).charAt (0); 103 } 104 105 106 110 114 public final boolean isLoggable () { 115 return getErrorManager().isLoggable (DEBUG_SEVERITY); 116 } 117 118 123 public final void debug (String message) { 124 if (message == null) return; 125 getErrorManager().log (DEBUG_SEVERITY, message); 126 } 127 128 133 public final void debug (Throwable ex) { 134 if (ex == null) return; 135 getErrorManager().notify (DEBUG_SEVERITY, ex); 136 } 137 138 144 public final void debug (String message, Throwable ex) { 145 if (ex == null) return; 146 if (message != null) { 147 ex = getErrorManager().annotate(ex, DEBUG_SEVERITY, message, null, null, null); 148 } 149 debug (ex); 150 } 151 152 157 public final synchronized ErrorManager getErrorManager () { 158 if ( packageErrorManager == null ) { 159 String pack = getPackageName(); 160 packageErrorManager = ErrorManager.getDefault().getInstance(pack); 161 } 162 return packageErrorManager; 163 } 164 165 } 166 | Popular Tags |