1 11 package org.eclipse.team.internal.ccvs.ssh2; 12 13 14 import java.text.MessageFormat ; 15 import java.util.MissingResourceException ; 16 import java.util.ResourceBundle ; 17 18 import org.eclipse.core.runtime.IProgressMonitor; 19 import org.eclipse.core.runtime.OperationCanceledException; 20 21 public class Policy { 22 protected static ResourceBundle bundle = null; 23 24 27 public static void localize(String bundleName) { 28 bundle = ResourceBundle.getBundle(bundleName); 29 } 30 31 35 public static String bind(String key) { 36 try { 37 return bundle.getString(key); 38 } catch (MissingResourceException e) { 39 return key; 40 } catch (NullPointerException e) { 41 return "!" + key + "!"; } 43 } 44 45 49 public static String bind(String id, String binding) { 50 return bind(id, new String [] { binding }); 51 } 52 53 57 public static String bind(String key, Object [] args) { 58 try { 59 return MessageFormat.format(bind(key), args); 60 } catch (MissingResourceException e) { 61 return key; 62 } catch (NullPointerException e) { 63 return "!" + key + "!"; } 65 } 66 67 public static void checkCanceled(IProgressMonitor monitor) { 68 if (monitor != null && monitor.isCanceled()) { 69 throw new OperationCanceledException(); 70 } 71 } 72 73 } 74 | Popular Tags |