diff options
Diffstat (limited to 'netx/net/sourceforge/jnlp/runtime')
5 files changed, 40 insertions, 12 deletions
diff --git a/netx/net/sourceforge/jnlp/runtime/Boot.java b/netx/net/sourceforge/jnlp/runtime/Boot.java index ea76bcb..195c55b 100644 --- a/netx/net/sourceforge/jnlp/runtime/Boot.java +++ b/netx/net/sourceforge/jnlp/runtime/Boot.java @@ -17,6 +17,8 @@ package net.sourceforge.jnlp.runtime; +import static net.sourceforge.jnlp.runtime.Translator.R; + import java.io.File; import java.io.IOException; import java.net.MalformedURLException; @@ -63,9 +65,6 @@ public final class Boot implements PrivilegedAction<Void> { // todo: decide whether a spawned netx (external launch) // should inherit the same options as this instance (store argv?) - private static String R(String key) { return JNLPRuntime.getMessage(key); } - private static String R(String key, Object param) { return JNLPRuntime.getMessage(key, new Object[] {param}); } - private static final String version = "0.5"; /** the text to display before launching the about link */ @@ -225,8 +224,7 @@ public final class Boot implements PrivilegedAction<Void> { if (JNLPRuntime.isDebug()) ex.printStackTrace(); - fatalError(JNLPRuntime.getMessage("RUnexpected", - new Object[] {ex.toString(), ex.getStackTrace()[0]} )); + fatalError(R("RUnexpected", ex.toString(), ex.getStackTrace()[0])); } return null; diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java index ebb9558..0960c1a 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java @@ -17,6 +17,8 @@ package net.sourceforge.jnlp.runtime; +import static net.sourceforge.jnlp.runtime.Translator.R; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -78,9 +80,6 @@ public class JNLPClassLoader extends URLClassLoader { // extension classes too so that main file classes can load // resources in an extension. - /** shortcut for resources */ - private static String R(String key) { return JNLPRuntime.getMessage(key); } - /** map from JNLPFile url to shared classloader */ private static Map<String,JNLPClassLoader> urlToLoader = new HashMap<String,JNLPClassLoader>(); // never garbage collected! diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java index a6f6304..31e6b06 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java @@ -522,7 +522,7 @@ public class JNLPRuntime { * * @param args the formatting arguments to the resource string */ - public static String getMessage(String key, Object args[]) { + public static String getMessage(String key, Object... args) { return MessageFormat.format(getMessage(key), args); } diff --git a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java index 5c49741..32a54f8 100644 --- a/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java +++ b/netx/net/sourceforge/jnlp/runtime/JNLPSecurityManager.java @@ -17,6 +17,8 @@ package net.sourceforge.jnlp.runtime; +import static net.sourceforge.jnlp.runtime.Translator.R; + import java.awt.Frame; import java.awt.Window; import java.awt.event.WindowAdapter; @@ -88,14 +90,12 @@ class JNLPSecurityManager extends AWTSecurityManager { // another way for different apps to have different properties // in java.lang.Sytem with the same names. - private static String R(String key) { return JNLPRuntime.getMessage(key); } - /** only class that can exit the JVM, if set */ private Object exitClass = null; /** this exception prevents exiting the JVM */ private SecurityException closeAppEx = // making here prevents huge stack traces - new SecurityException(JNLPRuntime.getMessage("RShutdown")); + new SecurityException(R("RShutdown")); /** weak list of windows created */ private WeakList<Window> weakWindows = new WeakList<Window>(); diff --git a/netx/net/sourceforge/jnlp/runtime/Translator.java b/netx/net/sourceforge/jnlp/runtime/Translator.java new file mode 100644 index 0000000..6e362b1 --- /dev/null +++ b/netx/net/sourceforge/jnlp/runtime/Translator.java @@ -0,0 +1,31 @@ +// Copyright (C) 2010 Red Hat, Inc. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +package net.sourceforge.jnlp.runtime; + +/** + * Utility class to provide simple methods to help localize messages + */ +public class Translator { + + /** + * @return the localized string for the message + */ + public static String R(String message, Object... params) { + return JNLPRuntime.getMessage(message, params); + } + +} |