@Entity
public class Trip
extends java.lang.Object
implements org.hibernate.classic.Lifecycle, java.io.Serializable
Serializable since Hibernate requires such.
Implements Lifecycle so that can have the onLoad() callback be called when reading in data so that can intern() member strings. In order to do this the String members could not be declared as final since they are updated after the constructor is called.
Constructor and Description |
---|
Trip(int configRev,
GtfsTrip gtfsTrip,
java.lang.String properRouteId,
java.lang.String routeShortName,
TitleFormatter titleFormatter)
Constructs Trip object from GTFS data.
|
Trip(Trip tripFromStopTimes,
int frequenciesBasedStartTime)
Creates a copy of the Trip object but adjusts the startTime, endTime, and
scheduledTimesMap according to the frequenciesBasedStartTime.
|
Trip(Trip tripFromStopTimes,
int frequenciesBasedStartTime,
int frequenciesBasedEndTime)
Creates a copy of the Trip object but adjusts the startTime, endTime, and
scheduledTimesMap according to the frequenciesBasedStartTime.
|
Modifier and Type | Method and Description |
---|---|
void |
addScheduleTimes(java.util.List<ScheduleTime> newScheduledTimesList)
For adding ScheduleTimes for stops to a Trip.
|
static int |
deleteFromRev(org.hibernate.Session session,
int configRev)
Deletes rev from the Trips table
|
boolean |
equals(java.lang.Object obj)
Required by Hibernate
|
Block |
getBlock()
Returns the Block that the Trip is associated with.
|
java.lang.String |
getBlockId()
The block_id is an optional element in GTFS trips.txt file.
|
int |
getConfigRev() |
java.lang.String |
getDirectionId() |
java.lang.Integer |
getEndTime()
Returns arrival time of last stop of trip.
|
java.lang.String |
getHeadsign()
The trip_headsign value from the trips.txt file.
|
java.lang.String |
getId() |
int |
getIndexInBlock()
Returns the index of the trip in the block.
|
double |
getLength()
Returns length of the trip from the first terminal to the last.
|
int |
getNumberStopPaths()
Returns number of stop paths defined for this trip.
|
Route |
getRoute()
Returns the Route object for this trip.
|
java.lang.String |
getRouteId() |
java.lang.String |
getRouteName()
Returns route name.
|
java.lang.String |
getRouteShortName()
Returns the routeShortName.
|
ScheduleTime |
getScheduleTime(int stopPathIndex)
Returns the ScheduleTime object for the stopPathIndex.
|
java.util.List<ScheduleTime> |
getScheduleTimes() |
java.lang.String |
getServiceId() |
java.lang.String |
getShapeId() |
java.lang.String |
getShortName() |
java.lang.Integer |
getStartTime()
Returns departure time of first stop of trip.
|
StopPath |
getStopPath(int stopPathIndex)
Returns the StopPath for the stopPathIndex specified
|
StopPath |
getStopPath(java.lang.String stopId)
Returns the StopPath specified by the stopId.
|
java.util.List<StopPath> |
getStopPaths()
Returns the List of the stop paths for the trip pattern
|
TravelTimesForTrip |
getTravelTimes() |
TravelTimesForStopPath |
getTravelTimesForStopPath(int stopPathIndex)
Returns the travel time info for the path specified by the stopPathIndex.
|
static Trip |
getTrip(org.hibernate.Session session,
int configRev,
java.lang.String tripId)
Returns specified Trip object for the specified configRev and tripId.
|
static Trip |
getTripByShortName(org.hibernate.Session session,
int configRev,
java.lang.String tripShortName)
Returns specified Trip object for the specified configRev and
tripShortName.
|
TripPattern |
getTripPattern() |
static java.util.Map<java.lang.String,Trip> |
getTrips(org.hibernate.Session session,
int configRev)
Returns map of Trip objects for the specified configRev.
|
int |
hashCode()
Required by Hibernate
|
boolean |
isExactTimesHeadway() |
boolean |
isNoSchedule() |
boolean |
onDelete(org.hibernate.Session s)
Implemented due to Lifecycle interface being implemented.
|
void |
onLoad(org.hibernate.Session s,
java.io.Serializable id)
Callback due to implementing Lifecycle interface.
|
boolean |
onSave(org.hibernate.Session s)
Implemented due to Lifecycle interface being implemented.
|
boolean |
onUpdate(org.hibernate.Session s)
Implemented due to Lifecycle interface being implemented.
|
void |
setTravelTimes(TravelTimesForTrip travelTimes)
TravelTimesForTrip created after the Trip.
|
void |
setTripPattern(TripPattern tripPattern)
TripPattern is created after the Trip.
|
java.lang.String |
toLongString()
Similar to toString() but also includes full TripPattern and travelTimes
|
java.lang.String |
toShortString()
Similar to toString() but doesn't include scheduledTimesMap which
can be quite verbose since it often contains times for many stops.
|
java.lang.String |
toString() |
public Trip(int configRev, GtfsTrip gtfsTrip, java.lang.String properRouteId, java.lang.String routeShortName, TitleFormatter titleFormatter)
Does not set startTime nor endTime. Those are set separately using addScheduleTimes(). Also doesn't set travel times. Those are set separately using setTravelTimes().
configRev
- gtfsTrip
- The GTFS data describing the tripproperRouteId
- The routeId, but can actually be the ID of the parent route.routeShortName
- Needed to provide a route identifier that is consistent over
schedule changes.titleFormatter
- So can fix titles associated with trippublic Trip(Trip tripFromStopTimes, int frequenciesBasedStartTime)
tripFromStopTimes
- frequenciesBasedStartTime
- public Trip(Trip tripFromStopTimes, int frequenciesBasedStartTime, int frequenciesBasedEndTime)
tripFromStopTimes
- frequenciesBasedStartTime
- frequenciesBasedEndTime
- public void addScheduleTimes(java.util.List<ScheduleTime> newScheduledTimesList)
newScheduledTimesList
- java.lang.ArrayIndexOutOfBoundsException
- If not enough space allocated for serialized schedule times
in scheduledTimesMap columnpublic void setTripPattern(TripPattern tripPattern)
tripPattern
- public void setTravelTimes(TravelTimesForTrip travelTimes)
travelTimes
- public static java.util.Map<java.lang.String,Trip> getTrips(org.hibernate.Session session, int configRev) throws org.hibernate.HibernateException
session
- configRev
- org.hibernate.HibernateException
public static Trip getTrip(org.hibernate.Session session, int configRev, java.lang.String tripId) throws org.hibernate.HibernateException
session
- configRev
- tripId
- org.hibernate.HibernateException
public static Trip getTripByShortName(org.hibernate.Session session, int configRev, java.lang.String tripShortName) throws org.hibernate.HibernateException
session
- configRev
- tripShortName
- org.hibernate.HibernateException
public static int deleteFromRev(org.hibernate.Session session, int configRev) throws org.hibernate.HibernateException
session
- configRev
- org.hibernate.HibernateException
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toLongString()
public java.lang.String toShortString()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public java.lang.Integer getStartTime()
public java.lang.Integer getEndTime()
public int getConfigRev()
public java.lang.String getId()
public java.lang.String getShortName()
public java.lang.String getRouteId()
public java.lang.String getRouteShortName()
public Route getRoute()
public java.lang.String getRouteName()
public java.lang.String getDirectionId()
public boolean isNoSchedule()
public boolean isExactTimesHeadway()
public java.lang.String getServiceId()
public java.lang.String getHeadsign()
public java.lang.String getBlockId()
public Block getBlock()
public int getIndexInBlock()
public java.lang.String getShapeId()
public TripPattern getTripPattern()
public ScheduleTime getScheduleTime(int stopPathIndex)
stopPathIndex
- public java.util.List<ScheduleTime> getScheduleTimes()
public TravelTimesForTrip getTravelTimes()
public TravelTimesForStopPath getTravelTimesForStopPath(int stopPathIndex)
stopPathIndex
- public double getLength()
public java.util.List<StopPath> getStopPaths()
public StopPath getStopPath(int stopPathIndex)
stopPathIndex
- public StopPath getStopPath(java.lang.String stopId)
stopId
- public int getNumberStopPaths()
public void onLoad(org.hibernate.Session s, java.io.Serializable id) throws org.hibernate.CallbackException
onLoad
in interface org.hibernate.classic.Lifecycle
org.hibernate.CallbackException
public boolean onSave(org.hibernate.Session s) throws org.hibernate.CallbackException
onSave
in interface org.hibernate.classic.Lifecycle
org.hibernate.CallbackException
public boolean onUpdate(org.hibernate.Session s) throws org.hibernate.CallbackException
onUpdate
in interface org.hibernate.classic.Lifecycle
org.hibernate.CallbackException
public boolean onDelete(org.hibernate.Session s) throws org.hibernate.CallbackException
onDelete
in interface org.hibernate.classic.Lifecycle
org.hibernate.CallbackException