Coverage Report - javax.faces.component.UIGraphic
 
Classes in this File Line Coverage Branch Coverage Complexity
UIGraphic
94%
16/17
100%
4/4
1.375
UIGraphic$PropertyKeys
100%
2/2
N/A
1.375
 
 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  
 
 23  
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
 24  
 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
 25  
 
 26  
 /**
 27  
  * Displays a graphical image.
 28  
  * <p>
 29  
  * See the javadoc for this class in the
 30  
  * <a href="http://java.sun.com/j2ee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
 31  
  * for further details.
 32  
  */
 33  
 @JSFComponent(defaultRendererType = "javax.faces.Image")
 34  
 public class UIGraphic extends UIComponentBase
 35  
 {
 36  
     public static final String COMPONENT_TYPE = "javax.faces.Graphic";
 37  
     public static final String COMPONENT_FAMILY = "javax.faces.Graphic";
 38  
 
 39  
     private static final String URL_PROPERTY = "url";
 40  
     private static final String VALUE_PROPERTY = "value";
 41  
 
 42  
     /**
 43  
      * Construct an instance of the UIGraphic.
 44  
      */
 45  
     public UIGraphic()
 46  6
     {
 47  6
         setRendererType("javax.faces.Image");
 48  6
     }
 49  
 
 50  
     @Override
 51  
     public String getFamily()
 52  
     {
 53  0
         return COMPONENT_FAMILY;
 54  
     }
 55  
 
 56  
     /**
 57  
      * An alias for the "value" attribute.
 58  
      */
 59  
     @JSFProperty
 60  
     public String getUrl()
 61  
     {
 62  2
         return (String) getValue();
 63  
     }
 64  
 
 65  
     public void setUrl(String url)
 66  
     {
 67  2
         setValue(url);
 68  2
     }
 69  
 
 70  
     @Override
 71  
     public ValueExpression getValueExpression(String name)
 72  
     {
 73  8
         if (URL_PROPERTY.equals(name))
 74  
         {
 75  4
             return super.getValueExpression(VALUE_PROPERTY);
 76  
         }
 77  
         else
 78  
         {
 79  4
             return super.getValueExpression(name);
 80  
         }
 81  
     }
 82  
 
 83  
     @Override
 84  
     public void setValueExpression(String name, ValueExpression binding)
 85  
     {
 86  8
         if (URL_PROPERTY.equals(name))
 87  
         {
 88  4
             super.setValueExpression(VALUE_PROPERTY, binding);
 89  
         }
 90  
         else
 91  
         {
 92  4
             super.setValueExpression(name, binding);
 93  
         }
 94  8
     }
 95  
 
 96  
     /**
 97  
      * The URL of the image.
 98  
      * <p>
 99  
      * If the URL starts with a '/', it is relative to the context path of the web application.
 100  
      * </p>
 101  
      */
 102  
     @JSFProperty
 103  
     public Object getValue()
 104  
     {
 105  4
         return  getStateHelper().eval(PropertyKeys.value);
 106  
     }
 107  
 
 108  
     public void setValue(Object value)
 109  
     {
 110  4
         getStateHelper().put(PropertyKeys.value, value );
 111  4
     }
 112  
     
 113  4
     enum PropertyKeys
 114  
     {
 115  2
          value
 116  
     }
 117  
 }