Coverage Report - javax.faces.webapp.AttributeTag
 
Classes in this File Line Coverage Branch Coverage Complexity
AttributeTag
0%
0/26
0%
0/10
2.4
 
 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.webapp;
 17  
 
 18  
 import javax.faces.component.UIComponent;
 19  
 import javax.faces.internal.WebAppUtil;
 20  
 import javax.servlet.jsp.JspException;
 21  
 import javax.servlet.jsp.tagext.TagSupport;
 22  
 
 23  
 /**
 24  
  * @author shot
 25  
  */
 26  
 public class AttributeTag extends TagSupport {
 27  
 
 28  
     private static final long serialVersionUID = 1L;
 29  
 
 30  0
     private String name = null;
 31  
 
 32  0
     private String value = null;
 33  
 
 34  0
     public AttributeTag() {
 35  0
     }
 36  
 
 37  
     public void setName(String name) {
 38  0
         this.name = name;
 39  0
     }
 40  
 
 41  
     public void setValue(String value) {
 42  0
         this.value = value;
 43  0
     }
 44  
 
 45  
     public int doStartTag() throws JspException {
 46  0
         UIComponentTag componentTag = UIComponentTag
 47  
                 .getParentUIComponentTag(pageContext);
 48  0
         if (componentTag == null) {
 49  0
             throw new JspException("Not nested in a UIComponentTag");
 50  
         }
 51  0
         UIComponent component = componentTag.getComponentInstance();
 52  0
         if (component == null) {
 53  0
             throw new JspException(
 54  
                     "No component associated with UIComponentTag");
 55  
         }
 56  0
         String nameObj = name;
 57  0
         if (UIComponentTag.isValueReference(name)) {
 58  0
             nameObj = (String) WebAppUtil.getValueFromCreatedValueBinding(name);
 59  
         }
 60  0
         Object valueObj = value;
 61  0
         if (UIComponentTag.isValueReference(value)) {
 62  0
             valueObj = WebAppUtil.getValueFromCreatedValueBinding(value);
 63  
         }
 64  0
         if (component.getAttributes().get(nameObj) == null) {
 65  0
             component.getAttributes().put(nameObj, valueObj);
 66  
         }
 67  0
         return SKIP_BODY;
 68  
     }
 69  
 
 70  
     public void release() {
 71  0
         name = null;
 72  0
         value = null;
 73  0
     }
 74  
 }