<commit_before>/**
 *  Copyright 2014-2016 <NAME> (TheCoder4.Eu) and <NAME> (http://www.beyondjava.net).
 *  
 *  This file is part of BootsFaces.
 *  
 *  BootsFaces is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  BootsFaces is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with BootsFaces. If not, see <http://www.gnu.org/licenses/>.
 */
package net.bootsfaces.utils;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 * Simplified reporting of errors, warning or informations to the user of our
 * JSF application.
 * 
 * @author stephan
 *
 */
public class FacesMessages {
	/**
	 * Adds an FATAL message.
	 *
	 * @param message The message.
	 */
	public static void fatal(String detail) {
		info("", detail);
	}
	public static void fatal(String summary, String detail) {
		info(null, summary, detail);
	}
	public static void fatal(String refItem, String summary, String detail) {
		FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_FATAL, summary, detail);
		FacesContext context = FacesContext.getCurrentInstance();
		context.addMessage(refItem, facesMsg);
	}
	
	/**
	 * Adds a ERROR message.
	 *
	 * @param message The message.
	 */
	public static void error(String detail) {
		error("", detail);
	}
	public static void error(String summary, String detail) {
		error(null, summary, detail);
	}
	public static void error(String refItem, String summary, String detail) {
		FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, summary, detail);
		FacesContext context = FacesContext.getCurrentInstance();
		context.addMessage(refItem, facesMsg);
	}
	
	/**<commit_msg>corrected the severity of the new convenience methods<commit_after>/**
 *  Copyright 2014-2016 <NAME> (TheCoder4.Eu) and <NAME> (http://www.beyondjava.net).
 *  
 *  This file is part of BootsFaces.
 *  
 *  BootsFaces is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  BootsFaces is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with BootsFaces. If not, see <http://www.gnu.org/licenses/>.
 */
package net.bootsfaces.utils;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 * Simplified reporting of errors, warning or informations to the user of our
 * JSF application.
 * 
 * @author stephan
 *
 */
public class FacesMessages {
	/**
	 * Adds a FATAL message.
	 *
	 * @param message The message.
	 */
	public static void fatal(String detail) {
		fatal("", detail);
	}
	public static void fatal(String summary, String detail) {
		fatal(null, summary, detail);
	}
	public static void fatal(String refItem, String summary, String detail) {
		FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_FATAL, summary, detail);
		FacesContext context = FacesContext.getCurrentInstance();
		context.addMessage(refItem, facesMsg);
	}
	
	/**
	 * Adds a ERROR message.
	 *
	 * @param message The message.
	 */
	public static void error(String detail) {
		error("", detail);
	}
	public static void error(String summary, String detail) {
		error(null, summary, detail);
	}
	public static void error(String refItem, String summary, String detail) {
		FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, summary, detail);
		FacesContext context = FacesContext.getCurrentInstance();
		context.addMessage(refItem, facesMsg);
	}
	
	/**
{'fraction_non_alphanumeric': 0.09308820107051431, 'fraction_numerical': 0.004654410053525715, 'mean_word_length': 4.0093240093240095, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7482947', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1229, 'n_words': 463}