/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/**
* Implementation of a local string manager. Provides access to i18n messages
* for classes that need them.
*
* <p> One StringManagerBase per resource bundle name can be created and accessed by the
* getManager method call.
*
* <xmp>
* Example:
*
* test=At {1,time} on {1,date}, there was {2} on planet {0,number,integer}
*
*
* StringManagerBase sm = StringManagerBase.getStringManager("LocalStrings.properties");
* .....
*
*
* try {
* ....
* } catch (Exception e) {
* String localizedMsg = sm.getString("test",
* new Integer(7), new java.util.Date(System.currentTimeMillis()),
* "a disturbance in the Force");
*
* throw new MyException(localizedMsg, e);
* }
*
* Localized message:
* At 2:27:41 PM on Jul 8, 2002, there was a disturbance in the Force
* on planet 7
*
* </xmp>
*
* @author Nazrul Islam
* @since JDK1.4
*/
public class StringManagerBase {
/** logger used for this class */
private static Logger _logger=LogDomains.getLogger(StringManagerBase.class, LogDomains.UTIL_LOGGER);
/** resource bundle to be used by this manager */
/** default value used for undefined local string */
/** cache for all the local string managers (per pkg) */
/**
* Initializes the resource bundle.
*
* @param resourceBundleName name of the resource bundle
*/
this._classLoader = classLoader;
}
/**
* Lazily load {@link ResourceBundle}.
*
* <p>
* {@link ResourceBundle} loading is expensive, and since we don't typically look at strings
* in start-up, doing this lazily improves overall performance.
*/
if(_resourceBundle==null) {
// worst case we just end up loading this twice. No big deal.
try {
} catch (Exception e) {
}
}
return _resourceBundle;
}
/**
* Returns a local string manager for the given resourceBundle name.
*
* @param resourceBundleName name of the resource bundle
*
* @return a local string manager for the given package name
*/
public synchronized static StringManagerBase getStringManager(String resourceBundleName, ClassLoader classLoader) {
try {
} catch (Exception e) {
}
}
return mgr;
}
/**
* Returns a localized string.
*
* @param key the name of the resource to fetch
*
* @return the localized string
*/
}
/**
* Returns a localized string. If the key is not found, it will
* return the default given value.
*
* @param key the name of the resource to fetch
* @param defaultValue the default return value if not found
*
* @return the localized string
*/
try {
} catch (Exception e) {
}
return value;
} else {
return defaultValue;
}
}
/**
* Returns a local string for the caller and format the arguments
* accordingly. If the key is not found, it will use the given
* default format.
*
* @param key the key to the local format string
* @param defaultFormat the default format if not found in the resources
* @param arguments the set of arguments to provide to the formatter
*
* @return a formatted localized string
*/
MessageFormat f =
arguments[i] = "null";
}
}
try {
} catch (Exception e) {
// returns default format
}
return fmtStr;
}
/**
* Returns a local string for the caller and format the arguments
* accordingly.
*
* @param key the key to the local format string
* @param arg1 the one argument to be provided to the formatter
*
* @return a formatted localized string
*/
}
/**
* Returns a local string for the caller and format the arguments
* accordingly.
*
* @param key the key to the local format string
* @param arg1 first argument to be provided to the formatter
* @param arg2 second argument to be provided to the formatter
*
* @return a formatted localized string
*/
}
/**
* Returns a local string for the caller and format the arguments
* accordingly.
*
* @param key the key to the local format string
* @param arg1 first argument to be provided to the formatter
* @param arg2 second argument to be provided to the formatter
* @param arg3 third argument to be provided to the formatter
*
* @return a formatted localized string
*/
}
/**
* Returns a local string for the caller and format the arguments
* accordingly.
*
* @param key the key to the local format string
* @param arg1 first argument to be provided to the formatter
* @param arg2 second argument to be provided to the formatter
* @param arg3 third argument to be provided to the formatter
* @param arg4 fourth argument to be provided to the formatter
*
* @return a formatted localized string
*/
}
/**
* Returns a local string for the caller and format the arguments
* accordingly.
*
* @param key the key to the local format string
* @param args the array of arguments to be provided to the formatter
*
* @return a formatted localized string
*/
}
}