org.onebusaway.gtfs.model.calendar.CalendarServiceData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of onebusaway-gtfs Show documentation
Show all versions of onebusaway-gtfs Show documentation
A Java library for reading and writing General Transit Feed Spec feeds
package org.onebusaway.gtfs.model.calendar;
import java.io.Serializable;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import org.onebusaway.gtfs.model.AgencyAndId;
public class CalendarServiceData implements Serializable {
private static final long serialVersionUID = 1L;
private Map _timeZonesByAgencyId = new HashMap();
private Map> _serviceDatesByServiceId = new HashMap>();
private Map> _datesByLocalizedServiceId = new HashMap>();
private Map> _serviceIdsByDate = new HashMap>();
public TimeZone getTimeZoneForAgencyId(String agencyId) {
return _timeZonesByAgencyId.get(agencyId);
}
public void putTimeZoneForAgencyId(String agencyId, TimeZone timeZone) {
_timeZonesByAgencyId.put(agencyId, timeZone);
}
public Set getServiceIds() {
return Collections.unmodifiableSet(_serviceDatesByServiceId.keySet());
}
public List getServiceDatesForServiceId(AgencyAndId serviceId) {
return _serviceDatesByServiceId.get(serviceId);
}
public Set getServiceIdsForDate(ServiceDate date) {
Set serviceIds = _serviceIdsByDate.get(date);
if (serviceIds == null)
serviceIds = new HashSet();
return serviceIds;
}
public void putServiceDatesForServiceId(AgencyAndId serviceId,
List serviceDates) {
Collections.sort(serviceDates);
_serviceDatesByServiceId.put(serviceId, serviceDates);
for (ServiceDate serviceDate : serviceDates) {
Set serviceIds = _serviceIdsByDate.get(serviceDate);
if (serviceIds == null) {
serviceIds = new HashSet();
_serviceIdsByDate.put(serviceDate, serviceIds);
}
serviceIds.add(serviceId);
}
}
public List getDatesForLocalizedServiceId(LocalizedServiceId serviceId) {
return _datesByLocalizedServiceId.get(serviceId);
}
public void putDatesForLocalizedServiceId(LocalizedServiceId serviceId,
List dates) {
_datesByLocalizedServiceId.put(serviceId, dates);
}
}