KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > form > translator > StringTranslator


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 JavaDoc _empty = null;
30
31     public StringTranslator()
32     {
33     }
34
35     // Needed until HIVEMIND-134 fix is available
36

37     public StringTranslator(String JavaDoc initializer)
38     {
39         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     protected Object JavaDoc parseText(IFormComponent field, String JavaDoc text)
47     {
48         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     protected String JavaDoc formatObject(IFormComponent field, Object JavaDoc object)
56     {
57         return object.toString();
58     }
59
60     public Object JavaDoc getEmpty()
61     {
62         return _empty;
63     }
64
65     public void setEmpty(String JavaDoc empty)
66     {
67         _empty = empty;
68     }
69
70 }
71
Popular Tags