Coverage Report - javax.faces.component.UISelectBoolean
 
Classes in this File Line Coverage Branch Coverage Complexity
UISelectBoolean
100%
18/18
100%
6/6
1.714
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package javax.faces.component;
 17  
 
 18  
 import javax.faces.el.ValueBinding;
 19  
 
 20  
 /**
 21  
  * @author shot
 22  
  */
 23  
 public class UISelectBoolean extends UIInput {
 24  
 
 25  
     public static final String COMPONENT_TYPE = "javax.faces.SelectBoolean";
 26  
 
 27  
     public static final String COMPONENT_FAMILY = "javax.faces.SelectBoolean";
 28  
 
 29  
     private static final String DEFAULT_RENDERER_TYPE = "javax.faces.Checkbox";
 30  
 
 31  300
     public UISelectBoolean() {
 32  300
         setRendererType(DEFAULT_RENDERER_TYPE);
 33  300
     }
 34  
 
 35  
     public String getFamily() {
 36  26
         return COMPONENT_FAMILY;
 37  
     }
 38  
 
 39  
     public boolean isSelected() {
 40  8
         Boolean value = (Boolean) getValue();
 41  8
         if (value != null) {
 42  6
             return value.booleanValue();
 43  
         } else {
 44  2
             return false;
 45  
         }
 46  
     }
 47  
 
 48  
     public void setSelected(boolean selected) {
 49  6
         if (selected) {
 50  4
             setValue(Boolean.TRUE);
 51  
         } else {
 52  2
             setValue(Boolean.FALSE);
 53  
         }
 54  6
     }
 55  
 
 56  
     public ValueBinding getValueBinding(String name) {
 57  277
         return super.getValueBinding(convertAlias(name));
 58  
     }
 59  
 
 60  
     public void setValueBinding(String name, ValueBinding vb) {
 61  62
         super.setValueBinding(convertAlias(name), vb);
 62  56
     }
 63  
 
 64  
     private String convertAlias(String name) {
 65  339
         if ("selected".equals(name)) {
 66  10
             return "value";
 67  
         }
 68  329
         return name;
 69  
     }
 70  
 
 71  
 }