1 package net.logAnalyzer.analysis; 2 3 import java.util.Date; 4 5 /*** 6 * This class defines a template for log analyzers with a date key. A log 7 * analyzer analysis a messageLabel and generate an {@link LAAnalysis}. a period is 8 * used to normalize keys dates. 9 * 10 * @author Karim REFEYTON 11 * @version 0.1 12 */ 13 public abstract class LAPeriodicAnalyzer extends LAAnalyzer { 14 15 /*** 16 * Time period used to normalize the keys. 17 */ 18 private LATimePeriod period; 19 20 /*** 21 * Construct a new analyzer from an analyzer definition. 22 * 23 * @param definition 24 * Definition of the analyzer. 25 * @param period 26 * Time period. 27 */ 28 public LAPeriodicAnalyzer(AnalyzerDefinition definition, LATimePeriod period) { 29 super(definition, period.getDateFormat()); 30 this.period = period; 31 } 32 33 /*** 34 * Return the time period used to normalize the keys. 35 * 36 * @return Time period. 37 */ 38 public final LATimePeriod getPeriod() { 39 return this.period; 40 } 41 42 /*** 43 * Normalize a date using the period. 44 * 45 * @param date 46 * Date to normalize. 47 * @return Normalized date in date format. 48 */ 49 public final Date normalizeDate(Date date) { 50 return period.normalize(date); 51 } 52 53 /*** 54 * Normalize a date using the period.. 55 * 56 * @param date 57 * Date to normalize. 58 * @return Normalized date in string format. 59 */ 60 public final String normalizeToString(Date date) { 61 return period.normalizeToString(date); 62 } 63 }