Coverage Report - javax.faces.internal.PageContextUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
PageContextUtil
88%
14/16
50%
1/2
1
 
 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.internal;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import javax.faces.component.UIViewRoot;
 21  
 import javax.faces.context.FacesContext;
 22  
 import javax.servlet.jsp.PageContext;
 23  
 
 24  
 /**
 25  
  * @author shot
 26  
  *
 27  
  * This class might be changed without notice. Please do not use it
 28  
  * excluding the JSF specification part.
 29  
  */
 30  
 public class PageContextUtil {
 31  
 
 32  0
     private PageContextUtil() {
 33  0
     }
 34  
 
 35  
     public static List getComponentTagStackAttribute(PageContext pageContext) {
 36  26
         return (List) pageContext.getAttribute(
 37  
                 InternalConstants.COMPONENT_TAG_STACK_ATTR, getScope());
 38  
     }
 39  
 
 40  
     public static void setComponentStackAttribute(PageContext pageContext,
 41  
             List list) {
 42  8
         pageContext.setAttribute(InternalConstants.COMPONENT_TAG_STACK_ATTR,
 43  
                 list, getScope());
 44  8
     }
 45  
 
 46  
     public static void removeComponentStackAttribute(PageContext pageContext) {
 47  3
         pageContext.removeAttribute(InternalConstants.COMPONENT_TAG_STACK_ATTR,
 48  
                 getScope());
 49  3
     }
 50  
 
 51  
     private static int getScope() {
 52  37
         String defaultSuffix = FacesConfigOptions.getDefaultSuffix();
 53  37
         return (defaultSuffix.indexOf(".htm") >= 0) ? PageContext.PAGE_SCOPE
 54  
                 : PageContext.REQUEST_SCOPE;
 55  
     }
 56  
 
 57  
     public static FacesContext getCurrentFacesContextAttribute(
 58  
             PageContext pageContext) {
 59  7
         return (FacesContext) pageContext
 60  
                 .getAttribute(InternalConstants.CURRENT_FACES_CONTEXT);
 61  
     }
 62  
 
 63  
     public static void setCurrentFacesContextAttribute(PageContext pageContext,
 64  
             FacesContext context) {
 65  7
         pageContext.setAttribute(InternalConstants.CURRENT_FACES_CONTEXT,
 66  
                 context);
 67  7
     }
 68  
 
 69  
     public static UIViewRoot getCurrentViewRootAttribute(PageContext pageContext) {
 70  7
         return (UIViewRoot) pageContext
 71  
                 .getAttribute(InternalConstants.CURRENT_VIEW_ROOT);
 72  
     }
 73  
 
 74  
     public static void setCurrentViewRootAttribute(PageContext pageContext,
 75  
             UIViewRoot component) {
 76  7
         pageContext
 77  
                 .setAttribute(InternalConstants.CURRENT_VIEW_ROOT, component);
 78  7
     }
 79  
 
 80  
     public static String getCharacterEncoding(PageContext pageContext) {
 81  7
         return pageContext.getRequest().getCharacterEncoding();
 82  
     }
 83  
 }