1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.gscg.experiment.scenario;
15
16 import java.io.Serializable;
17 import java.text.DateFormat;
18 import java.util.Calendar;
19
20 /***
21 * An event of a scenario.
22 * <p>
23 * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
24 * Delft, the Netherlands. All rights reserved.
25 *
26 * See for project information <a href="http://www.simulation.tudelft.nl/">
27 * www.simulation.tudelft.nl </a>.
28 *
29 * The source code and binary code of this software is proprietary information
30 * of Delft University of Technology. *
31 *
32 * @author <a
33 * href="http://www.tbm.tudelft.nl/webstaf/stijnh/index.htm">Stijn-Pieter
34 * van Houten </a>
35 * @version $Revision: 1.1 $ $Date: 2005/06/16 12:34:01 $
36 * @since 1.0.0
37 */
38 public class Event implements Serializable
39 {
40 /*** the serial version uid */
41 private static final long serialVersionUID = 12L;
42
43 /*** the start time */
44 private long startTime = 0L;
45
46 /*** the target object */
47 private Object targetObject = null;
48
49 /*** the name of the method */
50 private String methodName = null;
51
52 /*** the arguments for the method */
53 private Object[] args = null;
54
55 /***
56 * constructs a new Event
57 *
58 * @param startTime the start time for the event
59 * @param targetObject the target object of the event
60 * @param methodName the name of the method to invoke
61 * @param args the arguments for the method to invoke
62 */
63 public Event(final Object targetObject, final long startTime,
64 final String methodName, final Object[] args)
65 {
66 super();
67
68
69 this.targetObject = targetObject;
70 this.startTime = startTime;
71 this.methodName = methodName;
72 this.args = args;
73 }
74
75 /***
76 * @return Returns the arguments.
77 */
78 public Object[] getArgs()
79 {
80 return this.args;
81 }
82
83 /***
84 * @return Returns the method name.
85 */
86 public String getMethodName()
87 {
88 return this.methodName;
89 }
90
91 /***
92 * @return Returns the start time.
93 */
94 public long getStartTime()
95 {
96 return this.startTime;
97 }
98
99 /***
100 * @return Returns the target object.
101 */
102 public Object getTargetObject()
103 {
104 return this.targetObject;
105 }
106
107 /***
108 * @see java.lang.Object#toString()
109 */
110 public String toString()
111 {
112 Calendar calendar = Calendar.getInstance();
113 calendar.setTimeInMillis(this.startTime);
114
115 String result = "startTime: "
116 + DateFormat.getDateInstance().format((calendar.getTime()))
117 + ", "
118 + DateFormat.getTimeInstance().format((calendar.getTime()))
119 + "\nObject: " + this.targetObject + "\nEvent: "
120 + this.methodName;
121 return result;
122 }
123 }