Index: text/src/main/java/org/apache/harmony/text/internal/nls/messages.properties
===================================================================
--- text/src/main/java/org/apache/harmony/text/internal/nls/messages.properties (revision 0)
+++ text/src/main/java/org/apache/harmony/text/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: text/src/main/java/org/apache/harmony/text/internal/nls/Messages.java
===================================================================
--- text/src/main/java/org/apache/harmony/text/internal/nls/Messages.java (revision 0)
+++ text/src/main/java/org/apache/harmony/text/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.text.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.text.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.text.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: text/make/patternset.txt
===================================================================
--- text/make/patternset.txt (revision 433596)
+++ text/make/patternset.txt (working copy)
@@ -14,3 +14,5 @@
java/text/*
org/apache/harmony/text/*
+
+org/apache/harmony/text/internal/nls/*
Index: text/build.xml
===================================================================
--- text/build.xml (revision 433596)
+++ text/build.xml (working copy)
@@ -32,45 +32,45 @@
+ use the Eclipse Java compiler. -->
-
-
+
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
@@ -100,6 +100,15 @@
+
+
+
+
+
+
+
+
+
Index: applet/src/main/java/org/apache/harmony/applet/internal/nls/messages.properties
===================================================================
--- applet/src/main/java/org/apache/harmony/applet/internal/nls/messages.properties (revision 0)
+++ applet/src/main/java/org/apache/harmony/applet/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: applet/src/main/java/org/apache/harmony/applet/internal/nls/Messages.java
===================================================================
--- applet/src/main/java/org/apache/harmony/applet/internal/nls/Messages.java (revision 0)
+++ applet/src/main/java/org/apache/harmony/applet/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.applet.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.applet.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.applet.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: applet/make/patternset.txt
===================================================================
--- applet/make/patternset.txt (revision 433596)
+++ applet/make/patternset.txt (working copy)
@@ -13,3 +13,5 @@
# limitations under the License.
java/applet/*
+
+org/apache/harmony/applet/internal/nls/*
Index: applet/build.xml
===================================================================
--- applet/build.xml (revision 433596)
+++ applet/build.xml (working copy)
@@ -32,10 +32,10 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -66,6 +66,15 @@
+
+
+
+
+
+
+
+
+
Index: swing/src/main/java/common/org/apache/harmony/swing/internal/nls/messages.properties
===================================================================
--- swing/src/main/java/common/org/apache/harmony/swing/internal/nls/messages.properties (revision 0)
+++ swing/src/main/java/common/org/apache/harmony/swing/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: swing/src/main/java/common/org/apache/harmony/swing/internal/nls/Messages.java
===================================================================
--- swing/src/main/java/common/org/apache/harmony/swing/internal/nls/Messages.java (revision 0)
+++ swing/src/main/java/common/org/apache/harmony/swing/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.swing.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.swing.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.swing.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: swing/make/patternset.txt
===================================================================
--- swing/make/patternset.txt (revision 433596)
+++ swing/make/patternset.txt (working copy)
@@ -36,3 +36,5 @@
org/apache/harmony/x/swing/filechooser/windows/*
org/apache/harmony/x/swing/plaf/resources/basic/*
org/apache/harmony/x/swing/plaf/resources/metal/*
+
+org/apache/harmony/swing/internal/nls/*
Index: swing/build.xml
===================================================================
--- swing/build.xml (revision 433596)
+++ swing/build.xml (working copy)
@@ -32,7 +32,7 @@
+ use the Eclipse Java compiler. -->
@@ -43,7 +43,7 @@
-
+
@@ -78,6 +78,15 @@
+
+
+
+
+
+
+
+
+
Index: accessibility/src/main/java/org/apache/harmony/accessibility/internal/nls/messages.properties
===================================================================
--- accessibility/src/main/java/org/apache/harmony/accessibility/internal/nls/messages.properties (revision 0)
+++ accessibility/src/main/java/org/apache/harmony/accessibility/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: accessibility/src/main/java/org/apache/harmony/accessibility/internal/nls/Messages.java
===================================================================
--- accessibility/src/main/java/org/apache/harmony/accessibility/internal/nls/Messages.java (revision 0)
+++ accessibility/src/main/java/org/apache/harmony/accessibility/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.accessibility.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.accessibility.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.accessibility.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: accessibility/make/patternset.txt
===================================================================
--- accessibility/make/patternset.txt (revision 433596)
+++ accessibility/make/patternset.txt (working copy)
@@ -13,3 +13,5 @@
# limitations under the License.
javax/accessibility/*
+
+org/apache/harmony/accessibility/internal/nls/*
Index: accessibility/build.xml
===================================================================
--- accessibility/build.xml (revision 433596)
+++ accessibility/build.xml (working copy)
@@ -32,12 +32,12 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -68,6 +68,15 @@
+
+
+
+
+
+
+
+
+
Index: sound/src/main/java/org/apache/harmony/sound/internal/nls/messages.properties
===================================================================
--- sound/src/main/java/org/apache/harmony/sound/internal/nls/messages.properties (revision 0)
+++ sound/src/main/java/org/apache/harmony/sound/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: sound/src/main/java/org/apache/harmony/sound/internal/nls/Messages.java
===================================================================
--- sound/src/main/java/org/apache/harmony/sound/internal/nls/Messages.java (revision 0)
+++ sound/src/main/java/org/apache/harmony/sound/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.sound.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.sound.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.sound.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: sound/make/patternset.txt
===================================================================
--- sound/make/patternset.txt (revision 433596)
+++ sound/make/patternset.txt (working copy)
@@ -13,3 +13,5 @@
# limitations under the License.
javax/sound/midi/*
+
+org/apache/harmony/sound/internal/nls/*
Index: sound/build.xml
===================================================================
--- sound/build.xml (revision 433596)
+++ sound/build.xml (working copy)
@@ -32,10 +32,10 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -66,6 +66,15 @@
+
+
+
+
+
+
+
+
+
@@ -131,7 +140,7 @@
unless="test.case">
-
+
Index: math/src/main/java/org/apache/harmony/math/internal/nls/messages.properties
===================================================================
--- math/src/main/java/org/apache/harmony/math/internal/nls/messages.properties (revision 0)
+++ math/src/main/java/org/apache/harmony/math/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: math/src/main/java/org/apache/harmony/math/internal/nls/Messages.java
===================================================================
--- math/src/main/java/org/apache/harmony/math/internal/nls/Messages.java (revision 0)
+++ math/src/main/java/org/apache/harmony/math/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.math.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.math.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.math.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: math/make/patternset.txt
===================================================================
--- math/make/patternset.txt (revision 433596)
+++ math/make/patternset.txt (working copy)
@@ -13,4 +13,6 @@
# limitations under the License.
java/math/*
-com/ibm/oti/util/math/*
\ No newline at end of file
+com/ibm/oti/util/math/*
+
+org/apache/harmony/math/internal/nls/*
Index: math/build.xml
===================================================================
--- math/build.xml (revision 433596)
+++ math/build.xml (working copy)
@@ -32,10 +32,10 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -66,6 +66,15 @@
+
+
+
+
+
+
+
+
+
Index: tools/src/main/java/org/apache/harmony/tools/internal/nls/messages.properties
===================================================================
--- tools/src/main/java/org/apache/harmony/tools/internal/nls/messages.properties (revision 0)
+++ tools/src/main/java/org/apache/harmony/tools/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: tools/src/main/java/org/apache/harmony/tools/internal/nls/Messages.java
===================================================================
--- tools/src/main/java/org/apache/harmony/tools/internal/nls/Messages.java (revision 0)
+++ tools/src/main/java/org/apache/harmony/tools/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.tools.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.tools.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.tools.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: tools/build.xml
===================================================================
--- tools/build.xml (revision 433596)
+++ tools/build.xml (working copy)
@@ -17,13 +17,13 @@
-->
- Build for Tools component
+ Build for Tools component
-
-
+
+
-
-
+
+
@@ -31,88 +31,97 @@
-
-
+
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
-
+
+
+
-
-
+
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+ tools${line.separator}
-
+
-
-
+ tools${line.separator}
-
+
Index: auth/src/main/java/common/org/apache/harmony/auth/internal/nls/messages.properties
===================================================================
--- auth/src/main/java/common/org/apache/harmony/auth/internal/nls/messages.properties (revision 0)
+++ auth/src/main/java/common/org/apache/harmony/auth/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: auth/src/main/java/common/org/apache/harmony/auth/internal/nls/Messages.java
===================================================================
--- auth/src/main/java/common/org/apache/harmony/auth/internal/nls/Messages.java (revision 0)
+++ auth/src/main/java/common/org/apache/harmony/auth/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.auth.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.auth.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.auth.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: auth/make/patternset.txt
===================================================================
--- auth/make/patternset.txt (revision 433596)
+++ auth/make/patternset.txt (working copy)
@@ -24,3 +24,5 @@
org/apache/harmony/auth/*
org/apache/harmony/auth/login/*
org/apache/harmony/auth/module/*
+
+org/apache/harmony/auth/internal/nls/*
Index: auth/build.xml
===================================================================
--- auth/build.xml (revision 433596)
+++ auth/build.xml (working copy)
@@ -33,7 +33,7 @@
+ use the Eclipse Java compiler. -->
@@ -44,25 +44,25 @@
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
@@ -96,6 +96,15 @@
+
+
+
+
+
+
+
+
+
@@ -111,7 +120,7 @@
-
Index: regex/src/main/java/org/apache/harmony/regex/internal/nls/messages.properties
===================================================================
--- regex/src/main/java/org/apache/harmony/regex/internal/nls/messages.properties (revision 0)
+++ regex/src/main/java/org/apache/harmony/regex/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: regex/src/main/java/org/apache/harmony/regex/internal/nls/Messages.java
===================================================================
--- regex/src/main/java/org/apache/harmony/regex/internal/nls/Messages.java (revision 0)
+++ regex/src/main/java/org/apache/harmony/regex/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.regex.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.regex.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.regex.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: regex/make/patternset.txt
===================================================================
--- regex/make/patternset.txt (revision 433596)
+++ regex/make/patternset.txt (working copy)
@@ -13,4 +13,6 @@
# limitations under the License.
java/util/regex/*
-com/ibm/regex/*
\ No newline at end of file
+com/ibm/regex/*
+
+org/apache/harmony/regex/internal/nls/*
Index: regex/build.xml
===================================================================
--- regex/build.xml (revision 433596)
+++ regex/build.xml (working copy)
@@ -32,10 +32,10 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -66,6 +66,15 @@
+
+
+
+
+
+
+
+
+
Index: prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties
===================================================================
--- prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties (revision 0)
+++ prefs/src/main/java/org/apache/harmony/prefs/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java
===================================================================
--- prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java (revision 0)
+++ prefs/src/main/java/org/apache/harmony/prefs/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.prefs.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.prefs.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.prefs.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: prefs/make/patternset.txt
===================================================================
--- prefs/make/patternset.txt (revision 433596)
+++ prefs/make/patternset.txt (working copy)
@@ -12,4 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-java/util/prefs/*
\ No newline at end of file
+java/util/prefs/*
+
+org/apache/harmony/prefs/internal/nls/*
Index: prefs/build.xml
===================================================================
--- prefs/build.xml (revision 433596)
+++ prefs/build.xml (working copy)
@@ -32,20 +32,20 @@
+ use the Eclipse Java compiler. -->
-
+
+ prefs, so we check if we are on a windows platform -->
-
+
-
-
+
+
@@ -60,9 +60,9 @@
+ prefs, so we check if we are on a windows platform -->
-
+
@@ -86,6 +86,15 @@
+
+
+
+
+
+
+
+
+
Index: crypto/src/main/java/org/apache/harmony/crypto/internal/nls/messages.properties
===================================================================
--- crypto/src/main/java/org/apache/harmony/crypto/internal/nls/messages.properties (revision 0)
+++ crypto/src/main/java/org/apache/harmony/crypto/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: crypto/src/main/java/org/apache/harmony/crypto/internal/nls/Messages.java
===================================================================
--- crypto/src/main/java/org/apache/harmony/crypto/internal/nls/Messages.java (revision 0)
+++ crypto/src/main/java/org/apache/harmony/crypto/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.crypto.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.crypto.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.crypto.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: crypto/make/patternset.txt
===================================================================
--- crypto/make/patternset.txt (revision 433596)
+++ crypto/make/patternset.txt (working copy)
@@ -16,5 +16,5 @@
javax/crypto/interfaces/*
javax/crypto/spec/*
-org/apache/harmony/crypto/internal/*
+org/apache/harmony/crypto/internal/**
org/apache/harmony/crypto/utils/*
Index: crypto/build.xml
===================================================================
--- crypto/build.xml (revision 433596)
+++ crypto/build.xml (working copy)
@@ -32,12 +32,12 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -68,6 +68,15 @@
+
+
+
+
+
+
+
+
+
@@ -170,7 +179,7 @@
-
+
Index: archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties
===================================================================
--- archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties (revision 0)
+++ archive/src/main/java/org/apache/harmony/archive/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java
===================================================================
--- archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java (revision 0)
+++ archive/src/main/java/org/apache/harmony/archive/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.archive.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.archive.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.archive.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: archive/make/patternset.txt
===================================================================
--- archive/make/patternset.txt (revision 433596)
+++ archive/make/patternset.txt (working copy)
@@ -16,3 +16,4 @@
java/util/zip/*
org/apache/harmony/archive/**
+
Index: archive/build.xml
===================================================================
--- archive/build.xml (revision 433596)
+++ archive/build.xml (working copy)
@@ -32,59 +32,59 @@
+ use the Eclipse Java compiler. -->
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
-
+
-
-
+
-
@@ -95,15 +95,15 @@
-
+
-
-
-
-
-
+
+
+
+
+
@@ -126,6 +126,15 @@
+
+
+
+
+
+
+
+
+
@@ -192,7 +201,7 @@
-
+
Index: nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/messages.properties
===================================================================
--- nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/messages.properties (revision 0)
+++ nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
\ No newline at end of file
Index: nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/Messages.java
===================================================================
--- nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/Messages.java (revision 0)
+++ nio_char/src/main/java/org/apache/harmony/niochar/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.niochar.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.niochar.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.niochar.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: nio_char/make/patternset.txt
===================================================================
--- nio_char/make/patternset.txt (revision 433596)
+++ nio_char/make/patternset.txt (working copy)
@@ -13,4 +13,6 @@
# limitations under the License.
java/nio/charset/*
-java/nio/charset/spi/*
\ No newline at end of file
+java/nio/charset/spi/*
+
+org/apache/harmony/niochar/internal/nls/*
Index: nio_char/build.xml
===================================================================
--- nio_char/build.xml (revision 433596)
+++ nio_char/build.xml (working copy)
@@ -32,10 +32,10 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -66,6 +66,15 @@
+
+
+
+
+
+
+
+
+
Index: jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties
===================================================================
--- jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties (revision 0)
+++ jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: jndi/src/main/java/org/apache/harmony/jndi/internal/nls/Messages.java
===================================================================
--- jndi/src/main/java/org/apache/harmony/jndi/internal/nls/Messages.java (revision 0)
+++ jndi/src/main/java/org/apache/harmony/jndi/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.jndi.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.jndi.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.jndi.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: jndi/build.xml
===================================================================
--- jndi/build.xml (revision 433596)
+++ jndi/build.xml (working copy)
@@ -32,10 +32,10 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -66,6 +66,15 @@
+
+
+
+
+
+
+
+
+
@@ -126,43 +135,43 @@
-
+
-
-
+
+
-
+
-
+
-
-
-
-
+ unless="test.case">
+
+
+
+
-
+
-
-
-
-
-
-
+ unless="test.case">
+
+
+
+
+
+
-
-
-
-
-
+ unless="test.case">
+
+
+
+
+
Index: nio/src/main/java/org/apache/harmony/nio/internal/nls/messages.properties
===================================================================
--- nio/src/main/java/org/apache/harmony/nio/internal/nls/messages.properties (revision 0)
+++ nio/src/main/java/org/apache/harmony/nio/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java
===================================================================
--- nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java (revision 0)
+++ nio/src/main/java/org/apache/harmony/nio/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.nio.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.nio.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.nio.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: nio/make/patternset.txt
===================================================================
--- nio/make/patternset.txt (revision 433596)
+++ nio/make/patternset.txt (working copy)
@@ -19,3 +19,4 @@
org/apache/harmony/nio/*
org/apache/harmony/nio/internal/*
+org/apache/harmony/nio/internal/nls/*
Index: nio/build.xml
===================================================================
--- nio/build.xml (revision 433596)
+++ nio/build.xml (working copy)
@@ -17,168 +17,177 @@
-->
- Build for NIO component
+ Build for NIO component
-
-
+
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
+
-
+
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
-
+
+
+
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
- nio${line.separator}
-
+
+ nio${line.separator}
+
-
- nio${line.separator}
-
+
+ nio${line.separator}
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
Index: logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties
===================================================================
--- logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties (revision 0)
+++ logging/src/main/java/org/apache/harmony/logging/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: logging/src/main/java/org/apache/harmony/logging/internal/nls/Messages.java
===================================================================
--- logging/src/main/java/org/apache/harmony/logging/internal/nls/Messages.java (revision 0)
+++ logging/src/main/java/org/apache/harmony/logging/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.logging.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.logging.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.logging.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: logging/make/patternset.txt
===================================================================
--- logging/make/patternset.txt (revision 433596)
+++ logging/make/patternset.txt (working copy)
@@ -12,4 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-java/util/logging/*
\ No newline at end of file
+java/util/logging/*
+
+org/apache/harmony/logging/internal/nls/*
Index: logging/build.xml
===================================================================
--- logging/build.xml (revision 433596)
+++ logging/build.xml (working copy)
@@ -32,10 +32,10 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -46,7 +46,7 @@
-
+
@@ -183,6 +183,16 @@
append="true">logging${line.separator}
+
+
+
+
+
+
+
+
+
+
Index: rmi/src/main/java/org/apache/harmony/rmi/internal/nls/messages.properties
===================================================================
--- rmi/src/main/java/org/apache/harmony/rmi/internal/nls/messages.properties (revision 0)
+++ rmi/src/main/java/org/apache/harmony/rmi/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: rmi/src/main/java/org/apache/harmony/rmi/internal/nls/Messages.java
===================================================================
--- rmi/src/main/java/org/apache/harmony/rmi/internal/nls/Messages.java (revision 0)
+++ rmi/src/main/java/org/apache/harmony/rmi/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.rmi.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.rmi.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.rmi.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: rmi/make/patternset.txt
===================================================================
--- rmi/make/patternset.txt (revision 433596)
+++ rmi/make/patternset.txt (working copy)
@@ -29,3 +29,5 @@
org/apache/harmony/rmi/transport/*
org/apache/harmony/rmi/transport/proxy/*
org/apache/harmony/rmi/transport/tcp/*
+
+org/apache/harmony/rmi/internal/nls/*
Index: rmi/build.xml
===================================================================
--- rmi/build.xml (revision 433596)
+++ rmi/build.xml (working copy)
@@ -32,12 +32,12 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -68,6 +68,15 @@
+
+
+
+
+
+
+
+
+
Index: beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties
===================================================================
--- beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties (revision 0)
+++ beans/src/main/java/org/apache/harmony/beans/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: beans/src/main/java/org/apache/harmony/beans/internal/nls/Messages.java
===================================================================
--- beans/src/main/java/org/apache/harmony/beans/internal/nls/Messages.java (revision 0)
+++ beans/src/main/java/org/apache/harmony/beans/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.beans.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.beans.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.beans.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: beans/build.xml
===================================================================
--- beans/build.xml (revision 433596)
+++ beans/build.xml (working copy)
@@ -32,12 +32,12 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -68,6 +68,15 @@
+
+
+
+
+
+
+
+
+
@@ -82,8 +91,8 @@
-
-
+
+
-
+
-
+
-
-
-
+
+
-
-
+
+
@@ -179,10 +188,10 @@
-
-
-
-
+
+
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.xnet.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.xnet.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: x-net/make/patternset.txt
===================================================================
--- x-net/make/patternset.txt (revision 433596)
+++ x-net/make/patternset.txt (working copy)
@@ -14,4 +14,6 @@
javax/net/*
javax/net/ssl/*
-org/apache/harmony/xnet/provider/jsse/*
\ No newline at end of file
+org/apache/harmony/xnet/provider/jsse/*
+
+org/apache/harmony/xnet/internal/nls/*
Index: x-net/build.xml
===================================================================
--- x-net/build.xml (revision 433596)
+++ x-net/build.xml (working copy)
@@ -32,12 +32,12 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -68,6 +68,15 @@
+
+
+
+
+
+
+
+
+
@@ -105,7 +114,7 @@
-
+
@@ -147,7 +156,7 @@
-
+
Index: awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
===================================================================
--- awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties (revision 0)
+++ awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: awt/src/main/java/common/org/apache/harmony/awt/internal/nls/Messages.java
===================================================================
--- awt/src/main/java/common/org/apache/harmony/awt/internal/nls/Messages.java (revision 0)
+++ awt/src/main/java/common/org/apache/harmony/awt/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.awt.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.awt.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.awt.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: awt/make/patternset.txt
===================================================================
--- awt/make/patternset.txt (revision 433596)
+++ awt/make/patternset.txt (working copy)
@@ -47,3 +47,5 @@
org/apache/harmony/awt/wtk/*
org/apache/harmony/awt/wtk/linux/*
org/apache/harmony/awt/wtk/windows/*
+
+org/apache/harmony/awt/internal/nls/*
Index: awt/build.xml
===================================================================
--- awt/build.xml (revision 433596)
+++ awt/build.xml (working copy)
@@ -43,7 +43,7 @@
-
+
@@ -78,6 +78,15 @@
+
+
+
+
+
+
+
+
+
Index: misc/src/main/java/org/apache/harmony/misc/internal/nls/messages.properties
===================================================================
--- misc/src/main/java/org/apache/harmony/misc/internal/nls/messages.properties (revision 0)
+++ misc/src/main/java/org/apache/harmony/misc/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: misc/src/main/java/org/apache/harmony/misc/internal/nls/Messages.java
===================================================================
--- misc/src/main/java/org/apache/harmony/misc/internal/nls/Messages.java (revision 0)
+++ misc/src/main/java/org/apache/harmony/misc/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.misc.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.misc.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.misc.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: misc/make/patternset.txt
===================================================================
--- misc/make/patternset.txt (revision 433596)
+++ misc/make/patternset.txt (working copy)
@@ -14,3 +14,5 @@
#
org/apache/harmony/misc/*
org/apache/harmony/misc/accessors/*
+
+org/apache/harmony/misc/internal/nls/*
Index: misc/build.xml
===================================================================
--- misc/build.xml (revision 433596)
+++ misc/build.xml (working copy)
@@ -32,10 +32,10 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -66,6 +66,15 @@
+
+
+
+
+
+
+
+
+
@@ -77,19 +86,19 @@
-
+
-
-
-
+
+
+
-
+
-
Index: sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java
===================================================================
--- sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java (revision 433596)
+++ sql/src/main/java/org/apache/harmony/sql/internal/nls/Messages.java (working copy)
@@ -1,4 +1,4 @@
-/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,30 +13,42 @@
* limitations under the License.
*/
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
package org.apache.harmony.sql.internal.nls;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-import org.apache.harmony.luni.util.MsgHelp;
+import org.apache.harmony.kernel.vm.VM;
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.sql.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
public class Messages {
// ResourceBundle holding the system messages.
static private ResourceBundle bundle = null;
- static {
- // Attempt to load the messages.
- try {
- bundle = MsgHelp.setLocale(
- Locale.getDefault(),
- "org.apache.harmony.sql.internal.nls.messages"); //$NON-NLS-1$
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
-
/**
* Retrieves a message which has no arguments.
*
@@ -127,6 +139,103 @@
}
}
- return MsgHelp.format(format, args);
+ return format(format, args);
}
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.sql.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
}
Index: sql/build.xml
===================================================================
--- sql/build.xml (revision 433596)
+++ sql/build.xml (working copy)
@@ -32,10 +32,10 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -46,7 +46,7 @@
-
+
-
-
+
+
-
+
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.luni.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.luni.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: luni/make/patternset.txt
===================================================================
--- luni/make/patternset.txt (revision 433596)
+++ luni/make/patternset.txt (working copy)
@@ -38,3 +38,5 @@
org/apache/harmony/luni/net/*
org/apache/harmony/luni/platform/*
org/apache/harmony/luni/util/*
+
+org/apache/harmony/luni/internal/nls/*
Index: luni/build.xml
===================================================================
--- luni/build.xml (revision 433596)
+++ luni/build.xml (working copy)
@@ -38,7 +38,7 @@
-
+
@@ -251,7 +251,7 @@
-
+
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.security.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.security.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: security/make/patternset.txt
===================================================================
--- security/make/patternset.txt (revision 433596)
+++ security/make/patternset.txt (working copy)
@@ -20,3 +20,4 @@
javax/security/cert/*
org/apache/harmony/security/**/*
+org/apache/harmony/security/internal/nls/*
Index: security/build.xml
===================================================================
--- security/build.xml (revision 433596)
+++ security/build.xml (working copy)
@@ -33,7 +33,7 @@
+ use the Eclipse Java compiler. -->
@@ -44,7 +44,7 @@
-
+
@@ -54,7 +54,7 @@
-
+
@@ -63,7 +63,7 @@
-
+
@@ -101,6 +101,15 @@
+
+
+
+
+
+
+
+
+
@@ -229,7 +238,7 @@
-
+
Index: instrument/src/main/java/org/apache/harmony/instrument/internal/nls/messages.properties
===================================================================
--- instrument/src/main/java/org/apache/harmony/instrument/internal/nls/messages.properties (revision 0)
+++ instrument/src/main/java/org/apache/harmony/instrument/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: instrument/src/main/java/org/apache/harmony/instrument/internal/nls/Messages.java
===================================================================
--- instrument/src/main/java/org/apache/harmony/instrument/internal/nls/Messages.java (revision 0)
+++ instrument/src/main/java/org/apache/harmony/instrument/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.instrument.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.instrument.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.instrument.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: instrument/make/patternset.txt
===================================================================
--- instrument/make/patternset.txt (revision 433596)
+++ instrument/make/patternset.txt (working copy)
@@ -15,4 +15,5 @@
java/lang/instrument/*
org/apache/harmony/instrument/internal/*
+org/apache/harmony/instrument/internal/nls/*
Index: instrument/build.xml
===================================================================
--- instrument/build.xml (revision 433596)
+++ instrument/build.xml (working copy)
@@ -32,40 +32,40 @@
+ use the Eclipse Java compiler. -->
-
-
+
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
+
-
+
@@ -95,6 +95,15 @@
+
+
+
+
+
+
+
+
+
Index: annotation/src/main/java/org/apache/harmony/annotation/internal/nls/messages.properties
===================================================================
--- annotation/src/main/java/org/apache/harmony/annotation/internal/nls/messages.properties (revision 0)
+++ annotation/src/main/java/org/apache/harmony/annotation/internal/nls/messages.properties (revision 0)
@@ -0,0 +1,16 @@
+# Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# messages for EN locale
Index: annotation/src/main/java/org/apache/harmony/annotation/internal/nls/Messages.java
===================================================================
--- annotation/src/main/java/org/apache/harmony/annotation/internal/nls/Messages.java (revision 0)
+++ annotation/src/main/java/org/apache/harmony/annotation/internal/nls/Messages.java (revision 0)
@@ -0,0 +1,241 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL.
+ * All changes made to this file manually will be overwritten
+ * if this tool runs again. Better make changes in the template file.
+ */
+
+package org.apache.harmony.annotation.internal.nls;
+
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.apache.harmony.kernel.vm.VM;
+
+/**
+ * This class retrieves strings from a resource bundle and returns them,
+ * formatting them with MessageFormat when required.
+ *
+ * It is used by the system classes to provide national language support, by
+ * looking up messages in the
+ * org.apache.harmony.annotation.internal.nls.messages
+ *
+ * resource bundle. Note that if this file is not available, or an invalid key
+ * is looked up, or resource bundle support is not available, the key itself
+ * will be returned as the associated message. This means that the KEY
+ * should a reasonable human-readable (english) string.
+ *
+ */
+public class Messages {
+
+ // ResourceBundle holding the system messages.
+ static private ResourceBundle bundle = null;
+
+ /**
+ * Retrieves a message which has no arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg) {
+ if (bundle == null)
+ return msg;
+ try {
+ return bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ return "Missing message: " + msg; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Retrieves a message which takes 1 argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * Object the object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg) {
+ return getString(msg, new Object[] { arg });
+ }
+
+ /**
+ * Retrieves a message which takes 1 integer argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * int the integer to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, int arg) {
+ return getString(msg, new Object[] { Integer.toString(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 1 character argument.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg
+ * char the character to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, char arg) {
+ return getString(msg, new Object[] { String.valueOf(arg) });
+ }
+
+ /**
+ * Retrieves a message which takes 2 arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param arg1
+ * Object an object to insert in the formatted output.
+ * @param arg2
+ * Object another object to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object arg1, Object arg2) {
+ return getString(msg, new Object[] { arg1, arg2 });
+ }
+
+ /**
+ * Retrieves a message which takes several arguments.
+ *
+ * @param msg
+ * String the key to look up.
+ * @param args
+ * Object[] the objects to insert in the formatted output.
+ * @return String the message for that key in the system message bundle.
+ */
+ static public String getString(String msg, Object[] args) {
+ String format = msg;
+
+ if (bundle != null) {
+ try {
+ format = bundle.getString(msg);
+ } catch (MissingResourceException e) {
+ }
+ }
+
+ return format(format, args);
+ }
+
+ /**
+ * Generates a formatted text string given a source string containing
+ * "argument markers" of the form "{argNum}" where each argNum must be in
+ * the range 0..9. The result is generated by inserting the toString of each
+ * argument into the position indicated in the string.
+ *
+ * To insert the "{" character into the output, use a single backslash
+ * character to escape it (i.e. "\{"). The "}" character does not need to be
+ * escaped.
+ *
+ * @param format
+ * String the format to use when printing.
+ * @param args
+ * Object[] the arguments to use.
+ * @return String the formatted message.
+ */
+ public static String format(String format, Object[] args) {
+ StringBuilder answer = new StringBuilder(format.length()
+ + (args.length * 20));
+ String[] argStrings = new String[args.length];
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i] == null)
+ argStrings[i] = ""; //$NON-NLS-1$
+ else
+ argStrings[i] = args[i].toString();
+ }
+ int lastI = 0;
+ for (int i = format.indexOf('{', 0); i >= 0; i = format.indexOf('{',
+ lastI)) {
+ if (i != 0 && format.charAt(i - 1) == '\\') {
+ // It's escaped, just print and loop.
+ if (i != 1)
+ answer.append(format.substring(lastI, i - 1));
+ answer.append('{');
+ lastI = i + 1;
+ } else {
+ // It's a format character.
+ if (i > format.length() - 3) {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, format.length()));
+ lastI = format.length();
+ } else {
+ int argnum = (byte) Character.digit(format.charAt(i + 1),
+ 10);
+ if (argnum < 0 || format.charAt(i + 2) != '}') {
+ // Bad format, just print and loop.
+ answer.append(format.substring(lastI, i + 1));
+ lastI = i + 1;
+ } else {
+ // Got a good one!
+ answer.append(format.substring(lastI, i));
+ if (argnum >= argStrings.length)
+ answer.append(""); //$NON-NLS-1$
+ else
+ answer.append(argStrings[argnum]);
+ lastI = i + 3;
+ }
+ }
+ }
+ }
+ if (lastI < format.length())
+ answer.append(format.substring(lastI, format.length()));
+ return answer.toString();
+ }
+
+ /**
+ * Changes the locale of the messages.
+ *
+ * @param locale
+ * Locale the locale to change to.
+ */
+ static public ResourceBundle setLocale(final Locale locale,
+ final String resource) {
+ try {
+ final ClassLoader loader = VM.bootCallerClassLoader();
+ return (ResourceBundle) AccessController
+ .doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ return ResourceBundle.getBundle(resource, locale,
+ loader != null ? loader : ClassLoader.getSystemClassLoader());
+ }
+ });
+ } catch (MissingResourceException e) {
+ }
+ return null;
+ }
+
+ static {
+ // Attempt to load the messages.
+ try {
+ bundle = setLocale(Locale.getDefault(),
+ "org.apache.harmony.annotation.internal.nls.messages"); //$NON-NLS-1$
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+ }
+}
Index: annotation/make/patternset.txt
===================================================================
--- annotation/make/patternset.txt (revision 433596)
+++ annotation/make/patternset.txt (working copy)
@@ -13,3 +13,5 @@
# limitations under the License.
java/lang/annotation/*
+
+org/apache/harmony/annotation/internal/nls/*
Index: annotation/build.xml
===================================================================
--- annotation/build.xml (revision 433596)
+++ annotation/build.xml (working copy)
@@ -32,10 +32,10 @@
+ use the Eclipse Java compiler. -->
-
+
@@ -66,6 +66,16 @@
+
+
+
+
+
+
+
+
+
+