gt: 				if (!readCourses) {
context: /*
   * This file is part of Track It!.
   * Copyright (C) 2013 Henrique Malheiro
   * Copyright (C) 2015 Pedro Gomes
   * 
   * TrackIt! is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   * 
   * Track It! 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 General Public License for more details.
   * 
   * You should have received a copy of the GNU General Public License
   * along with Track It!. If not, see <http://www.gnu.org/licenses/>.
   * 
   */
  package com.trackit.business.reader.fit;
  
  import static com.trackit.business.common.Messages.getMessage;
  
  import java.util.Date;
  
  import org.apache.log4j.Logger;
  
  import com.garmin.fit.ActivityMesg;
  import com.garmin.fit.ActivityMesgListener;
  import com.garmin.fit.BatteryStatus;
  import com.garmin.fit.BikeProfileMesg;
  import com.garmin.fit.BikeProfileMesgListener;
  import com.garmin.fit.BloodPressureMesg;
  import com.garmin.fit.BloodPressureMesgListener;
  import com.garmin.fit.BufferedRecordMesg;
  import com.garmin.fit.BufferedRecordMesgListener;
  import com.garmin.fit.CapabilitiesMesg;
  import com.garmin.fit.CapabilitiesMesgListener;
  import com.garmin.fit.CourseMesg;
  import com.garmin.fit.CourseMesgListener;
  import com.garmin.fit.CoursePointMesg;
  import com.garmin.fit.CoursePointMesgListener;
  import com.garmin.fit.DateTime;
  import com.garmin.fit.DeviceInfoMesg;
  import com.garmin.fit.DeviceInfoMesgListener;
  import com.garmin.fit.DeviceSettingsMesg;
  import com.garmin.fit.DeviceSettingsMesgListener;
  import com.garmin.fit.DeviceType;
  import com.garmin.fit.DisplayMeasure;
  import com.garmin.fit.Event;
  import com.garmin.fit.EventMesg;
  import com.garmin.fit.EventMesgListener;
  import com.garmin.fit.FieldCapabilitiesMesg;
  import com.garmin.fit.FieldCapabilitiesMesgListener;
  import com.garmin.fit.File;
  import com.garmin.fit.FileCapabilitiesMesg;
  import com.garmin.fit.FileCapabilitiesMesgListener;
  import com.garmin.fit.FileCreatorMesg;
  import com.garmin.fit.FileCreatorMesgListener;
  import com.garmin.fit.FileIdMesg;
  import com.garmin.fit.FileIdMesgListener;
  import com.garmin.fit.Fit;
  import com.garmin.fit.GoalMesg;
  import com.garmin.fit.GoalMesgListener;
  import com.garmin.fit.HrZoneMesg;
  import com.garmin.fit.HrZoneMesgListener;
  import com.garmin.fit.HrmProfileMesg;
  import com.garmin.fit.HrmProfileMesgListener;
  import com.garmin.fit.HrvMesg;
  import com.garmin.fit.HrvMesgListener;
  import com.garmin.fit.Intensity;
  import com.garmin.fit.LapMesg;
  import com.garmin.fit.LapMesgListener;
  import com.garmin.fit.LapTrigger;
  import com.garmin.fit.LengthMesg;
  import com.garmin.fit.LengthMesgListener;
  import com.garmin.fit.LengthType;
  import com.garmin.fit.Manufacturer;
  import com.garmin.fit.Mesg;
  import com.garmin.fit.MesgCapabilitiesMesg;
  import com.garmin.fit.MesgCapabilitiesMesgListener;
  import com.garmin.fit.MesgListener;
  import com.garmin.fit.MesgWithEvent;
  import com.garmin.fit.MesgWithEventListener;
  import com.garmin.fit.MetZoneMesg;
  import com.garmin.fit.MetZoneMesgListener;
  import com.garmin.fit.MonitoringInfoMesg;
  import com.garmin.fit.MonitoringInfoMesgListener;
  import com.garmin.fit.MonitoringMesg;
  import com.garmin.fit.MonitoringMesgListener;
  import com.garmin.fit.PadMesg;
  import com.garmin.fit.PadMesgListener;
  import com.garmin.fit.PowerZoneMesg;
  import com.garmin.fit.PowerZoneMesgListener;
  import com.garmin.fit.RecordMesg;
  import com.garmin.fit.RecordMesgListener;
  import com.garmin.fit.ScheduleMesg;
  import com.garmin.fit.ScheduleMesgListener;
  import com.garmin.fit.SdmProfileMesg;
  import com.garmin.fit.SdmProfileMesgListener;
  import com.garmin.fit.SessionMesg;
  import com.garmin.fit.SessionMesgListener;
  import com.garmin.fit.SessionTrigger;
  import com.garmin.fit.SoftwareMesg;
  import com.garmin.fit.SoftwareMesgListener;
  import com.garmin.fit.Sport;
  import com.garmin.fit.SportMesg;
  import com.garmin.fit.SportMesgListener;
  import com.garmin.fit.SubSport;
  import com.garmin.fit.SwimStroke;
  import com.garmin.fit.TotalsMesg;
  import com.garmin.fit.TotalsMesgListener;
  import com.garmin.fit.UserProfileMesg;
  import com.garmin.fit.UserProfileMesgListener;
  import com.garmin.fit.WeightScaleMesg;
  import com.garmin.fit.WeightScaleMesgListener;
  import com.garmin.fit.WorkoutMesg;
  import com.garmin.fit.WorkoutMesgListener;
  import com.garmin.fit.WorkoutStepMesg;
  import com.garmin.fit.WorkoutStepMesgListener;
  import com.garmin.fit.ZonesTargetMesg;
  import com.garmin.fit.ZonesTargetMesgListener;
  import com.trackit.business.common.Constants;
  import com.trackit.business.domain.Activity;
  import com.trackit.business.domain.ActivityEvent;
  import com.trackit.business.domain.ActivityLap;
  import com.trackit.business.domain.ActivityTrack;
  import com.trackit.business.domain.ActivityType;
  import com.trackit.business.domain.BatteryStatusType;
  import com.trackit.business.domain.Course;
  import com.trackit.business.domain.CourseEvent;
  import com.trackit.business.domain.CourseLap;
  import com.trackit.business.domain.CoursePoint;
  import com.trackit.business.domain.CoursePointType;
  import com.trackit.business.domain.CourseTrack;
  import com.trackit.business.domain.DeviceInfo;
  import com.trackit.business.domain.DeviceTypeType;
  import com.trackit.business.domain.DisplayMeasureType;
  import com.trackit.business.domain.EventType;
  import com.trackit.business.domain.EventTypeType;
  import com.trackit.business.domain.FitnessEquipmentStateType;
  import com.trackit.business.domain.GPSDocument;
  import com.trackit.business.domain.GarminProductType;
  import com.trackit.business.domain.GenericProduct;
  import com.trackit.business.domain.IntensityType;
  import com.trackit.business.domain.Lap;
  import com.trackit.business.domain.LapTriggerType;
  import com.trackit.business.domain.Length;
  import com.trackit.business.domain.LengthTypeType;
  import com.trackit.business.domain.ManufacturerType;
  import com.trackit.business.domain.Session;
  import com.trackit.business.domain.SessionTriggerType;
  import com.trackit.business.domain.SportType;
  import com.trackit.business.domain.SubSportType;
  import com.trackit.business.domain.SwimStrokeType;
  import com.trackit.business.domain.TimerTriggerType;
  import com.trackit.business.domain.Track;
  import com.trackit.business.domain.Trackpoint;
  import com.trackit.business.utilities.Utilities;
  
  
  public class FITListener implements ActivityMesgListener, BikeProfileMesgListener, BloodPressureMesgListener,
  		BufferedRecordMesgListener, CapabilitiesMesgListener, CourseMesgListener, CoursePointMesgListener,
  		DeviceInfoMesgListener, DeviceSettingsMesgListener, EventMesgListener, FieldCapabilitiesMesgListener,
  		FileCapabilitiesMesgListener, FileCreatorMesgListener, FileIdMesgListener, GoalMesgListener,
  		HrZoneMesgListener, HrmProfileMesgListener, HrvMesgListener, LapMesgListener, LengthMesgListener,
  		MesgCapabilitiesMesgListener, MesgListener, MesgWithEventListener, MetZoneMesgListener,
  		MonitoringInfoMesgListener, MonitoringMesgListener, PadMesgListener, PowerZoneMesgListener,
  		RecordMesgListener, ScheduleMesgListener, SdmProfileMesgListener, SessionMesgListener,
  		SoftwareMesgListener, SportMesgListener, TotalsMesgListener, UserProfileMesgListener,
  		WeightScaleMesgListener, WorkoutMesgListener, WorkoutStepMesgListener, ZonesTargetMesgListener {
  	
  	private GPSDocument gpsDocument;
  	private Activity activity;
  	private Course course;
  	
  	private boolean isActivity;
  	private boolean isCourse;
  	
  	private boolean readActivities;
  	private boolean readCourses;
  	
  	private float accumulatedTimeDurationAlert = 0.0F;
  	private float accumulatedDistanceDurationAlert = 0.0F;
  	private long accumulatedCaloriesDurationAlert = 0L;
  	
  	Logger logger = Logger.getLogger(FITListener.class.getName());
  	
  	public FITListener(FITFileReader reader) {
  		super();
  		
  		readActivities = (Boolean) reader.getOptions().get(Constants.Reader.READ_ACTIVITIES);
  		readCourses = (Boolean) reader.getOptions().get(Constants.Reader.READ_COURSES);
  		
  		gpsDocument = new GPSDocument((String) reader.getOptions().get(Constants.Reader.FILENAME));
  	}
  	
  	public void onMesg(FileIdMesg mesg) {
  		logger.trace(getMessage("fitListener.processingMessage", mesg.getName()));
  		
  		if (mesg.getType() != null && mesg.getType() != File.INVALID) {
  			switch (mesg.getType()) {
  			case COURSE:
  