Coverage Report - javax.faces.application.StateManager
 
Classes in this File Line Coverage Branch Coverage Complexity
StateManager
100%
7/7
100%
2/2
1.167
StateManager$SerializedView
100%
8/8
N/A
1.167
 
 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.application;
 17  
 
 18  
 import java.io.IOException;
 19  
 import java.io.Serializable;
 20  
 
 21  
 import javax.faces.component.UIViewRoot;
 22  
 import javax.faces.context.FacesContext;
 23  
 
 24  
 /**
 25  
  * @author shot
 26  
  */
 27  1365
 public abstract class StateManager implements Serializable {
 28  
 
 29  
     public static final String STATE_SAVING_METHOD_CLIENT = "client";
 30  
 
 31  
     public static final String STATE_SAVING_METHOD_SERVER = "server";
 32  
 
 33  
     public static final String STATE_SAVING_METHOD_PARAM_NAME = "javax.faces.STATE_SAVING_METHOD";
 34  
 
 35  
     public abstract SerializedView saveSerializedView(FacesContext context);
 36  
 
 37  
     public abstract void writeState(FacesContext context, SerializedView state)
 38  
             throws IOException;
 39  
 
 40  
     protected abstract Object getTreeStructureToSave(FacesContext context);
 41  
 
 42  
     protected abstract Object getComponentStateToSave(FacesContext context);
 43  
 
 44  
     public abstract UIViewRoot restoreView(FacesContext context, String viewId,
 45  
             String renderKitId);
 46  
 
 47  
     protected abstract UIViewRoot restoreTreeStructure(FacesContext context,
 48  
             String viewId, String renderKitId);
 49  
 
 50  
     protected abstract void restoreComponentState(FacesContext context,
 51  
             UIViewRoot viewRoot, String renderKitId);
 52  
 
 53  
     public boolean isSavingStateInClient(FacesContext context) {
 54  19
         String state = getSavingState(context);
 55  18
         if (STATE_SAVING_METHOD_CLIENT.equalsIgnoreCase(state)) {
 56  6
             return true;
 57  
         }
 58  12
         return false;
 59  
     }
 60  
 
 61  
     private static String getSavingState(FacesContext context) {
 62  19
         return context.getExternalContext().getInitParameter(
 63  
                 STATE_SAVING_METHOD_PARAM_NAME);
 64  
     }
 65  
 
 66  1365
     public class SerializedView implements Serializable {
 67  
 
 68  
         private static final long serialVersionUID = 1L;
 69  
 
 70  11
         private Object structure = null;
 71  
 
 72  11
         private Object state = null;
 73  
 
 74  11
         public SerializedView(Object structure, Object state) {
 75  11
             this.structure = structure;
 76  11
             this.state = state;
 77  11
         }
 78  
 
 79  
         public Object getState() {
 80  8
             return state;
 81  
         }
 82  
 
 83  
         public Object getStructure() {
 84  9
             return structure;
 85  
         }
 86  
     }
 87  
 
 88  
 }