001/* 002 * jDTAUS Core Messages 003 * Copyright (C) 2005 Christian Schulte 004 * <cs@schulte.it> 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License, or any later version. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 019 * 020 */ 021package org.jdtaus.core.messages; 022 023import java.io.File; 024import java.net.URL; 025import java.util.Locale; 026import org.jdtaus.core.container.ContainerFactory; 027import org.jdtaus.core.text.Message; 028 029/** 030 * {@code Message} stating how to report a bug. 031 * 032 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 033 * @version $JDTAUS: BugReportMessage.java 8794 2012-12-03 16:51:09Z schulte $ 034 */ 035public final class BugReportMessage extends Message 036{ 037 //--Contstants-------------------------------------------------------------- 038 039 /** Serial version UID for backwards compatibility with 1.0.x classes. */ 040 private static final long serialVersionUID = -6031830488657149254L; 041 042 //---------------------------------------------------------------Constants-- 043 //--Message----------------------------------------------------------------- 044 045 /** 046 * {@inheritDoc} 047 * 048 * @return Strings giving information for where to report bugs and where 049 * to find any data to attach to any bug reports. 050 * <ul> 051 * <li>[0]: the absolute path of the directory holding the application's 052 * logfiles.</li> 053 * <li>[1]: URL of the online bugtracking system.</li> 054 * <li>[2]: email address to alternatively send the bugreport to.</li> 055 * </ul> 056 */ 057 public Object[] getFormatArguments( final Locale locale ) 058 { 059 if ( this.trackerUrl != null && this.reportAddress != null ) 060 { 061 return new Object[] 062 { 063 this.logDirectory.getAbsolutePath(), 064 this.trackerUrl.toExternalForm(), 065 this.reportAddress 066 }; 067 } 068 else if ( this.trackerUrl != null ) 069 { 070 return new Object[] 071 { 072 this.logDirectory.getAbsolutePath(), 073 this.trackerUrl.toExternalForm() 074 }; 075 076 } 077 else if ( this.reportAddress != null ) 078 { 079 return new Object[] 080 { 081 this.logDirectory.getAbsolutePath(), 082 this.reportAddress 083 }; 084 085 } 086 else 087 { 088 return new Object[] 089 { 090 this.logDirectory.getAbsolutePath() 091 }; 092 093 } 094 } 095 096 /** 097 * {@inheritDoc} 098 * 099 * @return The corresponding text from the message's {@code ResourceBundle}: 100 * <blockquote><pre> 101 * Please report this at {1} or send 102 * an email to {2} including a copy of the logfiles located in directory 103 * {0}. 104 * </pre></blockquote> 105 */ 106 public String getText( final Locale locale ) 107 { 108 if ( this.trackerUrl != null && this.reportAddress != null ) 109 { 110 return this.getBugReportUrlAndEmailMessage( 111 locale, this.logDirectory.getAbsolutePath(), 112 this.trackerUrl.toExternalForm(), this.reportAddress ); 113 114 } 115 else if ( this.trackerUrl != null ) 116 { 117 return this.getBugReportUrlMessage( 118 locale, this.logDirectory.getAbsolutePath(), 119 this.trackerUrl.toExternalForm() ); 120 121 } 122 else if ( this.reportAddress != null ) 123 { 124 return this.getBugReportEmailMessage( 125 locale, this.logDirectory.getAbsolutePath(), 126 this.reportAddress ); 127 128 } 129 else 130 { 131 return this.getBugReportMessage( 132 locale, this.logDirectory.getAbsolutePath() ); 133 134 } 135 } 136 137 //-----------------------------------------------------------------Message-- 138 //--BugReportMessage-------------------------------------------------------- 139 140 /** 141 * Directory holding the application's log files. 142 * @serial 143 */ 144 private File logDirectory; 145 146 /** 147 * URL of the online bugtracking system. 148 * @serial 149 */ 150 private URL trackerUrl; 151 152 /** 153 * Mail address to send the bugreport to. 154 * @serial 155 */ 156 private String reportAddress; 157 158 /** 159 * Creates a new {@code BugReportMessage} taking the application's logfile 160 * directory, an URL to the application's online bugtracking system, and 161 * an email address where to send bugreports to alternatively. 162 * 163 * @param logDirectory the directory holding the application's logfiles. 164 * @param trackerUrl an URL to the application's online bugtracking system. 165 * @param reportAddress an email address to alternatively send bugreports 166 * to. 167 * 168 * @throws NullPointerException if either {@code logDirectory} is 169 * {@code null}. 170 * @throws IllegalArgumentException if {@code logDirectory} is not a 171 * directory. 172 */ 173 public BugReportMessage( final File logDirectory, final URL trackerUrl, 174 final String reportAddress ) 175 { 176 if ( logDirectory == null ) 177 { 178 throw new NullPointerException( "logDirectory" ); 179 } 180 if ( !logDirectory.isDirectory() ) 181 { 182 throw new IllegalArgumentException( logDirectory.getAbsolutePath() ); 183 } 184 185 this.logDirectory = logDirectory; 186 this.trackerUrl = trackerUrl; 187 this.reportAddress = reportAddress; 188 } 189 190 //--------------------------------------------------------BugReportMessage-- 191 //--Messages---------------------------------------------------------------- 192 193// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:jdtausMessages 194 // This section is managed by jdtaus-container-mojo. 195 196 /** 197 * Gets the text of message <code>bugReport</code>. 198 * <blockquote><pre>Bitte melden Sie dieses Problem. Fügen Sie Ihrem Fehlerbericht bitte eine Kopie der aktuellen Protokolldateien der Anwendung aus Verzeichnis {0} bei.</pre></blockquote> 199 * <blockquote><pre>Please report this including a copy of the logfiles located in directory {0}.</pre></blockquote> 200 * 201 * @param locale The locale of the message instance to return. 202 * @param logDirectory Directory holding the application's logfiles. 203 * 204 * @return Information about how to report a bug. 205 */ 206 private String getBugReportMessage( final Locale locale, 207 final java.lang.String logDirectory ) 208 { 209 return ContainerFactory.getContainer(). 210 getMessage( this, "bugReport", locale, 211 new Object[] 212 { 213 logDirectory 214 }); 215 216 } 217 218 /** 219 * Gets the text of message <code>bugReportUrl</code>. 220 * <blockquote><pre>Bitte melden Sie dieses Problem unter {1}. Fügen Sie Ihrem Fehlerbericht bitte eine Kopie der aktuellen Protokolldateien der Anwendung aus Verzeichnis {0} bei.</pre></blockquote> 221 * <blockquote><pre>Please report this at {1} including a copy of the logfiles located in directory {0}.</pre></blockquote> 222 * 223 * @param locale The locale of the message instance to return. 224 * @param logDirectory Directory holding the application's logfiles. 225 * @param trackerUrl URL to the application's online bugtracking system. 226 * 227 * @return Information about how to report a bug. 228 */ 229 private String getBugReportUrlMessage( final Locale locale, 230 final java.lang.String logDirectory, 231 final java.lang.String trackerUrl ) 232 { 233 return ContainerFactory.getContainer(). 234 getMessage( this, "bugReportUrl", locale, 235 new Object[] 236 { 237 logDirectory, 238 trackerUrl 239 }); 240 241 } 242 243 /** 244 * Gets the text of message <code>bugReportEmail</code>. 245 * <blockquote><pre>Bitte melden Sie dieses Problem per eMail an {1}. Fügen Sie Ihrem Fehlerbericht bitte eine Kopie der aktuellen Protokolldateien der Anwendung aus Verzeichnis {0} bei.</pre></blockquote> 246 * <blockquote><pre>Please report this by sending an email to {1} including a copy of the logfiles located in directory {0}.</pre></blockquote> 247 * 248 * @param locale The locale of the message instance to return. 249 * @param logDirectory Directory holding the application's logfiles. 250 * @param reportAddress Email address to send bugreports to. 251 * 252 * @return Information about how to report a bug. 253 */ 254 private String getBugReportEmailMessage( final Locale locale, 255 final java.lang.String logDirectory, 256 final java.lang.String reportAddress ) 257 { 258 return ContainerFactory.getContainer(). 259 getMessage( this, "bugReportEmail", locale, 260 new Object[] 261 { 262 logDirectory, 263 reportAddress 264 }); 265 266 } 267 268 /** 269 * Gets the text of message <code>bugReportUrlAndEmail</code>. 270 * <blockquote><pre>Bitte melden Sie dieses Problem entweder unter {1} oder per eMail an {2}. Fügen Sie Ihrem Fehlerbericht bitte eine Kopie der aktuellen Protokolldateien der Anwendung aus Verzeichnis {0} bei.</pre></blockquote> 271 * <blockquote><pre>Please report this at {1} or send an email to {2} including a copy of the logfiles located in directory {0}.</pre></blockquote> 272 * 273 * @param locale The locale of the message instance to return. 274 * @param logDirectory Directory holding the application's logfiles. 275 * @param trackerUrl URL to the application's online bugtracking system. 276 * @param reportAddress Email address to alternatively send bugreports to. 277 * 278 * @return Information about how to report a bug. 279 */ 280 private String getBugReportUrlAndEmailMessage( final Locale locale, 281 final java.lang.String logDirectory, 282 final java.lang.String trackerUrl, 283 final java.lang.String reportAddress ) 284 { 285 return ContainerFactory.getContainer(). 286 getMessage( this, "bugReportUrlAndEmail", locale, 287 new Object[] 288 { 289 logDirectory, 290 trackerUrl, 291 reportAddress 292 }); 293 294 } 295 296// </editor-fold>//GEN-END:jdtausMessages 297 298 //----------------------------------------------------------------Messages-- 299}