Coverage Report - javax.faces.render.ResponseStateManager
 
Classes in this File Line Coverage Branch Coverage Complexity
ResponseStateManager
3%
1/27
0%
0/6
1.556
 
 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 javax.faces.application.StateManager;
 22  
 import javax.faces.application.StateManager.SerializedView;
 23  
 import javax.faces.context.FacesContext;
 24  
 import java.io.IOException;
 25  
 
 26  
 /**
 27  
  * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
 28  
  */
 29  520
 public abstract class ResponseStateManager
 30  
 {
 31  
     public static final String RENDER_KIT_ID_PARAM = "javax.faces.RenderKitId";
 32  
     public static final String VIEW_STATE_PARAM = "javax.faces.ViewState";
 33  
     
 34  
     public static final String CLIENT_WINDOW_PARAM = "javax.faces.ClientWindow";
 35  
     public static final String CLIENT_WINDOW_URL_PARAM = "jfwid";
 36  
     
 37  
     public static final String NON_POSTBACK_VIEW_TOKEN_PARAM = "javax.faces.Token";
 38  
 
 39  
     public void writeState(FacesContext context, Object state) throws IOException
 40  
     {
 41  
         SerializedView view;
 42  0
         if (state instanceof SerializedView)
 43  
         {
 44  0
             view = (SerializedView)state;
 45  
         }
 46  0
         else if (state instanceof Object[])
 47  
         {
 48  0
             Object[] structureAndState = (Object[])state;
 49  
 
 50  0
             if (structureAndState.length == 2)
 51  
             {
 52  0
                 Object structureObj = structureAndState[0];
 53  0
                 Object stateObj = structureAndState[1];
 54  
 
 55  0
                 StateManager stateManager = context.getApplication().getStateManager();
 56  0
                 view = stateManager.new SerializedView(structureObj, stateObj);
 57  0
             }
 58  
             else
 59  
             {
 60  0
                 throw new IOException("The state should be an array of Object[] of lenght 2");
 61  
             }
 62  0
         }
 63  
         else
 64  
         {
 65  0
             throw new IOException("The state should be an array of Object[] of lenght 2, or a SerializedView instance");
 66  
         }
 67  
 
 68  0
         writeState(context, view);
 69  0
     }
 70  
 
 71  
     /**
 72  
      * @throws IOException 
 73  
      * @deprecated
 74  
      */
 75  
     public void writeState(FacesContext context, StateManager.SerializedView state) throws IOException
 76  
     {
 77  
         // does nothing as per JSF 1.2 javadoc
 78  0
     }
 79  
     
 80  
     /**
 81  
      * 
 82  
      * @since 2.0
 83  
      * @param context
 84  
      * @param state
 85  
      * @return
 86  
      */
 87  
     public String getViewState(FacesContext context, Object state)
 88  
     {
 89  
         // TODO: IMPLEMENT HERE
 90  
         
 91  0
         return null;
 92  
     }
 93  
 
 94  
     /**
 95  
      * @since 1.2
 96  
      */
 97  
     public Object getState(FacesContext context, String viewId)
 98  
     {
 99  0
         Object[] structureAndState = new Object[2];
 100  0
         structureAndState[0] = getTreeStructureToRestore(context, viewId);
 101  0
         structureAndState[1] = getComponentStateToRestore(context);
 102  0
         return structureAndState;
 103  
     }
 104  
 
 105  
     /**
 106  
      * @deprecated
 107  
      */
 108  
     public Object getTreeStructureToRestore(FacesContext context, String viewId)
 109  
     {
 110  0
         return null;
 111  
     }
 112  
 
 113  
     /**
 114  
      * @deprecated
 115  
      */
 116  
     public Object getComponentStateToRestore(FacesContext context)
 117  
     {
 118  0
         return null;
 119  
     }
 120  
 
 121  
     /**
 122  
      * Checks if the current request is a postback
 123  
      * 
 124  
      * @since 1.2
 125  
      */
 126  
     public boolean isPostback(FacesContext context)
 127  
     {
 128  0
         return context.getExternalContext().getRequestParameterMap().containsKey(ResponseStateManager.VIEW_STATE_PARAM);
 129  
     }
 130  
 
 131  
     /**
 132  
      * @since 2.2
 133  
      * @param context
 134  
      * @return 
 135  
      */
 136  
     public String getCryptographicallyStrongTokenFromSession(FacesContext context)
 137  
     {
 138  0
         return null;
 139  
     }
 140  
     
 141  
     /**
 142  
      * @since 2.2
 143  
      * @param context
 144  
      * @param viewId
 145  
      * @return 
 146  
      */
 147  
     public boolean isStateless(FacesContext context, String viewId)
 148  
     {
 149  0
         return false;
 150  
     }
 151  
 }