1 19 package org.netbeans.modules.css; 20 21 import org.openide.ErrorManager; 22 import org.openide.util.Lookup; 23 import org.openide.util.NbBundle; 24 25 38 public abstract class AbstractUtil { 39 40 41 private String packageName; 42 43 private ErrorManager packageErrorManager; 44 45 private static final int DEBUG_SEVERITY = ErrorManager.INFORMATIONAL; 46 47 50 private final synchronized String getPackageName () { 51 if ( packageName == null ) { 52 packageName = this.getClass().getPackage().getName().intern(); 54 } 55 return packageName; 56 } 57 58 59 63 64 69 public final String getString (String key) { 70 if (key == null) throw new NullPointerException (); 71 return NbBundle.getMessage (this.getClass(), key); 72 } 73 74 80 public final String getString (String key, Object param) { 81 if (key == null) throw new NullPointerException (); 82 return NbBundle.getMessage (this.getClass(), key, param); 83 } 84 85 92 public final String getString (String key, Object param1, Object param2) { 93 if (key == null) throw new NullPointerException (); 94 return NbBundle.getMessage (this.getClass(), key, param1, param2); 95 } 96 97 102 public final char getChar (String key) { 103 if (key == null) throw new NullPointerException (); 104 return NbBundle.getMessage (this.getClass(), key).charAt (0); 105 } 106 107 108 112 116 public final boolean isLoggable () { 117 return getErrorManager().isLoggable (DEBUG_SEVERITY); 118 } 119 120 125 public final void debug (String message) { 126 if (message == null) return; 127 getErrorManager().log (DEBUG_SEVERITY, message); 128 } 129 130 135 public final void debug (Throwable ex) { 136 if (ex == null) return; 137 getErrorManager().notify (DEBUG_SEVERITY, ex); 138 } 139 140 146 public final void debug (String message, Throwable ex) { 147 if (ex == null) return; 148 if (message != null) { 149 ex = getErrorManager().annotate(ex, DEBUG_SEVERITY, message, null, null, null); 150 } 151 debug (ex); 152 } 153 154 159 public final synchronized ErrorManager getErrorManager () { 160 if ( packageErrorManager == null ) { 161 String pack = getPackageName(); 162 packageErrorManager = ErrorManager.getDefault().getInstance(pack); 163 } 164 return packageErrorManager; 165 } 166 167 } 168 | Popular Tags |