|
|||||||||||||||||||
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 | |||||||||||||||
StringTranslator.java | - | 80% | 83.3% | 81.8% |
|
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 org.apache.tapestry.form.IFormComponent; | |
18 | ||
19 | /** | |
20 | * A trivial {@link Translator} implementation. By default, empty text submissions are interpretted | |
21 | * as null. | |
22 | * | |
23 | * @author Paul Ferraro | |
24 | * @since 4.0 | |
25 | */ | |
26 | public class StringTranslator extends AbstractTranslator | |
27 | { | |
28 | ||
29 | private String _empty = null; | |
30 | ||
31 | 8 | public StringTranslator() |
32 | { | |
33 | } | |
34 | ||
35 | // Needed until HIVEMIND-134 fix is available | |
36 | ||
37 | 0 | public StringTranslator(String initializer) |
38 | { | |
39 | 0 | super(initializer); |
40 | } | |
41 | ||
42 | /** | |
43 | * @see org.apache.tapestry.form.translator.AbstractTranslator#parseText(org.apache.tapestry.form.IFormComponent, | |
44 | * java.lang.String) | |
45 | */ | |
46 | 2 | protected Object parseText(IFormComponent field, String text) |
47 | { | |
48 | 2 | return text; |
49 | } | |
50 | ||
51 | /** | |
52 | * @see org.apache.tapestry.form.translator.AbstractTranslator#formatObject(org.apache.tapestry.form.IFormComponent, | |
53 | * java.lang.Object) | |
54 | */ | |
55 | 1 | protected String formatObject(IFormComponent field, Object object) |
56 | { | |
57 | 1 | return object.toString(); |
58 | } | |
59 | ||
60 | 2 | public Object getEmpty() |
61 | { | |
62 | 2 | return _empty; |
63 | } | |
64 | ||
65 | 1 | public void setEmpty(String empty) |
66 | { | |
67 | 1 | _empty = empty; |
68 | } | |
69 | ||
70 | } |
|