Coverage Report - javax.faces.component.UIGraphic
 
Classes in this File Line Coverage Branch Coverage Complexity
UIGraphic
0%
0/30
0%
0/8
0
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package javax.faces.component;
 20  
 
 21  
 import javax.el.ValueExpression;
 22  
 import javax.faces.context.FacesContext;
 23  
 
 24  
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
 25  
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
 26  
 
 27  
 /**
 28  
  * Displays a graphical image.
 29  
  * <p>
 30  
  * See the javadoc for this class in the
 31  
  * <a href="http://java.sun.com/j2ee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
 32  
  * for further details.
 33  
  */
 34  
 @JSFComponent(defaultRendererType = "javax.faces.Image")
 35  
 public class UIGraphic extends UIComponentBase
 36  
 {
 37  
     public static final String COMPONENT_TYPE = "javax.faces.Graphic";
 38  
     public static final String COMPONENT_FAMILY = "javax.faces.Graphic";
 39  
 
 40  
     private static final String URL_PROPERTY = "url";
 41  
     private static final String VALUE_PROPERTY = "value";
 42  
 
 43  
     private Object _value;
 44  
 
 45  
     /**
 46  
      * Construct an instance of the UIGraphic.
 47  
      */
 48  
     public UIGraphic()
 49  0
     {
 50  0
         setRendererType("javax.faces.Image");
 51  0
     }
 52  
 
 53  
     @Override
 54  
     public String getFamily()
 55  
     {
 56  0
         return COMPONENT_FAMILY;
 57  
     }
 58  
 
 59  
     /**
 60  
      * An alias for the "value" attribute.
 61  
      */
 62  
     @JSFProperty
 63  
     public String getUrl()
 64  
     {
 65  0
         return (String) getValue();
 66  
     }
 67  
 
 68  
     public void setUrl(String url)
 69  
     {
 70  0
         setValue(url);
 71  0
     }
 72  
 
 73  
     @Override
 74  
     public ValueExpression getValueExpression(String name)
 75  
     {
 76  0
         if (URL_PROPERTY.equals(name))
 77  
         {
 78  0
             return super.getValueExpression(VALUE_PROPERTY);
 79  
         }
 80  
         else
 81  
         {
 82  0
             return super.getValueExpression(name);
 83  
         }
 84  
     }
 85  
 
 86  
     @Override
 87  
     public void setValueExpression(String name, ValueExpression binding)
 88  
     {
 89  0
         if (URL_PROPERTY.equals(name))
 90  
         {
 91  0
             super.setValueExpression(VALUE_PROPERTY, binding);
 92  
         }
 93  
         else
 94  
         {
 95  0
             super.setValueExpression(name, binding);
 96  
         }
 97  0
     }
 98  
 
 99  
     /**
 100  
      * The URL of the image.
 101  
      * <p>
 102  
      * If the URL starts with a '/', it is relative to the context path of the web application.
 103  
      * </p>
 104  
      */
 105  
     @JSFProperty
 106  
     public Object getValue()
 107  
     {
 108  0
         if (_value != null)
 109  
         {
 110  0
             return _value;
 111  
         }
 112  0
         ValueExpression expression = getValueExpression("value");
 113  0
         if (expression != null)
 114  
         {
 115  0
             return expression.getValue(getFacesContext().getELContext());
 116  
         }
 117  0
         return null;
 118  
     }
 119  
 
 120  
     public void setValue(Object value)
 121  
     {
 122  0
         this._value = value;
 123  0
     }
 124  
 
 125  
     @Override
 126  
     public Object saveState(FacesContext facesContext)
 127  
     {
 128  0
         Object[] values = new Object[2];
 129  0
         values[0] = super.saveState(facesContext);
 130  0
         values[1] = _value;
 131  
 
 132  0
         return values;
 133  
     }
 134  
 
 135  
     @Override
 136  
     public void restoreState(FacesContext facesContext, Object state)
 137  
     {
 138  0
         Object[] values = (Object[]) state;
 139  0
         super.restoreState(facesContext, values[0]);
 140  0
         _value = values[1];
 141  0
     }
 142  
 }