Source code: com/aendvari/griffin/validation/validator/HandlerMethod.java
1 /*
2 * HandlerMethod.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.util.*;
13
14 import com.aendvari.common.model.*;
15
16 import com.aendvari.griffin.validation.*;
17 import com.aendvari.griffin.validation.dataset.*;
18 import com.aendvari.griffin.validation.validator.*;
19
20
21 /**
22 * <p>Defines a {@link Handler} method.</p>
23 *
24 * <p>This class is used to define the method that is to be called from within a class.</p>
25 *
26 * <p>This class cannot be used directly, instead you must use either {@link ErrorMethod} or {@link ValidateMethod}.</p>
27 *
28 * @author Scott Milne
29 *
30 */
31
32 public abstract class HandlerMethod
33 {
34 /* Variables */
35
36 /** The name of the method to call. */
37 protected String name;
38
39 /** The list of {@link MethodParameter} defined for this method */
40 protected ArrayList parameters;
41
42
43 /* Constructors. */
44
45
46 /**
47 * Constructs an empty <code>HandlerMethod</code> instance.
48 *
49 */
50
51 public HandlerMethod()
52 {
53 name = "";
54 parameters = new ArrayList();
55 }
56
57
58 /* Accessors. */
59
60
61 /**
62 * Get the name of the method to call.
63 *
64 * @return The name of the method.
65 *
66 */
67
68 public String getName()
69 {
70 return name;
71 }
72
73 /**
74 * Set the name of the method to call.
75 *
76 * @param setName The name of the method.
77 *
78 */
79
80 public void setName( String setName )
81 {
82 name = setName;
83 }
84
85 /**
86 * Get the list of parameters for this method (in order of method call).
87 *
88 * @return <code>Collection</code> of {@link MethodParameter} objects.
89 *
90 */
91
92 public Collection getParameters()
93 {
94 return parameters;
95 }
96
97 /**
98 * Set the list of parameters for this method.
99 *
100 * @param setParameters A <code>Collection</code> of {@link MethodParameter} objects.
101 *
102 */
103
104 public void setParameters( Collection setParameters )
105 {
106 parameters = new ArrayList(setParameters);
107 }
108
109 /**
110 * Add a parameter to the list of parameters for this method.
111 *
112 * @param parameter A {@link MethodParameter} object.
113 *
114 */
115
116 public void addParameter( MethodParameter parameter )
117 {
118 parameters.add(parameter);
119 }
120
121 /**
122 * Executes this part of a Dataset validation.
123 *
124 * @param errorHandler The {@link ErrorHandler} instance for this method.
125 * @param property A {@link Property} instance for the value to test.
126 * @param defaultObjectHandler A {@link ValidationHandler} as object handler instance.
127 * @param defaultClassHandler A {@link ValidationHandler} as class handler instance.
128 *
129 */
130
131 public abstract boolean executeValidation(
132 Handler handler,
133 Property property,
134 ValidationHandler errorObjectHandler,
135 ValidationHandler errorClassHandler ) throws Exception;
136
137
138 /**
139 * Convert this object into a String representation.
140 *
141 */
142
143 public String toString()
144 {
145 String data = "HandlerMethod [";
146 data += "name=" + name + ",";
147 data += "parameters=" + parameters + ",";
148 data += "]";
149 return data;
150 }
151 }
152