Conversion to new NLS story
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ExpressionConverter.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ExpressionConverter.java
index 8d4f453..790f856 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ExpressionConverter.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/expressions/ExpressionConverter.java
@@ -19,6 +19,7 @@
import org.eclipse.core.internal.expressions.CompositeExpression;
import org.eclipse.core.internal.expressions.ExpressionMessages;
import org.eclipse.core.internal.expressions.ExpressionPlugin;
+import org.eclipse.core.internal.expressions.Messages;
/**
* An expression converter converts an XML expression represented by an
@@ -96,8 +97,8 @@
if (child == null)
throw new CoreException(new Status(IStatus.ERROR, ExpressionPlugin.getPluginId(),
IStatus.ERROR,
- ExpressionMessages.getFormattedString(
- "Expression.unknown_element", //$NON-NLS-1$
+ Messages.format(
+ ExpressionMessages.Expression_unknown_element, //$NON-NLS-1$
children[i].getName()),
null));
result.add(child);
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ExpressionMessages.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ExpressionMessages.java
index 5c095f2..3b26426 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ExpressionMessages.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ExpressionMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,57 +10,32 @@
*******************************************************************************/
package org.eclipse.core.internal.expressions;
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
+import org.eclipse.osgi.util.NLS;
-public class ExpressionMessages {
+public final class ExpressionMessages extends NLS {
- private static final String BUNDLE_NAME= "org.eclipse.core.internal.expressions.ExpressionMessages";//$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
+ private static final String BUNDLE_NAME = "org.eclipse.core.internal.expressions.ExpressionMessages";//$NON-NLS-1$
private ExpressionMessages() {
- // no instances
+ // Do not instantiate
}
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
+ public static String Expression_attribute_missing;
+ public static String Expression_attribute_invalid_value;
+ public static String Expression_variable_not_a_collection;
+ public static String Expression_variable_not_a_list;
+ public static String Expression_unknown_element;
+ public static String Expression_string_not_correctly_escaped;
+ public static String Expression_string_not_terminated;
+ public static String TypeExtender_unknownMethod;
+ public static String TypeExtender_incorrectType;
+ public static String TestExpression_no_name_space;
+ public static String WithExpression_variable_not_defined;
+ public static String ResolveExpression_variable_not_defined;
+ public static String PropertyTesterDescriptor_no_namespace;
+ public static String PropertyTesterDescritpri_no_properties;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, ExpressionMessages.class);
}
-
- public static String getFormattedString(String key, String arg) {
- try{
- return MessageFormat.format(RESOURCE_BUNDLE.getString(key), new String[] { arg });
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static String getFormattedString(String key, Object arg) {
- try{
- return MessageFormat.format(RESOURCE_BUNDLE.getString(key), new Object[] { arg });
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static String getFormattedString(String key, String[] args) {
- try{
- return MessageFormat.format(RESOURCE_BUNDLE.getString(key), args);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static String getFormattedString(String key, Object[] args) {
- try{
- return MessageFormat.format(RESOURCE_BUNDLE.getString(key), args);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-}
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ExpressionMessages.properties b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ExpressionMessages.properties
index a04fbaf..ed3f009 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ExpressionMessages.properties
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ExpressionMessages.properties
@@ -9,25 +9,25 @@
# IBM Corporation - initial API and implementation
###############################################################################
-Expression.attribute.missing=Mandatory attribute {0} is missing
-Expression.attribute.invalid_value=Attribute value {0} is not valid
+Expression_attribute_missing=Mandatory attribute {0} is missing
+Expression_attribute_invalid_value=Attribute value {0} is not valid
-Expression.variable.not_a_collection= The default variable is not of type java.util.Collection. Failed expression: \n{0}
-Expression.variable.not_a_list= The default variable is not of type java.util.List. Failed expression: \n{0}
+Expression_variable_not_a_collection= The default variable is not of type java.util.Collection. Failed expression: \n{0}
+Expression_variable_not_a_list= The default variable is not of type java.util.List. Failed expression: \n{0}
-Expression.unknown_element= Unknown expression element {0}
+Expression_unknown_element= Unknown expression element {0}
-Expression.string_not_correctly_escaped= The String {0} is not correctly escaped. Wrong number of apostrophe characters.
-Expression.string_not_terminated= The String {0} is not correctly terminated with an apostrophe character.
+Expression_string_not_correctly_escaped= The String {0} is not correctly escaped. Wrong number of apostrophe characters.
+Expression_string_not_terminated= The String {0} is not correctly terminated with an apostrophe character.
-TypeExtender.unknownMethod= No property tester contributes a property {0} to type {1}
-TypeExtender.incorrectType=The implementation class is not a sub type of org.eclipse.core.expressions.PropertyTester
+TypeExtender_unknownMethod= No property tester contributes a property {0} to type {1}
+TypeExtender_incorrectType=The implementation class is not a sub type of org.eclipse.core.expressions.PropertyTester
-TestExpression.no_name_space= The property attribute of the test expression must be qualified by a name space.
+TestExpression_no_name_space= The property attribute of the test expression must be qualified by a name space.
-WithExpression.variable_not_defined= The variable {0} is not defined
+WithExpression_variable_not_defined= The variable {0} is not defined
-ResolveExpression.variable_not_defined= The variable {0} is not defined
+ResolveExpression_variable_not_defined= The variable {0} is not defined
-PropertyTesterDescriptor.no_namespace= The mandatory attribute namespace is missing. Tester has been disabled.
-PropertyTesterDescritpri.no_properties= The mandatory attribute properties is missing. Tester has been disabled.
+PropertyTesterDescriptor_no_namespace= The mandatory attribute namespace is missing. Tester has been disabled.
+PropertyTesterDescritpri_no_properties= The mandatory attribute properties is missing. Tester has been disabled.
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Expressions.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Expressions.java
index 87a1b87..eb75302 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Expressions.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Expressions.java
@@ -58,7 +58,7 @@
if (value == null) {
throw new CoreException(new ExpressionStatus(
ExpressionStatus.MISSING_ATTRIBUTE,
- ExpressionMessages.getFormattedString("Expression.attribute.missing", name))); //$NON-NLS-1$
+ Messages.format(ExpressionMessages.Expression_attribute_missing, name)));
}
}
@@ -70,7 +70,7 @@
}
throw new CoreException(new ExpressionStatus(
ExpressionStatus.WRONG_ATTRIBUTE_VALUE,
- ExpressionMessages.getFormattedString("Expression.attribute.invalid_value", value))); //$NON-NLS-1$
+ Messages.format(ExpressionMessages.Expression_attribute_invalid_value, value)));
}
public static void checkCollection(Object var, Expression expression) throws CoreException {
@@ -78,7 +78,7 @@
return;
throw new CoreException(new ExpressionStatus(
ExpressionStatus.VARIABLE_IS_NOT_A_COLLECTION,
- ExpressionMessages.getFormattedString("Expression.variable.not_a_collection", expression.toString()))); //$NON-NLS-1$
+ Messages.format(ExpressionMessages.Expression_variable_not_a_collection, expression.toString())));
}
public static void checkList(Object var, Expression expression) throws CoreException {
@@ -86,7 +86,7 @@
return;
throw new CoreException(new ExpressionStatus(
ExpressionStatus.VARIABLE_IS_NOT_A_LIST,
- ExpressionMessages.getFormattedString("Expression.variable.not_a_list", expression.toString()))); //$NON-NLS-1$
+ Messages.format(ExpressionMessages.Expression_variable_not_a_list, expression.toString())));
}
//---- Argument parsing --------------------------------------------
@@ -137,7 +137,7 @@
if (inString)
throw new CoreException(new ExpressionStatus(
ExpressionStatus.STRING_NOT_TERMINATED,
- ExpressionMessages.getFormattedString("Expression.string_not_terminated", str))); //$NON-NLS-1$
+ Messages.format(ExpressionMessages.Expression_string_not_terminated, str)));
return -1;
}
@@ -176,7 +176,7 @@
if (i == str.length() - 1 || str.charAt(i + 1) != '\'')
throw new CoreException(new ExpressionStatus(
ExpressionStatus.STRING_NOT_CORRECT_ESCAPED,
- ExpressionMessages.getFormattedString("Expression.string_not_correctly_escaped", str))); //$NON-NLS-1$
+ Messages.format(ExpressionMessages.Expression_string_not_correctly_escaped, str)));
result.append('\'');
i++;
} else {
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Messages.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Messages.java
new file mode 100644
index 0000000..c17ee61
--- /dev/null
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/Messages.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.internal.expressions;
+
+import java.text.MessageFormat;
+
+/**
+ * Helper class to format message strings.
+ *
+ * @since 3.1
+ */
+public class Messages {
+
+ public static String format(String message, Object object) {
+ return MessageFormat.format(message, new Object[] { object});
+ }
+
+ public static String format(String message, Object[] objects) {
+ return MessageFormat.format(message, objects);
+ }
+
+ private Messages() {
+ // Not for instantiation
+ }
+}
\ No newline at end of file
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/PropertyTesterDescriptor.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/PropertyTesterDescriptor.java
index a651a27..a6b12f5 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/PropertyTesterDescriptor.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/PropertyTesterDescriptor.java
@@ -36,7 +36,7 @@
if (fNamespace == null) {
throw new CoreException(new Status(IStatus.ERROR, ExpressionPlugin.getPluginId(),
IStatus.ERROR,
- ExpressionMessages.getString("PropertyTesterDescriptor.no_namespace"), //$NON-NLS-1$
+ ExpressionMessages.PropertyTesterDescriptor_no_namespace,
null));
}
StringBuffer buffer= new StringBuffer(","); //$NON-NLS-1$
@@ -44,7 +44,7 @@
if (properties == null) {
throw new CoreException(new Status(IStatus.ERROR, ExpressionPlugin.getPluginId(),
IStatus.ERROR,
- ExpressionMessages.getString("PropertyTesterDescritpri.no_properties"), //$NON-NLS-1$
+ ExpressionMessages.PropertyTesterDescritpri_no_properties,
null));
}
for (int i= 0; i < properties.length(); i++) {
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java
index 4344d9f..7c8a26d 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/ResolveExpression.java
@@ -36,7 +36,7 @@
if (variable == null) {
throw new CoreException(new ExpressionStatus(
ExpressionStatus.VARIABLE_NOT_DEFINED,
- ExpressionMessages.getFormattedString("ResolveExpression.variable_not_defined", fVariable))); //$NON-NLS-1$
+ Messages.format(ExpressionMessages.ResolveExpression_variable_not_defined, fVariable)));
}
return evaluateAnd(new EvaluationContext(context, variable));
}
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TestExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TestExpression.java
index 53c9aaf..62ab93c 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TestExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TestExpression.java
@@ -35,7 +35,7 @@
if (pos == -1) {
throw new CoreException(new ExpressionStatus(
ExpressionStatus.NO_NAMESPACE_PROVIDED,
- ExpressionMessages.getString("TestExpression.no_name_space"))); //$NON-NLS-1$
+ ExpressionMessages.TestExpression_no_name_space));
}
fNamespace= property.substring(0, pos);
fProperty= property.substring(pos + 1);
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtension.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtension.java
index 5f04c38..cc31a88 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtension.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtension.java
@@ -98,7 +98,7 @@
fExtenders[i]= null;
throw new CoreException(new ExpressionStatus(
ExpressionStatus.TYPE_EXTENDER_INCORRECT_TYPE,
- ExpressionMessages.getString("TypeExtender.incorrectType"), //$NON-NLS-1$
+ ExpressionMessages.TypeExtender_incorrectType,
e));
}
} else {
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtensionManager.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtensionManager.java
index a88251b..65086d7 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtensionManager.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/TypeExtensionManager.java
@@ -103,8 +103,8 @@
if (extender == TypeExtension.CONTINUE || extender == null) {
throw new CoreException(new ExpressionStatus(
ExpressionStatus.TYPE_EXTENDER_UNKOWN_METHOD,
- ExpressionMessages.getFormattedString(
- "TypeExtender.unknownMethod", //$NON-NLS-1$
+ Messages.format(
+ ExpressionMessages.TypeExtender_unknownMethod, //$NON-NLS-1$
new Object[] {method, clazz.toString()})));
}
result.setPropertyTester(extender);
diff --git a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/WithExpression.java b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/WithExpression.java
index b1a06d3..f63f6e3 100644
--- a/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/WithExpression.java
+++ b/bundles/org.eclipse.core.expressions/src/org/eclipse/core/internal/expressions/WithExpression.java
@@ -32,7 +32,7 @@
if (variable == null) {
throw new CoreException(new ExpressionStatus(
ExpressionStatus.VARIABLE_NOT_DEFINED,
- ExpressionMessages.getFormattedString("WithExpression.variable_not_defined", fVariable))); //$NON-NLS-1$
+ Messages.format(ExpressionMessages.WithExpression_variable_not_defined, fVariable)));
}
return evaluateAnd(new EvaluationContext(context, variable));
}