Coverage Report - javax.faces.render.Renderer
 
Classes in this File Line Coverage Branch Coverage Complexity
Renderer
18%
7/38
13%
4/30
4.857
 
 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.render;
 20  
 
 21  
 import java.io.IOException;
 22  
 
 23  
 import javax.faces.component.UIComponent;
 24  
 import javax.faces.context.FacesContext;
 25  
 import javax.faces.convert.ConverterException;
 26  
 
 27  
 /**
 28  
  * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
 29  
  */
 30  36
 public abstract class Renderer
 31  
 {
 32  
     /**
 33  
      * @since 2.2
 34  
      */
 35  
     public static final String PASSTHROUGH_RENDERER_LOCALNAME_KEY = "elementName";
 36  
     
 37  
     public void decode(FacesContext context, UIComponent component)
 38  
     {
 39  24
         if (context == null)
 40  
         {
 41  0
             throw new NullPointerException("context");
 42  
         }
 43  24
         if (component == null)
 44  
         {
 45  0
             throw new NullPointerException("component");
 46  
         }
 47  24
     }
 48  
 
 49  
     /**
 50  
      * @throws IOException if an input/output error occurs while rendering 
 51  
      */
 52  
     public void encodeBegin(FacesContext context, UIComponent component) throws IOException
 53  
     {
 54  0
         if (context == null)
 55  
         {
 56  0
             throw new NullPointerException("context");
 57  
         }
 58  0
         if (component == null)
 59  
         {
 60  0
             throw new NullPointerException("component");
 61  
         }
 62  0
     }
 63  
 
 64  
     /**
 65  
      * Render all children if there are any.
 66  
      * 
 67  
      * Note: this will only be called if getRendersChildren() returns true. A component which has a renderer with
 68  
      * getRendersChildren() set to true will typically contain the rendering logic for its children in this method.
 69  
      * 
 70  
      * @param context
 71  
      * @param component
 72  
      * @throws IOException
 73  
      */
 74  
     public void encodeChildren(FacesContext context, UIComponent component) throws IOException
 75  
     {
 76  0
         if (context == null)
 77  
         {
 78  0
             throw new NullPointerException("context");
 79  
         }
 80  0
         if (component == null)
 81  
         {
 82  0
             throw new NullPointerException("component");
 83  
         }
 84  
 
 85  0
         if (component.getChildCount() > 0)
 86  
         {
 87  0
             for (int i = 0, childCount = component.getChildCount(); i < childCount; i++)
 88  
             {
 89  0
                 UIComponent child = component.getChildren().get(i);
 90  0
                 if (!child.isRendered())
 91  
                 {
 92  0
                     continue;
 93  
                 }
 94  
 
 95  0
                 child.encodeAll(context);
 96  
             }
 97  
         }
 98  0
     }
 99  
 
 100  
     /**
 101  
      * @throws IOException if an input/output error occurs while rendering 
 102  
      */
 103  
     public void encodeEnd(FacesContext context, UIComponent component) throws IOException
 104  
     {
 105  0
         if (context == null)
 106  
         {
 107  0
             throw new NullPointerException("context");
 108  
         }
 109  0
         if (component == null)
 110  
         {
 111  0
             throw new NullPointerException("component");
 112  
         }
 113  0
     }
 114  
 
 115  
     public String convertClientId(FacesContext context, String clientId)
 116  
     {
 117  82
         if (context == null)
 118  
         {
 119  0
             throw new NullPointerException("context");
 120  
         }
 121  82
         if (clientId == null)
 122  
         {
 123  0
             throw new NullPointerException("clientId");
 124  
         }
 125  82
         return clientId;
 126  
     }
 127  
 
 128  
     /**
 129  
      * Switch for deciding who renders the children.
 130  
      * 
 131  
      * @return <b>true</b> - if the component takes care of rendering its children. In this case, encodeChildren() ought
 132  
      *         to be called by the rendering controller (e.g., the rendering controller could be the method encodeAll()
 133  
      *         in UIComponent). In the method encodeChildren(), the component should therefore provide all children
 134  
      *         encode logic. <br/> <b>false</b> - if the component does not take care of rendering its children. In this
 135  
      *         case, encodeChildren() should not be called by the rendering controller. Instead, the children-list
 136  
      *         should be retrieved and the children should directly be rendered by the rendering controller one by one.
 137  
      */
 138  
     public boolean getRendersChildren()
 139  
     {
 140  0
         return false;
 141  
     }
 142  
 
 143  
     public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue)
 144  
         throws ConverterException
 145  
     {
 146  0
         if (context == null)
 147  
         {
 148  0
             throw new NullPointerException("context");
 149  
         }
 150  0
         if (component == null)
 151  
         {
 152  0
             throw new NullPointerException("component");
 153  
         }
 154  0
         return submittedValue;
 155  
     }
 156  
 
 157  
 }