MATSIM
PersonArrivalEvent.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * AgentArrivalEvent.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;
28 
30 
31 public class PersonArrivalEvent extends Event implements HasPersonId, HasLinkId {
32 
33  public static final String EVENT_TYPE = "arrival";
34 
35  public static final String ATTRIBUTE_PERSON = "person";
36  public static final String ATTRIBUTE_LINK = "link";
37  public static final String ATTRIBUTE_LEGMODE = "legMode";
38 
39  private final Id<Person> personId;
40  private final Id<Link> linkId;
41  private final String legMode;
42 
43 
44  public PersonArrivalEvent(final double time, final Id<Person> agentId, final Id<Link> linkId, final String legMode) {
45  super(time);
46  this.linkId = linkId;
47  this.legMode = legMode;
48  this.personId = agentId;
49  }
50 
52  return this.personId;
53  }
54 
55  public Id<Link> getLinkId() {
56  return this.linkId;
57  }
58 
59  public String getLegMode() {
60  return this.legMode;
61  }
62 
63  public String getEventType() {
64  return EVENT_TYPE;
65  }
66 
67  @Override
68  public Map<String, String> getAttributes() {
69  Map<String, String> attr = super.getAttributes();
70  // linkId, personId handled by superclass
71  if (this.legMode != null) {
72  attr.put(ATTRIBUTE_LEGMODE, this.legMode);
73  }
74  return attr;
75  }
76 
77  @Override
78  public void writeAsXML(StringBuilder out) {
79  // Writes all common attributes
80  writeXMLStart(out);
81  if (this.legMode != null) {
82  writeEncodedAttributeKeyValue(out, ATTRIBUTE_LEGMODE, this.legMode);
83  }
84  writeXMLEnd(out);
85  }
86 }
final void writeXMLEnd(StringBuilder out)
Definition: Event.java:151
final void writeXMLStart(StringBuilder out)
Definition: Event.java:116
PersonArrivalEvent(final double time, final Id< Person > agentId, final Id< Link > linkId, final String legMode)
static StringBuilder writeEncodedAttributeKeyValue(StringBuilder out, String key, String value)
Definition: XmlUtils.java:117