Coverage Report - org.seasar.cubby.validator.ValidationException
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidationException
50%
5/10
N/A
1
 
 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 org.seasar.cubby.action.ActionResult;
 19  
 
 20  
 /**
 21  
  * 入力検証に失敗した場合に後続の入力検証を実行しないようにするためにスローする例外です。
 22  
  * 
 23  
  * @author baba
 24  
  */
 25  
 public class ValidationException extends RuntimeException {
 26  
 
 27  
         /** シリアルバージョンUID。 */
 28  
         private static final long serialVersionUID = 1L;
 29  
 
 30  
         /** 入力検証でエラーがあった場合の振る舞い。 */
 31  
         private final ValidationFailBehaviour behaviour;
 32  
 
 33  
         /**
 34  
          * 新規例外を構築します。
 35  
          * 
 36  
          * @param behaviour
 37  
          *            入力検証でエラーがあった場合の振る舞い
 38  
          */
 39  1
         public ValidationException(final ValidationFailBehaviour behaviour) {
 40  1
                 this.behaviour = behaviour;
 41  1
         }
 42  
 
 43  
         /**
 44  
          * 新規例外を構築します。
 45  
          */
 46  
         public ValidationException() {
 47  1
                 this(new ErrorPageValidationFailBehaviour());
 48  1
         }
 49  
 
 50  
         /**
 51  
          * 新規例外を構築します。
 52  
          * 
 53  
          * @param errorMessage
 54  
          *            メッセージ
 55  
          * @param fieldNames
 56  
          *            フィールド名
 57  
          */
 58  
         public ValidationException(final String errorMessage,
 59  
                         final String... fieldNames) {
 60  0
                 this(new ErrorPageValidationFailBehaviour(errorMessage, fieldNames));
 61  0
         }
 62  
 
 63  
         /**
 64  
          * 新規例外を構築します。
 65  
          * 
 66  
          * @param actionResult
 67  
          *            エラーページの遷移などを行う {@link ActionResult}
 68  
          */
 69  
         public ValidationException(final ActionResult actionResult) {
 70  0
                 this(new ActionResultValidationFailBehaviour(actionResult));
 71  0
         }
 72  
 
 73  
         /**
 74  
          * 入力検証でエラーがあった場合の振る舞いを取得します。
 75  
          * 
 76  
          * @return 入力検証でエラーがあった場合の振る舞い
 77  
          */
 78  
         public ValidationFailBehaviour getBehaviour() {
 79  0
                 return behaviour;
 80  
         }
 81  
 
 82  
 }