Classes in this File | Line Coverage | Branch Coverage | Complexity | |||||||
ValidatorBinding |
|
| 1.0;1 |
1 | // Copyright 2005 The Apache Software Foundation |
|
2 | // |
|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
|
4 | // you may not use this file except in compliance with the License. |
|
5 | // You may obtain a copy of the License at |
|
6 | // |
|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | // |
|
9 | // Unless required by applicable law or agreed to in writing, software |
|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
12 | // See the License for the specific language governing permissions and |
|
13 | // limitations under the License. |
|
14 | ||
15 | package org.apache.tapestry.valid; |
|
16 | ||
17 | import org.apache.hivemind.Location; |
|
18 | import org.apache.hivemind.util.Defense; |
|
19 | import org.apache.tapestry.IBinding; |
|
20 | import org.apache.tapestry.binding.AbstractBinding; |
|
21 | import org.apache.tapestry.coerce.ValueConverter; |
|
22 | ||
23 | /** |
|
24 | * Implementation of {@link IBinding} that provides |
|
25 | * {@link org.apache.tapestry.valid.IValidator} instances based on a |
|
26 | * validator bean descriptor. The descriptor is of the form "type[,properties]". |
|
27 | * The types are values such as "string", "date" or "number" defined in the |
|
28 | * tapestry.valid.Validators configuration point. The properties are a |
|
29 | * properties initialization string. |
|
30 | * |
|
31 | * @author Howard M. Lewis Ship |
|
32 | * @since 4.0 |
|
33 | * @see org.apache.hivemind.util.PropertyUtils#configureProperties(java.lang.Object, |
|
34 | * java.lang.String) |
|
35 | */ |
|
36 | public class ValidatorBinding extends AbstractBinding |
|
37 | { |
|
38 | ||
39 | private final IValidator _validator; |
|
40 | ||
41 | public ValidatorBinding(String description, ValueConverter valueConverter, |
|
42 | Location location, IValidator validator) |
|
43 | { |
|
44 | 1 | super(description, valueConverter, location); |
45 | ||
46 | 1 | Defense.notNull(validator, "validator"); |
47 | ||
48 | 1 | _validator = validator; |
49 | 1 | } |
50 | ||
51 | public Object getObject() |
|
52 | { |
|
53 | 1 | return _validator; |
54 | } |
|
55 | ||
56 | } |