KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > pets > PlainStringPropertySelectionModel


1 package org.apache.tapestry.pets;
2
3 import org.apache.tapestry.form.IPropertySelectionModel;
4
5 /**
6  * Implementation of {@link IPropertySelectionModel} that allows one String from
7  * an array of Strings to be selected as the property and where value=label
8  *
9  **/

10 public class PlainStringPropertySelectionModel implements IPropertySelectionModel
11 {
12     private String JavaDoc[] options;
13
14     /**
15     * Standard constructor.
16     *
17     * The optionValues are retained (not copied).
18     **/

19     public PlainStringPropertySelectionModel(String JavaDoc[] options)
20     {
21         this.options = options;
22     }
23
24     public int getOptionCount()
25     {
26         return options.length;
27     }
28
29     public Object JavaDoc getOption(int index)
30     {
31         return options[index];
32     }
33
34     /**
35     * Labels match optionValues.
36     *
37     **/

38     public String JavaDoc getLabel(int index)
39     {
40         return options[index];
41     }
42
43     /**
44     * Values are indexes into the array of optionValues.
45     *
46     **/

47     public String JavaDoc getValue(int index)
48     {
49         return options[index];
50     }
51
52     public Object JavaDoc translateValue(String JavaDoc value)
53     {
54         return value;
55     }
56 }
57
Popular Tags