KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > event > GeneticEvent


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package org.jgap.event;
11
12 import java.util.EventObject JavaDoc;
13
14 /**
15  * Represents events that are fired via the EventManager when various
16  * genetic events occur. The specific kind of event is conveyed through the
17  * event name. Standard event names are provided as constants in this class.
18  *
19  * @author Neil Rotstan
20  * @author Klaus Meffert
21  * @since 1.0
22  */

23 public class GeneticEvent
24     extends EventObject JavaDoc {
25   /** String containing the CVS revision. Read out via reflection!*/
26   private final static String JavaDoc CVS_REVISION = "$Revision: 1.8 $";
27
28   /**
29    * Multi-purpose value object
30    */

31   private Object JavaDoc m_value;
32
33   /**
34    * Public constant representing the name of the event that is fired each
35    * time a Genotype is finished with a single evolution cycle.
36    */

37   public static final String JavaDoc GENOTYPE_EVOLVED_EVENT =
38       "genotype_evolved_event";
39
40   public static final String JavaDoc GPGENOTYPE_EVOLVED_EVENT =
41       "gpgenotype_evolved_event";
42
43   public static final String JavaDoc GPGENOTYPE_NEW_BEST_SOLUTION =
44       "gpgenotype_best_solution";
45
46   /**
47    * References the name of this event instance.
48    */

49   private final String JavaDoc m_eventName;
50
51   /**
52    * Constructs a new GeneticEvent of the given name.
53    *
54    * @param a_eventName the name of the event
55    * @param a_source the genetic object that acted as the source of the event.
56    * The type of this object will be dependent on the kind of event (which can
57    * be identified by the event name). It may not be null
58    *
59    * @throws IllegalArgumentException if the given source object is null
60    *
61    * @author Neil Rotstan
62    * @since 1.0
63    */

64   public GeneticEvent(final String JavaDoc a_eventName, final Object JavaDoc a_source) {
65     super(a_source);
66     m_eventName = a_eventName;
67   }
68
69   /**
70    * Constructs a new GeneticEvent of the given name.
71    *
72    * @param a_eventName the name of the event
73    * @param a_source the genetic object that acted as the source of the event.
74    * The type of this object will be dependent on the kind of event (which can
75    * be identified by the event name). It may not be null
76    * @param a_value informative value of the event
77    *
78    * @throws IllegalArgumentException if the given source object is null
79    *
80    * @author Neil Rotstan
81    * @since 1.0
82    */

83   public GeneticEvent(final String JavaDoc a_eventName, final Object JavaDoc a_source,
84                       final Object JavaDoc a_value) {
85     this(a_eventName, a_source);
86     m_value = a_value;
87   }
88
89   /**
90    * Retrieves the name of this event, which can be used to identify the
91    * type of event.
92    *
93    * @return the name of this GeneticEvent instance
94    *
95    * @author Neil Rotstan
96    * @since 1.0
97    */

98   public String JavaDoc getEventName() {
99     return m_eventName;
100   }
101
102   /**
103    * @return multi-purpose value of the event
104    *
105    * @author Klaus Meffert
106    * @since 3.0
107    */

108   public Object JavaDoc getValue() {
109     return m_value;
110   }
111 }
112
Popular Tags