/*
* � Copyright IBM Corp. 2012
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
/* Generated by Workplace Designer localization tool */
package com.ibm.xsp.extlib.designer;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/** Resource handler class **/
public class DesignerResourceHandler {
private static ResourceBundle _resourceBundle;
private static ResourceBundle _loggingResourceBundle;
private static ResourceBundle _specialAudienceBundle;
private static ResourceBundle getResourceBundle(String bundle) {
try {
String bundlePackage = buildResourcePath(bundle); //NON-NLS-1
return ResourceBundle.getBundle( bundlePackage );
}
catch (MissingResourceException e) {
// does nothing - this method will return null and
// getString(String) will return the key
// it was called with
}
return null;
}
private static String buildResourcePath(String name) {
String clName = DesignerResourceHandler.class.getName();
return clName.substring( 0, clName.lastIndexOf('.') + 1 ) + name;
}
/**
* @param key
* @return
*/
public static String getString(String key) {
if (_resourceBundle == null) {
_resourceBundle = getResourceBundle("messages");//$NON-NLS-1$
}
return getResourceBundleString(_resourceBundle, key);
}
/**
* @param key
* @return
*/
public static String getLoggingString(String key) {
if (_loggingResourceBundle == null) {
_loggingResourceBundle = getResourceBundle("logging");//$NON-NLS-1$
}
return getResourceBundleString(_loggingResourceBundle, key);
}
/**
* @param key
* @return
*/
public static String getSpecialAudienceString(String key) {
if( _specialAudienceBundle == null ){
_specialAudienceBundle = getResourceBundle("specialAudience");//$NON-NLS-1$
}
return getResourceBundleString(_specialAudienceBundle, key);
}
/**
* @param bundle
* @param key
* @return
*/
private static String getResourceBundleString(ResourceBundle bundle, String key){
if (bundle != null) {
try {
return bundle.getString(key);
}
catch (MissingResourceException e) {
return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
else {
return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
}