Clover coverage report - Code Coverage for tapestry release 4.0-alpha-3
Coverage timestamp: Mon May 16 2005 09:05:49 EDT
file stats: LOC: 83   Methods: 6
NCLOC: 30   Classes: 1
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
StringPropertySelectionModel.java - 87.5% 83.3% 85.7%
coverage coverage
 1   
 // Copyright 2004, 2005 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.tapestry.form;
 16   
 
 17   
 /**
 18   
  *  Implementation of {@link IPropertySelectionModel} that allows one String from
 19   
  *  an array of Strings to be selected as the property.
 20   
  *
 21   
  *  <p>Uses a simple index number as the value (used to represent the selected String).
 22   
  *  This assumes that the possible values for the Strings will remain constant between
 23   
  *  request cycles.
 24   
  *
 25   
  *  @author Howard Lewis Ship
 26   
  * 
 27   
  **/
 28   
 
 29   
 public class StringPropertySelectionModel implements IPropertySelectionModel
 30   
 {
 31   
     private String[] options;
 32   
 
 33   
     /**
 34   
      * Standard constructor.
 35   
      *
 36   
      * The options are retained (not copied).
 37   
      **/
 38   
 
 39  1
     public StringPropertySelectionModel(String[] options)
 40   
     {
 41  1
         this.options = options;
 42   
     }
 43   
 
 44  1
     public int getOptionCount()
 45   
     {
 46  1
         return options.length;
 47   
     }
 48   
 
 49  0
     public Object getOption(int index)
 50   
     {
 51  0
         return options[index];
 52   
     }
 53   
 
 54   
     /**
 55   
      *  Labels match options.
 56   
      *
 57   
      **/
 58   
 
 59  3
     public String getLabel(int index)
 60   
     {
 61  3
         return options[index];
 62   
     }
 63   
 
 64   
     /**
 65   
      *  Values are indexes into the array of options.
 66   
      *
 67   
      **/
 68   
 
 69  3
     public String getValue(int index)
 70   
     {
 71  3
         return Integer.toString(index);
 72   
     }
 73   
 
 74  1
     public Object translateValue(String value)
 75   
     {
 76  1
         int index;
 77   
 
 78  1
         index = Integer.parseInt(value);
 79   
 
 80  1
         return options[index];
 81   
     }
 82   
 
 83   
 }