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