1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17/* 18 * THE FILE HAS BEEN AUTOGENERATED BY MSGTOOL TOOL. 19 * All changes made to this file manually will be overwritten 20 * if this tool runs again. Better make changes in the template file. 21 */ 22 23// BEGIN android-note 24// Redundant code has been removed and is now called from MsgHelp. 25// END android-note 26 27package org.apache.harmony.annotation.internal.nls; 28 29 30import java.security.AccessController; 31import java.security.PrivilegedAction; 32import java.util.Locale; 33import java.util.MissingResourceException; 34import java.util.ResourceBundle; 35 36// BEGIN android-changed 37import org.apache.harmony.luni.util.MsgHelp; 38// END android-changed 39 40/** 41 * This class retrieves strings from a resource bundle and returns them, 42 * formatting them with MessageFormat when required. 43 * <p> 44 * It is used by the system classes to provide national language support, by 45 * looking up messages in the <code> 46 * org.apache.harmony.annotation.internal.nls.messages 47 * </code> 48 * resource bundle. Note that if this file is not available, or an invalid key 49 * is looked up, or resource bundle support is not available, the key itself 50 * will be returned as the associated message. This means that the <em>KEY</em> 51 * should a reasonable human-readable (english) string. 52 * 53 */ 54public class Messages { 55 56 // BEGIN android-changed 57 private static final String sResource = 58 "org.apache.harmony.annotation.internal.nls.messages"; 59 // END android-changed 60 61 /** 62 * Retrieves a message which has no arguments. 63 * 64 * @param msg 65 * String the key to look up. 66 * @return String the message for that key in the system message bundle. 67 */ 68 static public String getString(String msg) { 69 // BEGIN android-changed 70 return MsgHelp.getString(sResource, msg); 71 // END android-changed 72 } 73 74 /** 75 * Retrieves a message which takes 1 argument. 76 * 77 * @param msg 78 * String the key to look up. 79 * @param arg 80 * Object the object to insert in the formatted output. 81 * @return String the message for that key in the system message bundle. 82 */ 83 static public String getString(String msg, Object arg) { 84 return getString(msg, new Object[] { arg }); 85 } 86 87 /** 88 * Retrieves a message which takes 1 integer argument. 89 * 90 * @param msg 91 * String the key to look up. 92 * @param arg 93 * int the integer to insert in the formatted output. 94 * @return String the message for that key in the system message bundle. 95 */ 96 static public String getString(String msg, int arg) { 97 return getString(msg, new Object[] { Integer.toString(arg) }); 98 } 99 100 /** 101 * Retrieves a message which takes 1 character argument. 102 * 103 * @param msg 104 * String the key to look up. 105 * @param arg 106 * char the character to insert in the formatted output. 107 * @return String the message for that key in the system message bundle. 108 */ 109 static public String getString(String msg, char arg) { 110 return getString(msg, new Object[] { String.valueOf(arg) }); 111 } 112 113 /** 114 * Retrieves a message which takes 2 arguments. 115 * 116 * @param msg 117 * String the key to look up. 118 * @param arg1 119 * Object an object to insert in the formatted output. 120 * @param arg2 121 * Object another object to insert in the formatted output. 122 * @return String the message for that key in the system message bundle. 123 */ 124 static public String getString(String msg, Object arg1, Object arg2) { 125 return getString(msg, new Object[] { arg1, arg2 }); 126 } 127 128 /** 129 * Retrieves a message which takes several arguments. 130 * 131 * @param msg 132 * String the key to look up. 133 * @param args 134 * Object[] the objects to insert in the formatted output. 135 * @return String the message for that key in the system message bundle. 136 */ 137 static public String getString(String msg, Object[] args) { 138 // BEGIN android-changed 139 return MsgHelp.getString(sResource, msg, args); 140 // END android-changed 141 } 142 143 // BEGIN android-note 144 // Duplicate code was dropped in favor of using MsgHelp. 145 // END android-note 146} 147