Coverage Report - javax.faces.component.UIGraphic
 
Classes in this File Line Coverage Branch Coverage Complexity
UIGraphic
100%
31/31
83%
5/6
1.364
 
 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  
 import javax.faces.el.ValueBinding;
 20  
 
 21  
 /**
 22  
  * @author shot
 23  
  */
 24  
 public class UIGraphic extends UIComponentBase {
 25  
 
 26  
     public static final String COMPONENT_FAMILY = "javax.faces.Graphic";
 27  
 
 28  
     public static final String COMPONENT_TYPE = "javax.faces.Graphic";
 29  
 
 30  
     private static final String DEFAULT_RENDER_TYPE = "javax.faces.Image";
 31  
 
 32  
     private static final String VALUE_BINDING_NAME = "value";
 33  
 
 34  
     private static final String URL_BINDING_NAME = "url";
 35  
 
 36  225
     private Object value = null;
 37  
 
 38  225
     private boolean valueSet = false;
 39  
 
 40  225
     public UIGraphic() {
 41  225
         setRendererType(DEFAULT_RENDER_TYPE);
 42  225
     }
 43  
 
 44  
     public String getFamily() {
 45  24
         return COMPONENT_FAMILY;
 46  
     }
 47  
 
 48  
     public String getUrl() {
 49  17
         return (String) getValue();
 50  
     }
 51  
 
 52  
     public void setUrl(String url) {
 53  3
         setValue(url);
 54  3
     }
 55  
 
 56  
     public Object getValue() {
 57  26
         if (valueSet) {
 58  14
             return value;
 59  
         }
 60  12
         return ComponentUtil_.getValueBindingValue(this, VALUE_BINDING_NAME);
 61  
     }
 62  
 
 63  
     public void setValue(Object value) {
 64  10
         this.value = value;
 65  10
         valueSet = true;
 66  10
     }
 67  
 
 68  
     public ValueBinding getValueBinding(String name) {
 69  236
         return super.getValueBinding(convertAlias(name));
 70  
     }
 71  
 
 72  
     public void setValueBinding(String name, ValueBinding vb) {
 73  41
         super.setValueBinding(convertAlias(name), vb);
 74  35
     }
 75  
 
 76  
     private String convertAlias(String name) {
 77  277
         if (URL_BINDING_NAME.equals(name)) {
 78  6
             return VALUE_BINDING_NAME;
 79  
         }
 80  271
         return name;
 81  
     }
 82  
 
 83  
     public void restoreState(FacesContext context, Object state) {
 84  4
         Object[] values = (Object[]) state;
 85  4
         super.restoreState(context, values[0]);
 86  4
         value = values[1];
 87  4
         valueSet = ((Boolean) values[2]).booleanValue();
 88  4
     }
 89  
 
 90  
     public Object saveState(FacesContext context) {
 91  6
         Object[] values = new Object[3];
 92  6
         values[0] = super.saveState(context);
 93  6
         values[1] = value;
 94  6
         values[2] = (valueSet) ? Boolean.TRUE : Boolean.FALSE;
 95  6
         return values;
 96  
     }
 97  
 
 98  
 }