KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > data > config > ConfigProperty


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.data.config;
11
12 import java.util.*;
13
14 /**
15  * Represents a property to be shown on the configuration screen.
16  *
17  * @author Siddhartha Azad
18  * @since 2.3
19  */

20 public class ConfigProperty {
21   /** String containing the CVS revision. Read out via reflection!*/
22   private final static String JavaDoc CVS_REVISION = "$Revision: 1.4 $";
23
24   // name of the property
25
private String JavaDoc m_name;
26
27   // widget to use to get the value of this property
28
private String JavaDoc m_widget;
29
30   // label with which to display this property
31
private String JavaDoc m_label;
32
33   // allowed values for this property (if applicable)
34
private List m_values;
35
36   /**
37    * Default Constructor for a ConfigProperty.
38    *
39    * @author Siddhartha Azad
40    * @since 2.3
41    */

42   public ConfigProperty() {
43     // defaults
44
m_name = "";
45     m_label = "";
46     m_widget = "JTextField";
47     m_values = Collections.synchronizedList(new ArrayList());
48   }
49
50   /**
51    * @return name associated with this property
52    *
53    * @author Siddhartha Azad
54    * @since 2.3
55    */

56   public String JavaDoc getName() {
57     return m_name;
58   }
59
60   /**
61    * Setter for the name of this property.
62    * @param a_name the name associated with this property. This name will be
63    * used as the key in the properties file for persisting
64    * configuration information
65    *
66    * @author Siddhartha Azad
67    * @since 2.3
68    */

69   public void setName(final String JavaDoc a_name) {
70     m_name = a_name;
71     // by default display label is same as the name
72
if (m_label.equals("")) {
73       m_label = a_name;
74     }
75   }
76
77
78   /**
79    * @return name of the widget associated with this property
80    *
81    * @author Siddhartha Azad
82    * @since 2.3
83    */

84   public String JavaDoc getWidget() {
85     return m_widget;
86   }
87
88   /**
89    * Sets the widget.
90    * @param a_widget either "JList" or "JTextField" for now
91    *
92    * @author Siddhartha Azad
93    * @since 2.3
94    */

95   public void setWidget(final String JavaDoc a_widget) {
96     m_widget = a_widget;
97   }
98
99   /**
100    * @return label of the property
101    *
102    * @author Siddhartha Azad
103    * @since 2.4
104    */

105   public String JavaDoc getLabel() {
106     return m_label;
107   }
108
109   /**
110    * Sets the label.
111    * @param a_label the label of this property, by default the same as the
112    * name of the property
113    *
114    * @author Siddhartha Azad
115    * @since 2.4
116    */

117   public void setLabel(final String JavaDoc a_label) {
118     m_label = a_label;
119   }
120
121   /**
122    * Add a value into the values ArrayList. These values are added in case the
123    * display component is a ListBox or ComboBox or something that can have
124    * multiple values.
125    * @param a_value the value to add
126    *
127    * @author Siddhartha Azad
128    * @since 2.3
129    */

130   public void addValue(final String JavaDoc a_value) {
131     m_values.add(a_value);
132   }
133
134   /**
135    * @return iterator on the values ArrayList for this property
136    *
137    * @author Siddhartha Azad
138    * @since 2.3
139    */

140   public Iterator getValuesIter() {
141     return m_values.iterator();
142   }
143 }
144
Popular Tags