KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > adwt > editor > CollectionEditor


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.adwt.editor;
8
9 import java.util.Collection JavaDoc;
10 import java.util.Iterator JavaDoc;
11 import java.util.StringTokenizer JavaDoc;
12 import java.util.Vector JavaDoc;
13
14 /**
15  * Description of the Class
16  *
17  * @author Laurent Etiemble
18  * @version $Revision: 1.5 $
19  * @todo Javadoc to complete
20  * @todo Swing editor to complete
21  */

22 public class CollectionEditor extends GenericEditor
23 {
24    /** Constructor for the PropertiesEditor object */
25    public CollectionEditor()
26    {
27       this.value = new Vector JavaDoc();
28    }
29
30
31    /**
32     * Getter for the asText attribute
33     *
34     * @return The value of asText attribute
35     */

36    public String JavaDoc getAsText()
37    {
38       String JavaDoc result = "";
39       Iterator JavaDoc iterator = ((Collection JavaDoc) this.value).iterator();
40       while (iterator.hasNext())
41       {
42          result = result + iterator.next();
43          if (iterator.hasNext())
44          {
45             result = result + ",";
46          }
47       }
48       return result;
49    }
50
51
52    /**
53     * Setter for the asText attribute
54     *
55     * @param s The new value for asText attribute
56     */

57    public void setAsText(String JavaDoc s)
58    {
59       StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(s, ",");
60       this.value = new Vector JavaDoc();
61       while (st.hasMoreTokens())
62       {
63          ((Collection JavaDoc) this.value).add(st.nextToken());
64       }
65       this.firePropertyChange();
66    }
67
68 }
69
Popular Tags