MATSIM
PersonDepartureEvent.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * AgentDepartureEvent.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2007, 2008 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 java.util.Map;
24 
25 import org.matsim.api.core.v01.Id;
29 
30 public class PersonDepartureEvent extends Event implements HasPersonId, HasLinkId {
31 
32  public static final String EVENT_TYPE = "departure";
33 
34  public static final String ATTRIBUTE_PERSON = "person";
35  public static final String ATTRIBUTE_LINK = "link";
36  public static final String ATTRIBUTE_LEGMODE = "legMode";
37  public static final String ATTRIBUTE_ROUTING_MODE = "computationalRoutingMode";
38 
39  private final Id<Person> personId;
40  private final Id<Link> linkId;
41  private final String legMode;
42  private final String routingMode;
43 
44  public PersonDepartureEvent(final double time, final Id<Person> agentId, final Id<Link> linkId, final String legMode, final String routingMode) {
45  super(time);
46  this.linkId = linkId;
47  this.legMode = legMode;
48  this.personId = agentId;
49  this.routingMode = routingMode;
50  }
51 
52  @Override
54  return this.personId;
55  }
56 
57  public Id<Link> getLinkId() {
58  return this.linkId;
59  }
60 
61  public String getLegMode() {
62  return this.legMode;
63  }
64 
65  public String getRoutingMode() {
66  return routingMode;
67  }
68 
69  @Override
70  public String getEventType() {
71  return EVENT_TYPE;
72  }
73 
74  @Override
75  public Map<String, String> getAttributes() {
76  Map<String, String> attr = super.getAttributes();
77  // linkId, personId handled by superclass
78  if (this.legMode != null) {
79  attr.put(ATTRIBUTE_LEGMODE, this.legMode);
80  }
81  if (this.routingMode != null) {
82  attr.put(ATTRIBUTE_ROUTING_MODE, this.routingMode);
83  }
84  return attr;
85  }
86 
87  @Override
88  public void writeAsXML(StringBuilder out) {
89  writeXMLStart(out);
90  if (this.legMode != null) {
91  XmlUtils.writeEncodedAttributeKeyValue(out, ATTRIBUTE_LEGMODE, this.legMode);
92  }
93  if (this.routingMode != null) {
94  XmlUtils.writeEncodedAttributeKeyValue(out, ATTRIBUTE_ROUTING_MODE, this.routingMode);
95  }
96  writeXMLEnd(out);
97  }
98 }
final void writeXMLEnd(StringBuilder out)
Definition: Event.java:151
final void writeXMLStart(StringBuilder out)
Definition: Event.java:116
PersonDepartureEvent(final double time, final Id< Person > agentId, final Id< Link > linkId, final String legMode, final String routingMode)
static StringBuilder writeEncodedAttributeKeyValue(StringBuilder out, String key, String value)
Definition: XmlUtils.java:117