Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||
Translator |
|
| 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.form.translator; |
|
16 | ||
17 | import java.util.Locale; |
|
18 | ||
19 | import org.apache.tapestry.form.FormComponentContributor; |
|
20 | import org.apache.tapestry.form.IFormComponent; |
|
21 | import org.apache.tapestry.form.ValidatableField; |
|
22 | import org.apache.tapestry.form.ValidationMessages; |
|
23 | import org.apache.tapestry.valid.ValidatorException; |
|
24 | ||
25 | /** |
|
26 | * Interface used by {@link ValidatableField}s to both format an object as text and translate |
|
27 | * submitted text into an appropriate object for a given field. |
|
28 | * |
|
29 | * @author Paul Ferraro |
|
30 | * @since 4.0 |
|
31 | */ |
|
32 | public interface Translator extends FormComponentContributor |
|
33 | { |
|
34 | /** |
|
35 | * Invoked during rendering to format an object (which may be null) into a text value (which |
|
36 | * should not be null) appropriate for the specified field. |
|
37 | * @param locale TODO |
|
38 | */ |
|
39 | String format(IFormComponent field, Locale locale, Object object); |
|
40 | ||
41 | /** |
|
42 | * Invoked during rewind to parse a submitted input value into an object suitable for the |
|
43 | * specified component. |
|
44 | * @param messages TODO |
|
45 | * |
|
46 | * @return the parsed object |
|
47 | * @throws ValidatorException |
|
48 | * if the specified text could not be parsed into an object. |
|
49 | */ |
|
50 | Object parse(IFormComponent field, ValidationMessages messages, String value) throws ValidatorException; |
|
51 | } |