01: /*
02: * Created on 2 Aug 2007
03: */
04: package uk.org.ponder.mapping;
05:
06: /** Declaration of a policy on data conversion, applicable by the
07: * {@link DARApplier} for incoming requests, as well as for calls to
08: * {@link DARApplier#getFlattenedValue(String, Object, Class, uk.org.ponder.beanutil.BeanResolver).
09: * Note that this is somewhat similar to the Spring structure PropertyEditorRegistry,
10: * but has slightly different semantics, as well as accepting other forms of
11: * converters than PropertyEditors.
12: *
13: * @author Antranig Basman (amb26@ponder.org.uk)
14: *
15: */
16:
17: public class DataConverter {
18: private Class targetClass;
19:
20: private String targetPath;
21:
22: private Object converter;
23:
24: private String converterEL;
25:
26: public Class getTargetClass() {
27: return targetClass;
28: }
29:
30: /** If set, the converter will apply to all classes of the specified type
31: * targetted within the model. At least one of this property and {@link #setTargetPath(String)} must be set.
32: * If they are <i>both</i> set, the interpretation of targetPath is of a
33: * <i>relative</i> path to any instance of the specified class discovered.
34: */
35: public void setTargetClass(Class targetClass) {
36: this .targetClass = targetClass;
37: }
38:
39: public String getTargetPath() {
40: return targetPath;
41: }
42:
43: /** If set, the converter will apply to beans at the specified path
44: * expression which are targetted within the model. This path expression
45: * may contain wildcard segments such as .*.
46: * @param targetPath
47: */
48: public void setTargetPath(String targetPath) {
49: this .targetPath = targetPath;
50: }
51:
52: public Object getConverter() {
53: return converter;
54: }
55:
56: /** Some Object which can be converted to a DARReshaper or BeanResolver -
57: * supported are PropertyEditor and LeafObjectParser.
58: * @param converter
59: */
60: public void setConverter(Object converter) {
61: this .converter = converter;
62: }
63:
64: public String getConverterEL() {
65: return converterEL;
66: }
67:
68: /** An EL path from which the converter can be fetched **/
69: public void setConverterEL(String converterEL) {
70: this.converterEL = converterEL;
71: }
72: }
|