Coverage Report - javax.faces.internal.scope.RedirectScope
 
Classes in this File Line Coverage Branch Coverage Complexity
RedirectScope
41%
12/29
17%
1/6
1.6
 
 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.scope;
 17  
 
 18  
 import java.util.Map;
 19  
 
 20  
 import javax.faces.FacesException;
 21  
 import javax.faces.context.FacesContext;
 22  
 
 23  
 /**
 24  
  * @author higa
 25  
  *
 26  
  */
 27  
 public abstract class RedirectScope {
 28  
 
 29  2
     private static final String REDIRECTING_KEY = RedirectScope.class.getName();
 30  
 
 31  1
     private static final String REDIRECTED_KEY = RedirectScope.class.getName() +
 32  
             ".REDIRECTED";
 33  
 
 34  1
     private static final VariableScope scope = new VariableScope(
 35  
             REDIRECTING_KEY);
 36  
 
 37  0
     protected RedirectScope() {
 38  0
     }
 39  
 
 40  
     public static Map getContext(FacesContext context) throws FacesException {
 41  0
         return scope.getContext(context);
 42  
     }
 43  
 
 44  
     public static Map getOrCreateContext(FacesContext context)
 45  
             throws FacesException {
 46  4
         return scope.getOrCreateContext(context);
 47  
     }
 48  
 
 49  
     public static void removeContext(FacesContext context)
 50  
             throws FacesException {
 51  0
         scope.removeContext(context);
 52  0
     }
 53  
 
 54  
     public static void clearContext(FacesContext context) throws FacesException {
 55  2
         scope.clearContext(context);
 56  2
     }
 57  
 
 58  
     public static boolean isRedirecting(FacesContext context)
 59  
             throws FacesException {
 60  2
         Map ctx = scope.getContext(context);
 61  2
         if (ctx == null) {
 62  2
             return false;
 63  
         }
 64  0
         return ctx.containsKey(REDIRECTING_KEY);
 65  
     }
 66  
 
 67  
     public static void setRedirectingPath(FacesContext context, String path)
 68  
             throws FacesException {
 69  1
         Map ctx = getOrCreateContext(context);
 70  1
         ctx.put(REDIRECTING_KEY, path);
 71  1
     }
 72  
 
 73  
     public static String getRedirectingPath(FacesContext context)
 74  
             throws FacesException {
 75  0
         Map ctx = scope.getContext(context);
 76  0
         if (ctx == null) {
 77  0
             return null;
 78  
         }
 79  0
         return (String) ctx.get(REDIRECTING_KEY);
 80  
     }
 81  
 
 82  
     public static void setRedirectedPath(FacesContext context, String path)
 83  
             throws FacesException {
 84  0
         Map ctx = getOrCreateContext(context);
 85  0
         ctx.put(REDIRECTED_KEY, path);
 86  0
     }
 87  
 
 88  
     public static String getRedirectedPath(FacesContext context)
 89  
             throws FacesException {
 90  0
         Map ctx = scope.getContext(context);
 91  0
         if (ctx == null) {
 92  0
             return null;
 93  
         }
 94  0
         return (String) ctx.get(REDIRECTED_KEY);
 95  
     }
 96  
 }