View Javadoc

1   /*
2    * @(#)Scenario.java Aug 18, 2003
3    * 
4    * 
5    * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
6    * Delft, the Netherlands. All rights reserved.
7    * 
8    * See for project information <a href="http://www.simulation.tudelft.nl/">
9    * www.simulation.tudelft.nl </a>.
10   * 
11   * The source code and binary code of this software is proprietary information
12   * of Delft University of Technology.
13   */
14  package org.gscg.experiment.scenario;
15  
16  import java.io.Serializable;
17  import java.net.URL;
18  import java.util.Properties;
19  
20  import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
21  
22  /***
23   * The Scenario specifies the parameters for a simulation experiment <br>
24   * 
25   * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
26   * Delft, the Netherlands. All rights reserved.
27   * 
28   * See for project information <a href="http://www.simulation.tudelft.nl/">
29   * www.simulation.tudelft.nl </a>.
30   * 
31   * The source code and binary code of this software is proprietary information
32   * of Delft University of Technology.*
33   * 
34   * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
35   *         Jacobs </a>, <a
36   *         href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
37   *         Verbraeck </a>
38   * @version $Revision: 1.1 $ $Date: 2005/06/16 12:34:01 $
39   * @since 1.0.0
40   */
41  public class Scenario implements Serializable
42  {
43  	/*** the serial version uid */
44  	private static final long serialVersionUID = 11L;
45  
46  	/*** SCENARIO_NAME the name property */
47  	public static final String SCENARIO_NAME = "SCENARIO_NAME";
48  
49  	/*** SCENARIO_ANALYST the analyst name property */
50  	public static final String SCENARIO_ANALYST = "SCENARIO_ANALYST";
51  
52  	/*** actions represent the actions of this scenario */
53  	private Event[] actions = null;
54  
55  	/*** properties reflect the properties */
56  	private Properties properties = new Properties();
57  
58  	/*** simulator reflects the simulator */
59  	private SimulatorInterface simulator;
60  
61  	/*** the URL of the Scenario */
62  	private URL url = null;
63  
64  	/***
65  	 * constructs a new Scenario
66  	 */
67  	public Scenario()
68  	{
69  		super();
70  	}
71  
72  	/***
73  	 * sets the simulator
74  	 * 
75  	 * @param simulator the simulator
76  	 */
77  	public synchronized void setSimulator(final SimulatorInterface simulator)
78  	{
79  		this.simulator = simulator;
80  	}
81  
82  	/***
83  	 * returns the simulator
84  	 * 
85  	 * @return SimulatorInterface
86  	 */
87  	public SimulatorInterface getSimulator()
88  	{
89  		return this.simulator;
90  	}
91  
92  	/***
93  	 * returns the URL
94  	 * 
95  	 * @return URL
96  	 */
97  	public URL getUrl()
98  	{
99  		return this.url;
100 	}
101 
102 	/***
103 	 * returns a property
104 	 * 
105 	 * @param key properties are stored as key-value
106 	 * @return String the property
107 	 */
108 	public String getProperty(final String key)
109 	{
110 		return this.properties.getProperty(key);
111 	}
112 
113 	/***
114 	 * sets a property
115 	 * 
116 	 * @param key properties are stored in key-value pairs
117 	 * @param value properties are stored in key-value pairs
118 	 */
119 	public void setProperty(final String key, final String value)
120 	{
121 		this.properties.put(key, value);
122 	}
123 
124 	/***
125 	 * sets the actions
126 	 * 
127 	 * @param actions reflect the actions
128 	 */
129 	public void setActions(final Event[] actions)
130 	{
131 		this.actions = actions;
132 	}
133 
134 	/***
135 	 * sets the URL of the experiment
136 	 * 
137 	 * @param url the URL
138 	 * 
139 	 * @uml.property name="url"
140 	 */
141 	public void setUrl(final URL url)
142 	{
143 		this.url = url;
144 	}
145 
146 	/***
147 	 * @return Returns the actions.
148 	 */
149 	public Event[] getActions()
150 	{
151 		return this.actions;
152 	}
153 
154 	/***
155 	 * @see java.lang.Object#toString()
156 	 */
157 	public String toString()
158 	{
159 		String result = "Contents of scenario: ";
160 		for (int i = 0; i < this.actions.length; i++)
161 		{
162 			String action = this.actions[i].toString();
163 			result = result + "\n\nAction number " + (i + 1) + ": "
164 					+ action.toString();
165 		}
166 
167 		return result;
168 	}
169 }