KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > el > util > MessageFactory


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.el.util;
18
19 import java.text.MessageFormat JavaDoc;
20 import java.util.ResourceBundle JavaDoc;
21
22 /**
23  * @author Jacob Hookom [jacob@hookom.net]
24  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author: markt $
25  */

26 public final class MessageFactory {
27
28     protected final static ResourceBundle JavaDoc bundle = ResourceBundle
29             .getBundle("org.apache.el.Messages");
30     /**
31      *
32      */

33     public MessageFactory() {
34         super();
35     }
36     
37     public static String JavaDoc get(final String JavaDoc key) {
38         return bundle.getString(key);
39     }
40
41     public static String JavaDoc get(final String JavaDoc key, final Object JavaDoc obj0) {
42         return getArray(key, new Object JavaDoc[] { obj0 });
43     }
44
45     public static String JavaDoc get(final String JavaDoc key, final Object JavaDoc obj0,
46             final Object JavaDoc obj1) {
47         return getArray(key, new Object JavaDoc[] { obj0, obj1 });
48     }
49
50     public static String JavaDoc get(final String JavaDoc key, final Object JavaDoc obj0,
51             final Object JavaDoc obj1, final Object JavaDoc obj2) {
52         return getArray(key, new Object JavaDoc[] { obj0, obj1, obj2 });
53     }
54
55     public static String JavaDoc get(final String JavaDoc key, final Object JavaDoc obj0,
56             final Object JavaDoc obj1, final Object JavaDoc obj2, final Object JavaDoc obj3) {
57         return getArray(key, new Object JavaDoc[] { obj0, obj1, obj2, obj3 });
58     }
59
60     public static String JavaDoc get(final String JavaDoc key, final Object JavaDoc obj0,
61             final Object JavaDoc obj1, final Object JavaDoc obj2, final Object JavaDoc obj3,
62             final Object JavaDoc obj4) {
63         return getArray(key, new Object JavaDoc[] { obj0, obj1, obj2, obj3, obj4 });
64     }
65
66     public static String JavaDoc getArray(final String JavaDoc key, final Object JavaDoc[] objA) {
67         return MessageFormat.format(bundle.getString(key), objA);
68     }
69
70 }
71
Popular Tags