/* 
 * Qlue Web Application Framework
 * Copyright 2009-2012 Ivan Ristic <ivanr@webkreator.com>
 *
 * 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.
 */
package com.webkreator.qlue;

import java.util.Formatter;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.PropertyResourceBundle;

/**
 * This class translates message codes into actual messages,
 * which can be sent to the user.
 */
public class MessageSource {

	protected PropertyResourceBundle resourceBundle;

	protected Locale locale;

	/**
	 * Create a message source instance associated with the given
	 * resource bundle and locale.
	 * 
	 * @param resourceBundle
	 * @param locale
	 */
	protected MessageSource(PropertyResourceBundle resourceBundle, Locale locale) {
		this.resourceBundle = resourceBundle;
		this.locale = locale;
	}

	/**
	 * Resolve a non-parameterized message code.
	 * 
	 * @param code
	 * @return
	 */
	public String get(String code) {
		try {
			return resourceBundle.getString(code);
		} catch (MissingResourceException mre) {
			return code;
		}
	}

	/**
	 * Resolve a message code using the given parameters.
	 * 
	 * @param code
	 * @param params
	 * @return
	 */
	public String get(String code, Object... params) {					
		StringBuffer sb = new StringBuffer();
		Formatter formatter = new Formatter(sb, locale);
		formatter.format(get(code), params);
		return sb.toString();
	}
}

@@ -1170,66 +1170,14 @@
 e.%0D%0A
-%09 * %0D%0A%09 * @param resourceBundle%0D%0A%09 * @param locale%0D%0A
 %09 */%0D%0A
+
 %09pro
@@ -1383,44 +1383,8 @@
 e.%0D%0A
-%09 * %0D%0A%09 * @param code%0D%0A%09 * @return%0D%0A
 %09 */
@@ -1608,63 +1608,9 @@
 ers.
-%0D%0A%09 * %0D%0A%09 * @param code%0D%0A%09 * @param params%0D%0A%09 * @return
+k
 %0D%0A%09 

Tidy up.