MATSIM
ActivityEndEvent.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * ActEndEvent.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 
26 import org.matsim.api.core.v01.Coord;
27 import org.matsim.api.core.v01.Id;
31 
33 
34 public final class ActivityEndEvent extends Event implements HasPersonId, HasLinkId, HasFacilityId, BasicLocation {
35 
36  public static final String EVENT_TYPE = "actend";
37  public static final String ATTRIBUTE_ACTTYPE = "actType";
38 
39  private final Id<Person> personId;
40  private Coord coord;
41  private final Id<Link> linkId;
43  private final String acttype;
44 
48  @Deprecated // add Coord as argument
49  public ActivityEndEvent( final double time, final Id<Person> agentId, final Id<Link> linkId,
50  final Id<ActivityFacility> facilityId, final String acttype ){
51  this( time, agentId, linkId, facilityId, acttype, null);
52  }
53  // this is the new constructor:
54  public ActivityEndEvent(final double time, final Id<Person> agentId, final Id<Link> linkId,
55  final Id<ActivityFacility> facilityId, final String acttype, final Coord coord) {
56  super(time);
57  this.linkId = linkId;
58  this.facilityId = facilityId;
59  this.acttype = acttype == null ? "" : acttype;
60  this.personId = agentId;
61  this.coord = coord;
62  }
63 
64  @Override
65  public String getEventType() {
66  return EVENT_TYPE;
67  }
68 
69  public String getActType() {
70  return this.acttype;
71  }
72 
73  @Override public Id<Link> getLinkId() {
74  return this.linkId;
75  }
76 
77  @Override public Id<ActivityFacility> getFacilityId() {
78  return this.facilityId;
79  }
80 
81  @Override public Id<Person> getPersonId() {
82  return this.personId;
83  }
84 
85  @Override
86  public Map<String, String> getAttributes() {
87  Map<String, String> attr = super.getAttributes();
88  // person, link, facility done by superclass
89  attr.put(ATTRIBUTE_ACTTYPE, this.acttype);
90  return attr;
91  }
92 
93  @Override public Coord getCoord(){
94  return coord;
95  }
96  public void setCoord( Coord coord ) {
97  // yy this is to retrofit the coordinate into existing events that don't have it.
98  this.coord = coord;
99  }
100 
101  @Override
102  public void writeAsXML(StringBuilder out) {
103  // Writes common attributes
104  writeXMLStart(out);
105  writeEncodedAttributeKeyValue(out, ATTRIBUTE_ACTTYPE, this.acttype);
106  writeXMLEnd(out);
107  }
108 }
final void writeXMLEnd(StringBuilder out)
Definition: Event.java:151
ActivityEndEvent(final double time, final Id< Person > agentId, final Id< Link > linkId, final Id< ActivityFacility > facilityId, final String acttype, final Coord coord)
final void writeXMLStart(StringBuilder out)
Definition: Event.java:116
ActivityEndEvent(final double time, final Id< Person > agentId, final Id< Link > linkId, final Id< ActivityFacility > facilityId, final String acttype)
static StringBuilder writeEncodedAttributeKeyValue(StringBuilder out, String key, String value)
Definition: XmlUtils.java:117