From 21a7d70d20ac45fbf2a8d000ba8e9f93be5dd195 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 10 Jan 2017 13:30:57 +0500 Subject: - Rename calendarData to data - Cleanup Calendar model - Fix TripsTest --- src/org/traccar/model/Calendar.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/org') diff --git a/src/org/traccar/model/Calendar.java b/src/org/traccar/model/Calendar.java index 19b5fde16..94f6bc2a3 100644 --- a/src/org/traccar/model/Calendar.java +++ b/src/org/traccar/model/Calendar.java @@ -18,7 +18,6 @@ package org.traccar.model; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.sql.SQLException; import java.util.Collection; import java.util.Date; @@ -29,12 +28,10 @@ import net.fortuna.ical4j.data.ParserException; import net.fortuna.ical4j.filter.Filter; import net.fortuna.ical4j.filter.PeriodRule; import net.fortuna.ical4j.filter.Rule; -import net.fortuna.ical4j.model.Component; import net.fortuna.ical4j.model.DateTime; import net.fortuna.ical4j.model.Dur; import net.fortuna.ical4j.model.Period; import net.fortuna.ical4j.model.component.CalendarComponent; -import net.fortuna.ical4j.validate.ValidationException; public class Calendar extends Extensible { @@ -48,16 +45,16 @@ public class Calendar extends Extensible { this.name = name; } - private byte[] calendarData; + private byte[] data; - public byte[] getCalendarData() throws ValidationException, IOException { - return calendarData.clone(); + public byte[] getData() { + return data.clone(); } - public void setCalendarData(byte[] calendarData) throws IOException, ParserException, SQLException { + public void setData(byte[] data) throws IOException, ParserException { CalendarBuilder builder = new CalendarBuilder(); - calendar = builder.build(new ByteArrayInputStream(calendarData)); - this.calendarData = calendarData.clone(); + calendar = builder.build(new ByteArrayInputStream(data)); + this.data = data.clone(); } private net.fortuna.ical4j.model.Calendar calendar; @@ -70,9 +67,9 @@ public class Calendar extends Extensible { public boolean checkMoment(Date date) { if (calendar != null) { Period period = new Period(new DateTime(date), new Dur(0, 0, 0, 0)); - Rule periodRule = new PeriodRule(period); - Filter filter = new Filter(new Rule[] {periodRule}, Filter.MATCH_ANY); - Collection events = filter.filter(calendar.getComponents(Component.VEVENT)); + Rule periodRule = new PeriodRule<>(period); + Filter filter = new Filter<>(new Rule[] {periodRule}, Filter.MATCH_ANY); + Collection events = filter.filter(calendar.getComponents(CalendarComponent.VEVENT)); if (events != null && !events.isEmpty()) { return true; } -- cgit v1.2.3