This commit was manufactured by cvs2svn to create branch 'R1_0'.
Cherrypick from unlabeled-1.2.2 2001-08-29 13:49:26 UTC DJ Houghton <dj> 'fix for: 1GJ837O: ITPCORE:ALL - Typo in Messages.properties references':
org.eclipse.pde.build/src/org/eclipse/pde/internal/build/Policy.java
diff --git a/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/Policy.java b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/Policy.java
new file mode 100644
index 0000000..78719b4
--- /dev/null
+++ b/org.eclipse.pde.build/src/org/eclipse/pde/internal/build/Policy.java
@@ -0,0 +1,110 @@
+package org.eclipse.pde.internal.core;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.core.runtime.*;
+import java.util.*;
+
+class Policy {
+ private static ResourceBundle bundle;
+ private static final String bundleName = "org.eclipse.pde.internal.core.messages";
+
+ static {
+ relocalize();
+ }
+
+/**
+ * Lookup the message with the given ID in this catalog
+ */
+public static String bind(String id) {
+ return bind(id, (String[])null);
+}
+/**
+ * Lookup the message with the given ID in this catalog and bind its
+ * substitution locations with the given string.
+ */
+public static String bind(String id, String binding) {
+ return bind(id, new String[] {binding});
+}
+/**
+ * Lookup the message with the given ID in this catalog and bind its
+ * substitution locations with the given strings.
+ */
+public static String bind(String id, String binding1, String binding2) {
+ return bind(id, new String[] {binding1, binding2});
+}
+
+/**
+ * Lookup the message with the given ID in this catalog and bind its
+ * substitution locations with the given string values.
+ */
+public static String bind(String id, String[] bindings) {
+ if (id == null)
+ return "No message available";
+ String message = null;
+ try {
+ message = bundle.getString(id);
+ } catch (MissingResourceException e) {
+ // If we got an exception looking for the message, fail gracefully by just returning
+ // the id we were looking for. In most cases this is semi-informative so is not too bad.
+ return "Missing message: " + id + "in: " + bundleName;
+ }
+ if (bindings == null)
+ return message;
+ int length = message.length();
+ int start = -1;
+ int end = length;
+ StringBuffer output = new StringBuffer(80);
+ while (true) {
+ if ((end = message.indexOf('{', start)) > -1) {
+ output.append(message.substring(start + 1, end));
+ if ((start = message.indexOf('}', end)) > -1) {
+ int index = -1;
+ try {
+ index = Integer.parseInt(message.substring(end + 1, start));
+ output.append(bindings[index]);
+ } catch (NumberFormatException nfe) {
+ output.append(message.substring(end + 1, start + 1));
+ } catch (ArrayIndexOutOfBoundsException e) {
+ output.append("{missing " + Integer.toString(index) + "}");
+ }
+ } else {
+ output.append(message.substring(end, length));
+ break;
+ }
+ } else {
+ output.append(message.substring(start + 1, length));
+ break;
+ }
+ }
+ return output.toString();
+}
+public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
+ if (monitor == null)
+ return new NullProgressMonitor();
+ return monitor;
+}
+/**
+ * Creates a NLS catalog for the given locale.
+ */
+public static void relocalize() {
+ bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
+}
+public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
+ if (monitor == null)
+ return new NullProgressMonitor();
+ if (monitor instanceof NullProgressMonitor)
+ return monitor;
+ return new SubProgressMonitor(monitor, ticks);
+}
+public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks, int style) {
+ if (monitor == null)
+ return new NullProgressMonitor();
+ if (monitor instanceof NullProgressMonitor)
+ return monitor;
+ return new SubProgressMonitor(monitor, ticks, style);
+}
+}