1 /* 2 * The MIT License 3 * Copyright © 2004-2014 Fabrizio Giustina 4 * Copyright © 2022-2022 Web-Legacy 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 package net.sf.maventaglib; 25 26 import java.util.Locale; 27 28 import org.apache.maven.doxia.sink.Sink; 29 import org.apache.maven.reporting.AbstractMavenReportRenderer; 30 31 /** 32 * @author ste-gr 33 */ 34 public abstract class AbstractMavenTaglibReportRenderer extends AbstractMavenReportRenderer 35 { 36 37 /** 38 * The defined locale for the messages. 39 */ 40 private final Locale locale; 41 42 /** 43 * Class-Constructor 44 * 45 * @param sink the sink to use. 46 * @param locale the wanted locale to return the report's description, could be {@code null}. 47 */ 48 public AbstractMavenTaglibReportRenderer( Sink sink, Locale locale ) 49 { 50 super(sink); 51 this.locale = locale; 52 } 53 54 /** 55 * Gets a string for the given key from the resource bundle with the defined locale. 56 * If the locale is {@code null}, then the default-locale is used. 57 * 58 * @param key the key for the desired string 59 * 60 * @exception NullPointerException if {@code key} is {@code null} 61 * @exception ClassCastException if the object found for the given key is not a string 62 * 63 * @return the string for the given key with the defined locale 64 */ 65 protected String getMessageString( String key ) 66 { 67 return Messages.getString(locale, key); 68 } 69 }