1 19 package org.netbeans.tax; 20 21 import java.util.ResourceBundle ; 22 import java.text.MessageFormat ; 23 24 29 public abstract class AbstractUtil { 30 31 private boolean loggable; 32 33 private boolean loggableInit = false; 34 35 private ResourceBundle bundle; 36 37 38 43 public static boolean equals (Object a, Object b) { 44 if ( a != null ) { 45 return (a.equals (b)); 46 } else { 47 return (a == b); 48 } 49 } 50 51 54 public final void debug (String message, Throwable ex) { 55 if ( isLoggable() ) { 56 System.err.println("[org.netbeans.tax] " + message); 57 if ( ex != null ) { 58 ex.printStackTrace (System.err); 59 } 60 } 61 } 62 63 64 67 public final void debug (String message) { 68 debug (message, null); 69 } 70 71 72 75 public final void debug (Throwable ex) { 76 debug (ex.getMessage(), ex); 77 } 78 79 80 82 public final synchronized boolean isLoggable () { 83 if ( loggableInit == false ) { 84 loggable = Boolean.getBoolean("org.netbeans.tax"); loggableInit = true; 86 } 87 return loggable; 88 } 89 90 93 protected final synchronized ResourceBundle getBundle () { 94 return ResourceBundle.getBundle(getClass().getName().replaceFirst("\\.[^.]+$", ".Bundle")); } 96 97 101 public final String getString (String key) { 102 return getBundle ().getString (key); 103 } 104 105 110 public final String getString (String key, Object param) { 111 return MessageFormat.format (getBundle().getString (key), new Object [] {param}); 112 } 113 114 118 public final char getChar (String key) { 119 return getString (key).charAt (0); 120 } 121 122 } 123 | Popular Tags |