Coverage Report - org.seasar.teeda.core.util.StateManagerUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
StateManagerUtil
87%
13/15
88%
7/8
2
 
 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.util;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.Iterator;
 20  
 import java.util.List;
 21  
 
 22  
 import javax.faces.component.NamingContainer;
 23  
 import javax.faces.component.UIComponent;
 24  
 import javax.faces.context.FacesContext;
 25  
 
 26  
 /**
 27  
  * @author shot
 28  
  */
 29  
 public class StateManagerUtil {
 30  
 
 31  0
     private StateManagerUtil() {
 32  0
     }
 33  
 
 34  
     public static boolean isSavingStateInClient(FacesContext context) {
 35  9
         return FacesContextUtil.getStateManager(context).isSavingStateInClient(
 36  
                 context);
 37  
     }
 38  
 
 39  
     public static void assertComponentNoDuplicateId(UIComponent component) {
 40  4
         assertComponentNoDuplicateIdInternal(component, new ArrayList());
 41  1
     }
 42  
 
 43  
     private static void assertComponentNoDuplicateIdInternal(
 44  
             UIComponent component, List idList) {
 45  9
         String id = component.getId();
 46  9
         if (id != null && idList.contains(id)) {
 47  2
             throw new IllegalStateException("Component id:" + id
 48  
                     + " has same id in view tree.");
 49  
         }
 50  7
         idList.add(id);
 51  7
         for (Iterator itr = component.getFacetsAndChildren(); itr.hasNext();) {
 52  6
             UIComponent child = (UIComponent) itr.next();
 53  6
             if (component instanceof NamingContainer) {
 54  1
                 assertComponentNoDuplicateId(child);
 55  
             } else {
 56  5
                 assertComponentNoDuplicateIdInternal(child, idList);
 57  
             }
 58  
         }
 59  3
     }
 60  
 
 61  
 }