KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > gp > terminal > Argument


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.gp.terminal;
11
12 import org.jgap.gp.*;
13 import org.jgap.*;
14 import org.jgap.gp.impl.*;
15
16 /**
17  * An argument that will be used internally only by ADF's.
18  *
19  * @author Klaus Meffert
20  * @since 3.0
21  */

22 public class Argument
23     extends CommandGene {
24   /** String containing the CVS revision. Read out via reflection!*/
25   private static final String JavaDoc CVS_REVISION = "$Revision: 1.7 $";
26
27   private int m_index;
28
29   public Argument(final GPConfiguration a_conf, int a_index, Class JavaDoc type)
30       throws InvalidConfigurationException {
31     super(a_conf, 0, type);
32     m_index = a_index;
33   }
34
35   public String JavaDoc toString() {
36     return "Arg(" + m_index + ")";
37   }
38
39   /**
40    * @return textual name of this command
41    *
42    * @author Klaus Meffert
43    * @since 3.2
44    */

45   public String JavaDoc getName() {
46     return "ADF Argument";
47   }
48
49   public int execute_int(ProgramChromosome c, int n, Object JavaDoc[] args) {
50     return ( (Integer JavaDoc) args[m_index]).intValue();
51   }
52
53   public long execute_long(ProgramChromosome c, int n, Object JavaDoc[] args) {
54     return ( (Long JavaDoc) args[m_index]).longValue();
55   }
56
57   public float execute_float(ProgramChromosome c, int n, Object JavaDoc[] args) {
58     return ( (Float JavaDoc) args[m_index]).floatValue();
59   }
60
61   public double execute_double(ProgramChromosome c, int n, Object JavaDoc[] args) {
62     return ( (Double JavaDoc) args[m_index]).doubleValue();
63   }
64
65   public Object JavaDoc execute_object(ProgramChromosome c, int n, Object JavaDoc[] args) {
66     return args[m_index];
67   }
68
69   public Class JavaDoc getChildType(IGPProgram a_ind, int a_chromNum) {
70     return null;
71   }
72 }
73
Popular Tags