##### Coverage Report - org.seasar.cubby.validator.AbstractValidationRules

Classes in this File | Line Coverage | Branch Coverage | Complexity
AbstractValidationRules |
90% | 9/10
83% | 5/6
| 3.0;3

1 |  |
     /*
2 |  |
      * Copyright 2004-2009 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.cubby.validator;
17 |  |
18 |  |
     import java.util.Collection;
19 |  |
     import java.util.Map;
20 |  |
21 |  |
     import org.seasar.cubby.action.ActionErrors;
22 |  |
23 |  |
     /**
24 |  |
      * 入力検証ルールの抽象Kクラスです。
25 |  |
      *
26 |  |
      * @author baba
27 |  |
      */
28 | 11 |
     public abstract class AbstractValidationRules implements ValidationRules {
29 |  |
30 |  |
             /**
31 |  |
              * すべてのフェーズに対する入力検証を実行します。
32 |  |
              *
33 |  |
              * @param params
34 |  |
              *            要求パラメータ
35 |  |
              * @param form
36 |  |
              *            フォームオブジェクト
37 |  |
              * @param errors
38 |  |
              *            アクションのエラー
39 |  |
              */
40 |  |
             public void validate(final Map<String, Object[]> params, final Object form,
41 |  |
                             final ActionErrors errors) {
42 | 1 |
                     for (final ValidationPhase validationPhase : this.getValidationPhases()) {
43 | 2 |
                             validate(validationPhase, params, form, errors);
44 |  |
                     }
45 | 0 |
             }
46 |  |
47 |  |
             /**
48 |  |
              * 指定されたフェーズに対する入力検証を実行します。
49 |  |
              *
50 |  |
              * @param validationRules
51 |  |
              *            入力検証ルールの集合
52 |  |
              * @param validationPhase
53 |  |
              *            入力検証のフェーズ
54 |  |
              * @param errors
55 |  |
              *            アクションのエラー
56 |  |
              * @param params
57 |  |
              *            要求パラメータ
58 |  |
              * @param form
59 |  |
              *            フォームオブジェクト
60 |  |
              */
61 |  |
             protected void validate(final ValidationPhase validationPhase,
62 |  |
                             final Map<String, Object[]> params, final Object form,
63 |  |
                             final ActionErrors errors) {
64 | 2 |
                     final Collection<ValidationRule> phaseValidationRules = this
65 |  |
                                     .getPhaseValidationRules(validationPhase);
66 | 2 |
                     for (final ValidationRule validationRule : phaseValidationRules) {
67 | 1 |
                             validationRule.apply(params, form, errors);
68 |  |
                     }
69 | 2 |
                     if (!errors.isEmpty()) {
70 | 1 |
                             throw new ValidationException();
71 |  |
                     }
72 | 1 |
             }
73 |  |
74 |  |
     }