Coverage Report - javax.faces.component.UISelectItem
 
Classes in this File Line Coverage Branch Coverage Complexity
UISelectItem
100%
54/54
100%
12/12
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.context.FacesContext;
 19  
 
 20  
 /**
 21  
  * @author shot
 22  
  */
 23  
 public class UISelectItem extends UIComponentBase {
 24  
 
 25  
     public static final String COMPONENT_FAMILY = "javax.faces.SelectItem";
 26  
 
 27  
     public static final String COMPONENT_TYPE = "javax.faces.SelectItem";
 28  
 
 29  
     private static final String ITEM_DESCRIPTION_BINDING_NAME = "itemDescription";
 30  
 
 31  
     private static final String ITEM_DISABLED_BINDING_NAME = "itemDisabled";
 32  
 
 33  
     private static final String ITEM_LABEL_BINDING_NAME = "itemLabel";
 34  
 
 35  
     private static final String ITEM_VALUE_BINDING_NAME = "itemValue";
 36  
 
 37  
     private static final String VALUE_BINDING_NAME = "value";
 38  
 
 39  243
     private String itemDescription = null;
 40  
 
 41  243
     private String itemLabel = null;
 42  
 
 43  243
     private Object itemValue = null;
 44  
 
 45  243
     private Object value = null;
 46  
 
 47  243
     private boolean itemDisabled = false;
 48  
 
 49  243
     private boolean itemDisabledSet = false;
 50  
 
 51  243
     public UISelectItem() {
 52  243
     }
 53  
 
 54  
     public String getFamily() {
 55  5
         return COMPONENT_FAMILY;
 56  
     }
 57  
 
 58  
     public String getItemDescription() {
 59  174
         if (itemDescription != null) {
 60  6
             return itemDescription;
 61  
         }
 62  168
         return (String) ComponentUtil_.getValueBindingValue(this,
 63  
                 ITEM_DESCRIPTION_BINDING_NAME);
 64  
     }
 65  
 
 66  
     public void setItemDescription(String itemDescription) {
 67  5
         this.itemDescription = itemDescription;
 68  5
     }
 69  
 
 70  
     public boolean isItemDisabled() {
 71  174
         if (itemDisabledSet) {
 72  27
             return itemDisabled;
 73  
         }
 74  147
         Object value = ComponentUtil_.getValueBindingValue(this,
 75  
                 ITEM_DISABLED_BINDING_NAME);
 76  147
         return (value != null) ? Boolean.TRUE.equals(value) : itemDisabled;
 77  
     }
 78  
 
 79  
     public void setItemDisabled(boolean itemDisabled) {
 80  20
         this.itemDisabled = itemDisabled;
 81  20
         itemDisabledSet = true;
 82  20
     }
 83  
 
 84  
     public String getItemLabel() {
 85  174
         if (itemLabel != null) {
 86  173
             return itemLabel;
 87  
         }
 88  1
         return (String) ComponentUtil_.getValueBindingValue(this,
 89  
                 ITEM_LABEL_BINDING_NAME);
 90  
     }
 91  
 
 92  
     public void setItemLabel(String itemLabel) {
 93  150
         this.itemLabel = itemLabel;
 94  150
     }
 95  
 
 96  
     public Object getItemValue() {
 97  172
         if (itemValue != null) {
 98  171
             return itemValue;
 99  
         }
 100  1
         return ComponentUtil_.getValueBindingValue(this,
 101  
                 ITEM_VALUE_BINDING_NAME);
 102  
     }
 103  
 
 104  
     public void setItemValue(Object itemValue) {
 105  150
         this.itemValue = itemValue;
 106  150
     }
 107  
 
 108  
     public Object getValue() {
 109  182
         if (value != null) {
 110  12
             return value;
 111  
         }
 112  170
         return ComponentUtil_.getValueBindingValue(this, VALUE_BINDING_NAME);
 113  
     }
 114  
 
 115  
     public void setValue(Object value) {
 116  9
         this.value = value;
 117  9
     }
 118  
 
 119  
     public void restoreState(FacesContext context, Object state) {
 120  3
         Object[] values = (Object[]) state;
 121  3
         super.restoreState(context, values[0]);
 122  3
         itemDescription = (String) values[1];
 123  3
         itemDisabled = ((Boolean) values[2]).booleanValue();
 124  3
         itemDisabledSet = ((Boolean) values[3]).booleanValue();
 125  3
         itemLabel = (String) values[4];
 126  3
         itemValue = values[5];
 127  3
         value = values[6];
 128  3
     }
 129  
 
 130  
     public Object saveState(FacesContext context) {
 131  4
         Object[] values = new Object[7];
 132  4
         values[0] = super.saveState(context);
 133  4
         values[1] = itemDescription;
 134  4
         values[2] = ComponentUtil_.convertToBoolean(itemDisabled);
 135  4
         values[3] = ComponentUtil_.convertToBoolean(itemDisabledSet);
 136  4
         values[4] = itemLabel;
 137  4
         values[5] = itemValue;
 138  4
         values[6] = value;
 139  4
         return values;
 140  
     }
 141  
 
 142  
 }