01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.wicket.util.convert;
18:
19: import java.util.Date;
20: import java.util.Locale;
21:
22: import org.apache.wicket.IClusterable;
23:
24: /**
25: * Converts input to output and vice versa. Converters are needed in web
26: * applications because we have to switch between Java objects on the server and
27: * Strings in the browser output and input.
28: * <p>
29: * Output conversion, which is handled by
30: * {@link #convertToString(Object, Locale)}, is typically used by components
31: * when they render, so that a date can be displayed as '12/12/2007'. Input
32: * conversion, handled by {@link #convertToObject(String, Locale)}, is
33: * typically used by form components to interpret incoming values Such values
34: * are strings as they are send as request parameters from browsers. An incoming
35: * value could be the string '12/12/2007' which could be translated to a
36: * corresponding {@link Date} object.
37: * </p>
38: *
39: * @author Eelco Hillenius
40: * @author Jonathan Locke
41: */
42: public interface IConverter extends IClusterable {
43: /**
44: * Converts the given {@link String} value
45: *
46: * @param value
47: * The string value to convert
48: * @param locale
49: * The locale used to convert the value
50: * @return The converted value
51: */
52: Object convertToObject(String value, Locale locale);
53:
54: /**
55: * Converts the given value to a string.
56: *
57: * @param value
58: * The value to convert
59: * @param locale
60: * The locale used to convert the value
61: *
62: * @return The converted string value
63: */
64: String convertToString(Object value, Locale locale);
65: }
|