Java Resource Message getMessageWithArgs(String pTemplate, Object pArg0)

Here you can find the source of getMessageWithArgs(String pTemplate, Object pArg0)

Description

Returns a formatted message based on the provided template and a single parameter.

License

CDDL license

Parameter

Parameter Description
pTemplate the base message
pArg0 parameter

Return

Returns a formatted message based on the provided template and a single parameter.

Declaration

public static String getMessageWithArgs(String pTemplate, Object pArg0) 

Method Source Code


//package com.java2s;
/*//from   ww  w. j  a  v  a  2s . co m
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 * 
 * You can obtain a copy of the License at
 * https://javaserverfaces.dev.java.net/CDDL.html or
 * legal/CDDLv1.0.txt. 
 * See the License for the specific language governing
 * permission and limitations under the License.
 * 
 * When distributing Covered Code, include this CDDL
 * Header Notice in each file and include the License file
 * at legal/CDDLv1.0.txt.    
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * your own identifying information:
 * "Portions Copyrighted [year] [name of copyright owner]"
 * 
 * [Name of File] [ver.__] [Date]
 * 
 * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
 */

import java.text.MessageFormat;

public class Main {
    /**
     * <p>Returns a formatted message based on the provided template and
     * a single parameter.</p>
     *
     * @param pTemplate the base message
     * @param pArg0     parameter
     * @return Returns a formatted message based on the provided template and
     *         a single parameter.
     */
    public static String getMessageWithArgs(String pTemplate, Object pArg0) {
        return MessageFormat.format(pTemplate, new Object[] { "" + pArg0 });
    }

    /**
     * <p>Returns a formatted message based on the provided template and
     * provided parameter.</p>
     *
     * @param pTemplate the base message
     * @param pArg0     parameter 1
     * @param pArg1     parameter 2
     * @return Returns a formatted message based on the provided template and
     *         provided parameter
     */
    public static String getMessageWithArgs(String pTemplate, Object pArg0, Object pArg1) {
        return MessageFormat.format(pTemplate, new Object[] { "" + pArg0, "" + pArg1 });
    }

    /**
     * <p>Returns a formatted message based on the provided template and
     * provided parameter.</p>
     *
     * @param pTemplate the base message
     * @param pArg0     parameter 1
     * @param pArg1     parameter 2
     * @param pArg2     parameter 3
     * @return Returns a formatted message based on the provided template and
     *         provided parameter
     */
    public static String getMessageWithArgs(String pTemplate, Object pArg0, Object pArg1, Object pArg2) {
        return MessageFormat.format(pTemplate, new Object[] { "" + pArg0, "" + pArg1, "" + pArg2 });
    }

    /**
     * <p>Returns a formatted message based on the provided template and
     * provided parameter.</p>
     *
     * @param pTemplate the base message
     * @param pArg0     parameter 1
     * @param pArg1     parameter 2
     * @param pArg2     parameter 3
     * @param pArg3     parameter 4
     * @return Returns a formatted message based on the provided template and
     *         provided parameter
     */
    public static String getMessageWithArgs(String pTemplate, Object pArg0, Object pArg1, Object pArg2,
            Object pArg3) {
        return MessageFormat.format(pTemplate, new Object[] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3 });
    }

    /**
     * <p>Returns a formatted message based on the provided template and
     * provided parameter.</p>
     *
     * @param pTemplate the base message
     * @param pArg0     parameter 1
     * @param pArg1     parameter 2
     * @param pArg2     parameter 3
     * @param pArg3     parameter 4
     * @param pArg4     parameter 5
     * @return Returns a formatted message based on the provided template and
     *         provided parameter
     */
    public static String getMessageWithArgs(String pTemplate, Object pArg0, Object pArg1, Object pArg2,
            Object pArg3, Object pArg4) {
        return MessageFormat.format(pTemplate,
                new Object[] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, "" + pArg4 });
    }

    /**
     * <p>Returns a formatted message based on the provided template and
     * provided parameter.</p>
     *
     * @param pTemplate the base message
     * @param pArg0     parameter 1
     * @param pArg1     parameter 2
     * @param pArg2     parameter 3
     * @param pArg3     parameter 4
     * @param pArg4     parameter 5
     * @param pArg5     parameter 6
     * @return Returns a formatted message based on the provided template and
     *         provided parameter
     */
    public static String getMessageWithArgs(String pTemplate, Object pArg0, Object pArg1, Object pArg2,
            Object pArg3, Object pArg4, Object pArg5) {
        return MessageFormat.format(pTemplate,
                new Object[] { "" + pArg0, "" + pArg1, "" + pArg2, "" + pArg3, "" + pArg4, "" + pArg5 });
    }
}

Related

  1. getMessageNoKey(String messageName)
  2. getMessages(final Class cls)
  3. getMessageString(String bundleName, String key, Object[] params, Locale locale)
  4. getMessageString(String key, Locale locale)
  5. getMessageString(String key, Locale locale)