Coverage Report - javax.faces.internal.ValidatorChain
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidatorChain
82%
14/17
100%
2/2
1.125
 
 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.Iterator;
 19  
 import java.util.LinkedList;
 20  
 import java.util.List;
 21  
 
 22  
 import javax.faces.component.StateHolder;
 23  
 import javax.faces.component.UIComponent;
 24  
 import javax.faces.component.UIComponentBase;
 25  
 import javax.faces.context.FacesContext;
 26  
 import javax.faces.validator.Validator;
 27  
 import javax.faces.validator.ValidatorException;
 28  
 
 29  
 /**
 30  
  * @author Satoshi Kimura
 31  
  * @author shot
 32  
  * @author manhole
 33  
  */
 34  7
 public class ValidatorChain implements Validator, StateHolder {
 35  
 
 36  
     //TODO testing
 37  7
     private boolean transientValue = false;
 38  
 
 39  7
     private List validators = new LinkedList();
 40  
 
 41  
     public int getValidatorSize() {
 42  1
         return validators.size();
 43  
     }
 44  
 
 45  
     public Validator getValidator(int index) {
 46  8
         return (Validator) validators.get(index);
 47  
     }
 48  
 
 49  
     public void add(Validator validator) {
 50  12
         validators.add(validator);
 51  12
     }
 52  
 
 53  
     public void validate(FacesContext context, UIComponent component,
 54  
             Object value) throws ValidatorException {
 55  1
         for (Iterator iterator = validators.iterator(); iterator.hasNext();) {
 56  2
             Validator validator = (Validator) iterator.next();
 57  2
             validator.validate(context, component, value);
 58  
         }
 59  1
     }
 60  
 
 61  
     public Object saveState(FacesContext context) {
 62  1
         return UIComponentBase.saveAttachedState(context, validators);
 63  
     }
 64  
 
 65  
     public void restoreState(FacesContext context, Object state) {
 66  1
         validators = (List) UIComponentBase
 67  
                 .restoreAttachedState(context, state);
 68  1
     }
 69  
 
 70  
     public boolean isTransient() {
 71  0
         return transientValue;
 72  
     }
 73  
 
 74  
     public void setTransient(boolean transientValue) {
 75  0
         this.transientValue = transientValue;
 76  0
     }
 77  
 }