|
|||||||||||||||||||
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
FieldTracking.java | - | 100% | 100% | 100% |
|
1 | // Copyright 2004, 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 java.io.Serializable; | |
18 | ||
19 | import org.apache.hivemind.util.Defense; | |
20 | import org.apache.tapestry.IRender; | |
21 | import org.apache.tapestry.form.IFormComponent; | |
22 | ||
23 | /** | |
24 | * Default implementation of {@link IFieldTracking}. | |
25 | * | |
26 | * @author Howard Lewis Ship | |
27 | * @since 1.0.8 | |
28 | */ | |
29 | ||
30 | public class FieldTracking implements IFieldTracking, Serializable | |
31 | { | |
32 | private static final long serialVersionUID = -5397563163968532716L; | |
33 | ||
34 | private transient IFormComponent _component; | |
35 | ||
36 | private String _input; | |
37 | ||
38 | private IRender _renderer; | |
39 | ||
40 | private String _fieldName; | |
41 | ||
42 | private ValidationConstraint _constraint; | |
43 | ||
44 | /** | |
45 | * Constructor used for unassociated errors; errors that are not about any particular field | |
46 | * within the form. | |
47 | */ | |
48 | ||
49 | 1 | FieldTracking() |
50 | { | |
51 | } | |
52 | ||
53 | /** | |
54 | * Standard constructor for a field (with the given name), rendered by the specified component. | |
55 | */ | |
56 | ||
57 | 12 | FieldTracking(String fieldName, IFormComponent component) |
58 | { | |
59 | 12 | Defense.notNull(fieldName, "fieldName"); |
60 | 12 | Defense.notNull(component, "component"); |
61 | ||
62 | 12 | _fieldName = fieldName; |
63 | 12 | _component = component; |
64 | } | |
65 | ||
66 | 8 | public IFormComponent getComponent() |
67 | { | |
68 | 8 | return _component; |
69 | } | |
70 | ||
71 | 15 | public IRender getErrorRenderer() |
72 | { | |
73 | 15 | return _renderer; |
74 | } | |
75 | ||
76 | 10 | public void setErrorRenderer(IRender value) |
77 | { | |
78 | 10 | _renderer = value; |
79 | } | |
80 | ||
81 | 5 | public String getInput() |
82 | { | |
83 | 5 | return _input; |
84 | } | |
85 | ||
86 | 10 | public void setInput(String value) |
87 | { | |
88 | 10 | _input = value; |
89 | } | |
90 | ||
91 | 9 | public String getFieldName() |
92 | { | |
93 | 9 | return _fieldName; |
94 | } | |
95 | ||
96 | 3 | public ValidationConstraint getConstraint() |
97 | { | |
98 | 3 | return _constraint; |
99 | } | |
100 | ||
101 | 10 | public void setConstraint(ValidationConstraint constraint) |
102 | { | |
103 | 10 | _constraint = constraint; |
104 | } | |
105 | ||
106 | /** @since 3.0 * */ | |
107 | ||
108 | 13 | public boolean isInError() |
109 | { | |
110 | 13 | return _renderer != null; |
111 | } | |
112 | ||
113 | } |
|