Simplify based on StringManager changes
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 18 Dec 2010 17:43:01 +0000 (17:43 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 18 Dec 2010 17:43:01 +0000 (17:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1050682 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/el/util/MessageFactory.java

index 8767cca..cecafc9 100644 (file)
@@ -25,11 +25,9 @@ import java.util.ResourceBundle;
  */
 public final class MessageFactory {
 
-    protected static final ResourceBundle bundle = ResourceBundle
-            .getBundle("org.apache.el.Messages");
-    /**
-     * 
-     */
+    protected static final ResourceBundle bundle =
+            ResourceBundle.getBundle("org.apache.el.Messages");
+
     public MessageFactory() {
         super();
     }
@@ -38,33 +36,13 @@ public final class MessageFactory {
         return bundle.getString(key);
     }
 
-    public static String get(final String key, final Object obj0) {
-        return getArray(key, new Object[] { obj0 });
-    }
-
-    public static String get(final String key, final Object obj0,
-            final Object obj1) {
-        return getArray(key, new Object[] { obj0, obj1 });
-    }
-
-    public static String get(final String key, final Object obj0,
-            final Object obj1, final Object obj2) {
-        return getArray(key, new Object[] { obj0, obj1, obj2 });
-    }
+    public static String get(final String key, final Object... args) {
+        String value = get(key);
+        if (value == null) {
+            value = key;
+        }
 
-    public static String get(final String key, final Object obj0,
-            final Object obj1, final Object obj2, final Object obj3) {
-        return getArray(key, new Object[] { obj0, obj1, obj2, obj3 });
+        MessageFormat mf = new MessageFormat(value);
+        return mf.format(args, new StringBuffer(), null).toString();
     }
-
-    public static String get(final String key, final Object obj0,
-            final Object obj1, final Object obj2, final Object obj3,
-            final Object obj4) {
-        return getArray(key, new Object[] { obj0, obj1, obj2, obj3, obj4 });
-    }
-
-    public static String getArray(final String key, final Object[] objA) {
-        return MessageFormat.format(bundle.getString(key), objA);
-    }
-
 }