|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| SimpleEnumPropertySelectionModel.java | - | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* Joey and its relative products are published under the terms
|
|
| 3 |
* of the Apache Software License.
|
|
| 4 |
*/
|
|
| 5 |
/*
|
|
| 6 |
* Created on 2004/01/13
|
|
| 7 |
*/
|
|
| 8 |
package org.asyrinx.brownie.tapestry.components.form;
|
|
| 9 |
|
|
| 10 |
import org.apache.commons.lang.enum.Enum;
|
|
| 11 |
import org.apache.tapestry.form.IPropertySelectionModel;
|
|
| 12 |
|
|
| 13 |
/**
|
|
| 14 |
* @author akima
|
|
| 15 |
*/
|
|
| 16 |
public class SimpleEnumPropertySelectionModel implements |
|
| 17 |
IPropertySelectionModel {
|
|
| 18 |
|
|
| 19 |
/**
|
|
| 20 |
*
|
|
| 21 |
*/
|
|
| 22 | 0 |
public SimpleEnumPropertySelectionModel(Enum[] enums) {
|
| 23 | 0 |
super();
|
| 24 | 0 |
this.enums = enums;
|
| 25 |
} |
|
| 26 |
|
|
| 27 |
private final Enum[] enums;
|
|
| 28 |
|
|
| 29 |
/**
|
|
| 30 |
* @see org.apache.tapestry.form.IPropertySelectionModel#getOptionCount()
|
|
| 31 |
*/
|
|
| 32 | 0 |
public int getOptionCount() { |
| 33 | 0 |
return enums.length;
|
| 34 |
} |
|
| 35 |
|
|
| 36 |
/**
|
|
| 37 |
* @see org.apache.tapestry.form.IPropertySelectionModel#getOption(int)
|
|
| 38 |
*/
|
|
| 39 | 0 |
public Object getOption(int index) { |
| 40 | 0 |
return enums[index];
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
/**
|
|
| 44 |
* @see org.apache.tapestry.form.IPropertySelectionModel#getLabel(int)
|
|
| 45 |
*/
|
|
| 46 | 0 |
public String getLabel(int index) { |
| 47 | 0 |
return enums[index].getName();
|
| 48 |
} |
|
| 49 |
|
|
| 50 |
/**
|
|
| 51 |
* @see org.apache.tapestry.form.IPropertySelectionModel#getValue(int)
|
|
| 52 |
*/
|
|
| 53 | 0 |
public String getValue(int index) { |
| 54 | 0 |
return Integer.toString(index);
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
/**
|
|
| 58 |
* @see org.apache.tapestry.form.IPropertySelectionModel#translateValue(java.lang.String)
|
|
| 59 |
*/
|
|
| 60 | 0 |
public Object translateValue(String value) {
|
| 61 | 0 |
int index = Integer.parseInt(value);
|
| 62 | 0 |
return enums[index];
|
| 63 |
} |
|
| 64 |
} |
|
||||||||||