Coverage Report - org.seasar.teeda.core.taglib.core.VerbatimTag
 
Classes in this File Line Coverage Branch Coverage Complexity
VerbatimTag
80%
20/25
50%
5/10
1.571
 
 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 org.seasar.teeda.core.taglib.core;
 17  
 
 18  
 import javax.faces.component.UIComponent;
 19  
 import javax.faces.component.UIOutput;
 20  
 import javax.faces.webapp.UIComponentBodyTag;
 21  
 import javax.servlet.jsp.JspException;
 22  
 import javax.servlet.jsp.tagext.BodyContent;
 23  
 
 24  
 import org.seasar.teeda.core.JsfConstants;
 25  
 import org.seasar.teeda.core.util.BindingUtil;
 26  
 import org.seasar.teeda.core.util.ConverterUtil;
 27  
 
 28  
 /**
 29  
  * @author yone
 30  
  * @author shot
 31  
  */
 32  
 public class VerbatimTag extends UIComponentBodyTag {
 33  
 
 34  
     private static final String COMPONENT_TYPE = "javax.faces.Output";
 35  
 
 36  
     private static final String RENDER_TYPE = "javax.faces.Text";
 37  
 
 38  5
     private String escape = null;
 39  
 
 40  
     public VerbatimTag() {
 41  5
         super();
 42  5
     }
 43  
 
 44  
     public String getComponentType() {
 45  1
         return COMPONENT_TYPE;
 46  
     }
 47  
 
 48  
     public String getRendererType() {
 49  5
         return RENDER_TYPE;
 50  
     }
 51  
 
 52  
     public void setEscape(String escape) {
 53  1
         this.escape = escape;
 54  1
     }
 55  
 
 56  
     public String getEscape() {
 57  2
         return escape;
 58  
     }
 59  
 
 60  
     protected void setProperties(UIComponent component) {
 61  2
         super.setProperties(component);
 62  2
         final String escapeStr = getEscape();
 63  2
         if (escapeStr != null) {
 64  1
             if (BindingUtil.isValueReference(escapeStr)) {
 65  0
                 BindingUtil.setValueBinding(component,
 66  
                         JsfConstants.ESCAPE_ATTR, escapeStr);
 67  
             } else {
 68  1
                 boolean escape = ConverterUtil.convertToBoolean(escapeStr);
 69  1
                 component.getAttributes().put(JsfConstants.ESCAPE_ATTR,
 70  
                         escape ? Boolean.TRUE : Boolean.FALSE);
 71  
             }
 72  
         } else {
 73  1
             component.getAttributes().put(JsfConstants.ESCAPE_ATTR,
 74  
                     Boolean.FALSE);
 75  
         }
 76  2
         component.setTransient(true);
 77  2
     }
 78  
 
 79  
     public int doAfterBody() throws JspException {
 80  1
         BodyContent bodyContent = getBodyContent();
 81  1
         if (bodyContent != null) {
 82  0
             String value = bodyContent.getString().trim();
 83  0
             if (value != null) {
 84  0
                 UIOutput component = (UIOutput) getComponentInstance();
 85  0
                 component.setValue(value);
 86  
             }
 87  
         }
 88  1
         return super.doAfterBody();
 89  
     }
 90  
 
 91  
 }