View Javadoc

1   /*
2    * @(#) ExperimentParsingThread.java Mar 2, 2004 Copyright (c) 2002-2005 Delft
3    * University of Technology Jaffalaan 5, 2628 BX Delft, the Netherlands. All
4    * rights reserved. This software is proprietary information of Delft University
5    * of Technology The code is published under the Lesser General Public License
6    */
7   package nl.tudelft.simulation.xml.dsol;
8   
9   import java.io.IOException;
10  import java.net.URL;
11  
12  import nl.tudelft.simulation.dsol.experiment.ExperimentalFrame;
13  import nl.tudelft.simulation.event.Event;
14  import nl.tudelft.simulation.event.EventListenerInterface;
15  import nl.tudelft.simulation.event.EventType;
16  import nl.tudelft.simulation.logger.Logger;
17  
18  /***
19   * A ExperimentParsingThread <br>
20   * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft
21   * University of Technology </a>, the Netherlands. <br>
22   * See for project information <a
23   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
24   * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
25   * General Public License (LGPL) </a>, no warranty.
26   * 
27   * @version 1.0 Mar 2, 2004 <br>
28   * @author <a href="http://www.peter-jacobs.com">Peter Jacobs </a>
29   */
30  public class ExperimentParsingThread extends Thread
31  {
32      /*** EXPERIMENT_PARSED_EVENT */
33      public static final EventType EXPERIMENT_PARSED_EVENT = new EventType(
34              "EXPERIMENT_PARSED_EVENT");
35  
36      /*** the owning listener */
37      protected EventListenerInterface source = null;
38  
39      /*** the experiment */
40      protected URL experiment = null;
41  
42      /***
43       * constructs a new ExperimentParsingThread
44       * 
45       * @param source the source of this thread
46       * @param experiment the experiment to parse
47       */
48      public ExperimentParsingThread(final EventListenerInterface source,
49              final URL experiment)
50      {
51          super("ExperimentParsingThread");
52          this.source = source;
53          this.experiment = experiment;
54      }
55  
56      /***
57       * @see java.lang.Runnable#run()
58       */
59      @Override
60      public void run()
61      {
62          try
63          {
64              ExperimentalFrame experimentalFrame = ExperimentParser
65                      .parseExperimentalFrame(this.experiment);
66              this.source.notify(new Event(EXPERIMENT_PARSED_EVENT, this,
67                      experimentalFrame));
68          } catch (IOException exception)
69          {
70              Logger.warning(this, "run", exception);
71          }
72      }
73  }