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 18/* 19 * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL. 20 * All changes made to this file manually will be overwritten 21 * if this tool runs again. Better make changes in the template file. 22 */ 23 24// BEGIN android-note 25// Redundant code has been removed and is now called from MsgHelp. 26// END android-note 27 28package org.apache.harmony.crypto.internal.nls; 29 30 31import java.security.AccessController; 32import java.security.PrivilegedAction; 33import java.util.Locale; 34import java.util.MissingResourceException; 35import java.util.ResourceBundle; 36 37// BEGIN android-changed 38import org.apache.harmony.luni.util.MsgHelp; 39// END android-changed 40 41/** 42 * This class retrieves strings from a resource bundle and returns them, 43 * formatting them with MessageFormat when required. 44 * <p> 45 * It is used by the system classes to provide national language support, by 46 * looking up messages in the <code> 47 * org.apache.harmony.crypto.internal.nls.messages 48 * </code> 49 * resource bundle. Note that if this file is not available, or an invalid key 50 * is looked up, or resource bundle support is not available, the key itself 51 * will be returned as the associated message. This means that the <em>KEY</em> 52 * should a reasonable human-readable (english) string. 53 * 54 */ 55public class Messages { 56 57 // BEGIN android-changed 58 private static final String sResource = 59 "org.apache.harmony.crypto.internal.nls.messages"; //$NON-NLS-1$ 60 // END android-changed 61 62 /** 63 * Retrieves a message which has no arguments. 64 * 65 * @param msg 66 * String the key to look up. 67 * @return String the message for that key in the system message bundle. 68 */ 69 static public String getString(String msg) { 70 // BEGIN android-changed 71 return MsgHelp.getString(sResource, msg); 72 // END android-changed 73 } 74 75 /** 76 * Retrieves a message which takes 1 argument. 77 * 78 * @param msg 79 * String the key to look up. 80 * @param arg 81 * Object the object to insert in the formatted output. 82 * @return String the message for that key in the system message bundle. 83 */ 84 static public String getString(String msg, Object arg) { 85 return getString(msg, new Object[] { arg }); 86 } 87 88 /** 89 * Retrieves a message which takes 1 integer argument. 90 * 91 * @param msg 92 * String the key to look up. 93 * @param arg 94 * int the integer to insert in the formatted output. 95 * @return String the message for that key in the system message bundle. 96 */ 97 static public String getString(String msg, int arg) { 98 return getString(msg, new Object[] { Integer.toString(arg) }); 99 } 100 101 /** 102 * Retrieves a message which takes 1 character argument. 103 * 104 * @param msg 105 * String the key to look up. 106 * @param arg 107 * char the character to insert in the formatted output. 108 * @return String the message for that key in the system message bundle. 109 */ 110 static public String getString(String msg, char arg) { 111 return getString(msg, new Object[] { String.valueOf(arg) }); 112 } 113 114 /** 115 * Retrieves a message which takes 2 arguments. 116 * 117 * @param msg 118 * String the key to look up. 119 * @param arg1 120 * Object an object to insert in the formatted output. 121 * @param arg2 122 * Object another object to insert in the formatted output. 123 * @return String the message for that key in the system message bundle. 124 */ 125 static public String getString(String msg, Object arg1, Object arg2) { 126 return getString(msg, new Object[] { arg1, arg2 }); 127 } 128 129 /** 130 * Retrieves a message which takes several arguments. 131 * 132 * @param msg 133 * String the key to look up. 134 * @param args 135 * Object[] the objects to insert in the formatted output. 136 * @return String the message for that key in the system message bundle. 137 */ 138 static public String getString(String msg, Object[] args) { 139 // BEGIN android-changed 140 return MsgHelp.getString(sResource, msg, args); 141 // END android-changed 142 } 143 144 // BEGIN android-note 145 // Duplicate code was dropped in favor of using MsgHelp. 146 // END android-note 147} 148