1 11 package org.eclipse.core.resources.ant; 12 13 import java.text.MessageFormat ;import java.util.*; 15 import org.eclipse.core.runtime.IProgressMonitor; 16 import org.eclipse.core.runtime.NullProgressMonitor; 17 18 public class Policy { 19 private static final String bundleName = "org.eclipse.core.resources.ant.messages"; private static ResourceBundle bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault()); 21 22 25 public static String bind(String id) { 26 return bind(id, (String []) null); 27 } 28 29 public static IProgressMonitor monitorFor(IProgressMonitor monitor) { 30 if (monitor == null) 31 return new NullProgressMonitor(); 32 return monitor; 33 } 34 35 39 public static String bind(String id, String binding) { 40 return bind(id, new String [] {binding}); 41 } 42 43 47 public static String bind(String id, String binding1, String binding2) { 48 return bind(id, new String [] {binding1, binding2}); 49 } 50 51 55 public static String bind(String id, String [] bindings) { 56 if (id == null) 57 return "No message available"; String message = null; 59 try { 60 message = bundle.getString(id); 61 } catch (MissingResourceException e) { 62 return "Missing message: " + id + " in: " + bundleName; } 66 if (bindings == null) 67 return message; 68 return MessageFormat.format(message, bindings); 69 } 70 } 71 | Popular Tags |