View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.shared_orchestra.util;
20  
21  import java.text.MessageFormat;
22  
23  /**
24   * <p>Utility class for generating parameterized messages.</p>
25   * 
26   * This is a copy from commons-el MessageUtil class.
27   * 
28   * @version $Id$
29   */
30  
31  class _MessageUtil
32  {
33   
34      /**
35       * <p>Returns a formatted message based on the provided template and
36       * a single parameter.</p>
37       * @param pTemplate the base message
38       * @param pArg0 parameter
39       * @return Returns a formatted message based on the provided template and
40       * a single parameter.
41       */ 
42      public static String getMessageWithArgs(String pTemplate, Object pArg0) {
43          return MessageFormat.format(pTemplate, new Object[]{ "" + pArg0 });
44      }
45      
46      /**
47       * <p>Returns a formatted message based on the provided template and
48       * provided parameter.</p>
49       * @param pTemplate the base message
50       * @param pArg0 parameter 1
51       * @param pArg1 parameter 2
52       * @return Returns a formatted message based on the provided template and
53       * provided parameter
54       */ 
55      public static String getMessageWithArgs(String pTemplate, Object pArg0, Object pArg1) {
56          return MessageFormat.format(pTemplate, new Object[]{"" + pArg0, "" + pArg1 });
57      }
58      
59      /**
60       * <p>Returns a formatted message based on the provided template and
61       * provided parameter.</p>
62       * @param pTemplate the base message
63       * @param pArg0 parameter 1
64       * @param pArg1 parameter 2
65       * @param pArg2 parameter 3
66       * @return Returns a formatted message based on the provided template and
67       * provided parameter
68       */ 
69      public static String getMessageWithArgs(String pTemplate, Object pArg0, Object pArg1, Object pArg2) {
70          return MessageFormat.format(pTemplate, new Object[]{
71              "" + pArg0,
72              "" + pArg1,
73              "" + pArg2
74          });
75      }
76      
77      /**
78       * <p>Returns a formatted message based on the provided template and
79       * provided parameter.</p>
80       * @param pTemplate the base message
81       * @param pArg0 parameter 1
82       * @param pArg1 parameter 2
83       * @param pArg2 parameter 3
84       * @param pArg3 parameter 4
85       * @return Returns a formatted message based on the provided template and
86       * provided parameter
87       */
88      public static String getMessageWithArgs(String pTemplate, Object pArg0, Object pArg1, Object pArg2, Object pArg3) {
89          return MessageFormat.format(
90              pTemplate, new Object[]{
91                  "" + pArg0,
92                  "" + pArg1,
93                  "" + pArg2,
94                  "" + pArg3
95              });
96      }
97      
98      /**
99       * <p>Returns a formatted message based on the provided template and
100      * provided parameter.</p>
101      * @param pTemplate the base message
102      * @param pArg0 parameter 1
103      * @param pArg1 parameter 2
104      * @param pArg2 parameter 3
105      * @param pArg3 parameter 4
106      * @param pArg4 parameter 5
107      * @return Returns a formatted message based on the provided template and
108      * provided parameter
109      */
110     public static String getMessageWithArgs(String pTemplate, Object pArg0, Object pArg1, Object pArg2, Object pArg3, Object pArg4) {
111         return MessageFormat.format(
112             pTemplate, new Object[]{
113                 "" + pArg0,
114                 "" + pArg1,
115                 "" + pArg2,
116                 "" + pArg3,
117                 "" + pArg4
118             });
119     }
120     
121     /**
122      * <p>Returns a formatted message based on the provided template and
123      * provided parameter.</p>
124      * @param pTemplate the base message
125      * @param pArg0 parameter 1
126      * @param pArg1 parameter 2
127      * @param pArg2 parameter 3
128      * @param pArg3 parameter 4
129      * @param pArg4 parameter 5
130      * @param pArg5 parameter 6
131      * @return Returns a formatted message based on the provided template and
132      * provided parameter
133      */
134     public static String getMessageWithArgs(
135         String pTemplate, Object pArg0, Object pArg1, Object pArg2, Object pArg3,
136         Object pArg4, Object pArg5) {
137         return MessageFormat.format(
138             pTemplate, new Object[]{
139                 "" + pArg0,
140                 "" + pArg1,
141                 "" + pArg2,
142                 "" + pArg3,
143                 "" + pArg4,
144                 "" + pArg5
145             });
146     }  
147 }