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