All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.onebusaway.gtfs.model.calendar.CalendarServiceData Maven / Gradle / Ivy

There is a newer version: 1.3.4
Show newest version
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);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy