Source code: com/aendvari/griffin/validation/validator/ErrorHandler.java
1 /*
2 * ErrorHandler.java
3 *
4 * Copyright (c) 2001, 2002 Aendvari, Ltd. All Rights Reserved.
5 *
6 * See the file LICENSE for terms of use.
7 *
8 */
9
10 package com.aendvari.griffin.validation.validator;
11
12 import java.io.*;
13 import java.util.*;
14 import java.beans.*;
15
16 import java.lang.reflect.*;
17 import java.lang.NoSuchMethodException;
18 import java.lang.IllegalAccessException;
19
20 import com.aendvari.common.*;
21
22 import com.aendvari.common.model.*;
23
24 import com.aendvari.griffin.validation.*;
25 import com.aendvari.griffin.validation.dataset.*;
26 import com.aendvari.griffin.validation.validator.*;
27
28
29 /**
30 * <p>Defines a {@link ErrorHandler}.</p>
31 *
32 * @author Scott Milne
33 *
34 */
35
36 public class ErrorHandler extends Handler
37 {
38 /**
39 * Executes this classes' part of a <code>Dataset</code> validation.
40 *
41 * @param property A {@link Property} instance for the value to test.
42 * @param handlers A HashMap of {@link ValidationHandler} instances.
43 *
44 * @return Returns boolean for determining if the error was successful.
45 *
46 */
47
48 public boolean executeValidation( Property property, HashMap handlers )
49 throws Exception
50 {
51 ValidationHandler errorHandlerObjectHandler = (ValidationHandler)handlers.get(handlerObject);
52
53 ValidationHandler errorHandlerClassHandler = (ValidationHandler)handlers.get(handlerClass);
54
55 // execute the error method
56 boolean methodExecuted = handlerMethod.executeValidation(
57 this,
58 property,
59 errorHandlerObjectHandler,
60 errorHandlerClassHandler
61 );
62
63 return methodExecuted;
64 }
65
66 /**
67 * Convert this object into a String representation.
68 *
69 */
70
71 public String toString()
72 {
73 String data = "ErrorHandler [";
74 data += "name=" + name + ",";
75 data += "handlerObject=" + handlerObject + ",";
76 data += "handlerClass=" + handlerClass + ",";
77 data += "handlerMethod=" + handlerMethod + ",";
78 data += "parameterDefines="+parameterDefines;
79 data += "]";
80 return data;
81 }
82 }
83