1   /*
2    *  SystemData.java
3    *
4    *  Copyright (c) 1998-2005, The University of Sheffield.
5    *
6    *  This file is part of GATE (see http://gate.ac.uk/), and is free
7    *  software, licenced under the GNU Library General Public License,
8    *  Version 2, June 1991 (in the distribution as file licence.html,
9    *  and also available at http://gate.ac.uk/gate/licence.html).
10   *
11   *  Hamish Cunningham, 9/Nov/2000
12   *
13   *  $Id: SystemData.java,v 1.7 2005/01/11 13:51:31 ian Exp $
14   */
15  
16  package gate.config;
17  
18  import java.util.*;
19  
20  import gate.Factory;
21  import gate.FeatureMap;
22  import gate.creole.ResourceInstantiationException;
23  import gate.util.GateSaxException;
24  import gate.util.Strings;
25  
26  
27  /** This class represents and instantiates systems during
28    * config data parsing.
29    */
30  class SystemData
31  {
32    /** Debug flag */
33    protected static final boolean DEBUG = false;
34  
35    /** Default constructor. */
36    SystemData() {
37    } // default constructor
38  
39    /** The list of PRs */
40    List prList = new ArrayList();
41  
42    /** The list of LRs */
43    List lrList = new ArrayList();
44  
45    /** The name of the SYSTEM */
46    String systemName = new String("name not set");
47  
48    /** The type name of the SYSTEM's controller */
49    String controllerTypeName = new String("controller type name not set");
50  
51    /** Create a Controller; called when all the system data
52      * is present.
53      */
54    void createSystem() throws GateSaxException
55    {
56      // create the controller
57      if(controllerTypeName.equalsIgnoreCase("none")){
58        //no controller required, bail
59        return;
60      }
61      try {
62        FeatureMap controllerParams = Factory.newFeatureMap();
63        Collection controller = (Collection)
64          Factory.createResource(controllerTypeName, controllerParams);
65        controller.addAll(prList);
66      } catch(ResourceInstantiationException e) {
67        throw new GateSaxException(
68          "Couldn't create controller for SYSTEM: " +
69          systemName + "; problem was: " + Strings.getNl() + e
70        );
71      }
72    } // createSystem()
73  
74  } // class SystemData
75