View Javadoc

1   /*
2    * AI Soccer Project - network gaming environment for AI warriors.
3    * Copyright (C) 2001-2004  Marcin Werla, Pawel Widera
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License
7    * as published by the Free Software Foundation; either version 2
8    * of the License, or (at your option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, you can find it here:
17   * http://www.gnu.org/licenses/gpl.html
18   */
19  
20  package snifos.communication;
21  
22  import java.lang.reflect.Constructor;
23  
24  import java.util.Properties;
25  
26  
27  /***
28   * This class represents informations about communication module
29   * read from server configuration file.
30   * @version $Id: CommModuleInfo.java,v 1.2 2004/05/08 21:55:25 mwerla Exp $
31   */
32  public class CommModuleInfo {
33      private Properties properties = new Properties();
34      private Constructor constructor;
35  
36      /***
37       * Sets main communication module class name.
38       * @param className Class name to set.
39       * @see CommModule
40       * @throws SecurityException Thrown by the security manager to indicate
41       * a security violation during reflection use.
42       * @throws NoSuchMethodException Thrown when main class does not have
43       * default constructor (without parameters).
44       * @throws ClassNotFoundException Thrown when given class is not found in
45       * classpath.
46       */
47      public void setClassName(String className)
48          throws SecurityException, NoSuchMethodException, ClassNotFoundException {
49          constructor = Class.forName(className).getConstructor(new Class[0]);
50      }
51  
52      /***
53       * Sets single property of communication module configuration.
54       * @param name Property name.
55       * @param value Property value.
56       */
57      public void setProperty(String name, String value) {
58          properties.setProperty(name, value);
59      }
60  
61      /***
62       * Returns Properties describing communication module configuration.
63       * @return Properties describing communication module configuration.
64       */
65      public Properties getProperties() {
66          return properties;
67      }
68  
69      /***
70       * Returns constructor of main communication module class.
71       * @return Constructor of main communication module class.
72       */
73      public Constructor getConstructor() {
74          return constructor;
75      }
76  }