KickJava   Java API By Example, From Geeks To Geeks.

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


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 StringRecordPropertySelectionModel implements
11         IPropertySelectionModel {
12
13     private String JavaDoc[] optionValues;
14
15     private String JavaDoc[] optionLabels;
16
17     /**
18      * Standard constructor.
19      *
20      * The optionValues are retained (not copied).
21      */

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

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

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