Source code: com/aendvari/griffin/validation/validator/ParameterDefine.java
1 /*
2 * ParameterDefine.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.validator.*;
18
19
20 /**
21 * <p>Defines a parameter define for a {@link Validator}.</p>
22 *
23 * <p>
24 * This class is used to define a single parameter name for either a
25 * {@link ErrorMethod} or {@link ValidateMethod}.
26 * </p>
27 *
28 * @author Scott Milne
29 *
30 */
31
32 public class ParameterDefine
33 {
34 /* Variables */
35
36 /** The name of the parameter define */
37 private String name;
38
39 /** The value of the parameter. */
40 private Object value;
41
42 /** The path query that can be used to determine value (use only if set, and instead of "value") */
43 private String path;
44
45 /** The type of the parameter */
46 private String type;
47
48 /** Constants for the type of the parameter. */
49 public interface Type
50 {
51 public static String None = "";
52 public static String Collection = "collection";
53 public static String Property = "property";
54 }
55
56
57 /* Constructors. */
58
59
60 /**
61 * Constructs an empty <code>ParameterDefine</code> instance.
62 *
63 */
64
65 public ParameterDefine()
66 {
67 name = "";
68 value = null;
69 type = Type.None;
70 path = "";
71 }
72
73 /**
74 * Constructs an completed <code>ParameterDefine</code> instance.
75 *
76 * @param setName The name of the parameter define.
77 * @param setValue The value of the parameter define.
78 * @param setPath The path query to obtain a value for the define.
79 * @param setType The type of the parameter
80 *
81 */
82
83 public ParameterDefine( String setName, String setValue, String setPath, String setType )
84 {
85 name = setName;
86 value = setValue;
87 path = setPath;
88 type = setType;
89 }
90
91
92 /* Accessors. */
93
94 /**
95 * Get the name of the parameter.
96 *
97 * @return A string representing the name of the parameter.
98 *
99 */
100
101 public String getName()
102 {
103 return name;
104 }
105
106 /**
107 * Set the name of the parameter.
108 *
109 * @param setName A string representing the name of the parameter.
110 *
111 */
112
113 public void setName( String setName )
114 {
115 name = setName;
116 }
117
118 /**
119 * Get the value of the parameter.
120 *
121 * @return An <code>Object</code> representing the value of the parameter.
122 *
123 */
124
125 public Object getValue()
126 {
127 return value;
128 }
129
130 /**
131 * Set the value of the parameter.
132 *
133 * @param setValue An <code>Object</code> representing the value of the parameter.
134 *
135 */
136
137 public void setValue( Object setValue )
138 {
139 value = setValue;
140 }
141
142 /**
143 * Get the xpath of the parameter.
144 *
145 * @return A string representing the path of the parameter.
146 *
147 */
148
149 public String getPath()
150 {
151 return path;
152 }
153
154 /**
155 * Set the xpath of the parameter.
156 *
157 * @param setPath A string representing the path of the parameter.
158 *
159 */
160
161 public void setPath( String setPath )
162 {
163 path = setPath;
164 }
165
166 /**
167 * Get the type of the parameter.
168 *
169 * @return A string representing the type of the parameter.
170 *
171 */
172
173 public String getType()
174 {
175 return type;
176 }
177
178 /**
179 * Set the type of the parameter.
180 *
181 * @param setType A string representing the type of the parameter.
182 *
183 */
184
185 public void setType( String setType )
186 {
187 type = setType;
188 }
189
190 /**
191 * Executes this part of a <code>Dataset</code> validation.
192 *
193 * @param datasetNode The {@link ModelNode} of which to extract the data to be validated from.
194 * @param validators A <code>HashMap</code> of {@link Validator} instances.
195 * @param handlers A <code>HashMap</code> of {@link ValidationHandler} instances.
196 *
197 */
198
199 public void executeValidation( ModelNode datasetNode, HashMap validators, HashMap handlers )
200 throws Exception
201 {
202
203 }
204
205 /**
206 * Convert this object into a String representation.
207 *
208 */
209
210 public String toString()
211 {
212 String data = "ParameterDefine [";
213 data += "name=" + name + ",";
214 data += "value=" + value + ",";
215 data += "path=" + path + ",";
216 data += "type=" + type + "";
217 data += "]";
218 return data;
219 }
220 }
221