1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
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 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 7 | public class ValidatorChain implements Validator, StateHolder { |
35 | |
|
36 | |
|
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 | |
} |