MATSIM
LinkEnterEvent.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * LinkEnterEvent.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2009 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 
21 package org.matsim.api.core.v01.events;
22 
23 import org.matsim.api.core.v01.Id;
26 import org.matsim.vehicles.Vehicle;
27 
28 import java.util.Map;
29 
30 public class LinkEnterEvent extends Event implements HasLinkId, HasVehicleId {
31 
32  public static final String EVENT_TYPE = "entered link";
33 
34  private final Id<Link> linkId;
35  private final Id<Vehicle> vehicleId;
36 
37  final static String missingVehicleIdMessage = "vehicleId=null in LinkEnter/LeaveEvent; this would cause problems downstream thus we are not accepting it";
38 
39  public LinkEnterEvent(final double time, final Id<Vehicle> vehicleId, final Id<Link> linkId) {
40  super(time);
41  this.linkId = linkId;
42  if ( vehicleId==null ) {
43  throw new RuntimeException( missingVehicleIdMessage ) ;
44  }
45  this.vehicleId = vehicleId;
46  }
47 
48  @Override
49  public String getEventType() {
50  return EVENT_TYPE;
51  }
52 
57  @Deprecated
59  throw new RuntimeException( LinkLeaveEvent.missingDriverIdMessage ) ;
60  }
61  @Override
62  public Id<Link> getLinkId() {
63  return this.linkId;
64  }
65 
67  return vehicleId;
68  }
69 
70  @Override
71  public Map<String, String> getAttributes() {
72  Map<String, String> atts = super.getAttributes();
73  // linkId, vehicleId handled by superclass
74  return atts;
75  }
76 
77  @Override
78  public void writeAsXML(StringBuilder out) {
79  // Writes all common attributes
80  writeXMLStart(out);
81  writeXMLEnd(out);
82  }
83 }
final void writeXMLEnd(StringBuilder out)
Definition: Event.java:151
final void writeXMLStart(StringBuilder out)
Definition: Event.java:116