org.onebusaway.gtfs.serialization.mappings
Class DefaultAgencyIdFieldMappingFactory

java.lang.Object
  extended by org.onebusaway.gtfs.serialization.mappings.DefaultAgencyIdFieldMappingFactory
All Implemented Interfaces:
FieldMappingFactory

public class DefaultAgencyIdFieldMappingFactory
extends java.lang.Object
implements FieldMappingFactory

A FieldMappingFactory implementation that produces a FieldMapping that is responsible for setting the AgencyAndId.setAgencyId(String) portion of an AgencyAndId identifier. The GTFS library makes use of AgencyAndId identifier for most ids for GTFS entities, so as to provide as simple namespace mechanism for loading multiple feeds from different agencies into the same data-store. Since agency ids only appear in a few places in a GTFS feed, if at all, we need some mechanism for setting the agencyId portion of ids for all appropriate entities in the system. This FieldMappingFactory and the FieldMapping it produces does the heavy lifting of setting those agencyId values in an appropriate way. By default, we use the agencyId returned by GtfsReaderContext.getDefaultAgencyId(). However, if you specify a property path expression to the DefaultAgencyIdFieldMappingFactory(String) constructor, we will evaluate that property path expression against the target entity instance to determine the agencyId. So, for example, to set the agencyId for Route.getId(), we specify a path of "agency.id", which will call Route.getAgency() and then Agency.getId() to set the agency id. See also the path "route.agency.id" for Trip.

Author:
bdferris
See Also:
GtfsEntitySchemaFactory

Constructor Summary
DefaultAgencyIdFieldMappingFactory()
           
DefaultAgencyIdFieldMappingFactory(java.lang.String agencyIdPath)
           
 
Method Summary
 FieldMapping createFieldMapping(EntitySchemaFactory schemaFactory, java.lang.Class<?> entityType, java.lang.String csvFieldName, java.lang.String objFieldName, java.lang.Class<?> objFieldType, boolean required)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultAgencyIdFieldMappingFactory

public DefaultAgencyIdFieldMappingFactory()

DefaultAgencyIdFieldMappingFactory

public DefaultAgencyIdFieldMappingFactory(java.lang.String agencyIdPath)
Method Detail

createFieldMapping

public FieldMapping createFieldMapping(EntitySchemaFactory schemaFactory,
                                       java.lang.Class<?> entityType,
                                       java.lang.String csvFieldName,
                                       java.lang.String objFieldName,
                                       java.lang.Class<?> objFieldType,
                                       boolean required)
Specified by:
createFieldMapping in interface FieldMappingFactory


Copyright © 2010 OneBusAway. All Rights Reserved.