12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
package net.sf.tapestry.form; /** * Implementation of {@link IPropertySelectionModel} that allows one String from * an array of Strings to be selected as the property. * * <p>Uses a simple index number as the value (used to represent the selected String). * This assumes that the possible values for the Strings will remain constant between * request cycles. * * @version $Id: StringPropertySelectionModel.java,v 1.5 2002/11/27 17:58:47 hship Exp $ * @author Howard Lewis Ship * **/ public class StringPropertySelectionModel implements IPropertySelectionModel { private String[] options; /** * Standard constructor. * * The options are retained (not copied). **/ public StringPropertySelectionModel(String[] options) { this.options = options; } public int getOptionCount() { return options.length; } public Object getOption(int index) { return options[index]; } /** * Labels match options. * **/ public String getLabel(int index) { return options[index]; } /** * Values are indexes into the array of options. * **/ public String getValue(int index) { return Integer.toString(index); } public Object translateValue(String value) { int index; index = Integer.parseInt(value); return options[index]; } }