svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / feature / AbstractDataProfile.java @ 46517
History | View | Annotate | Download (2.02 KB)
1 | 44189 | jjdelcerro | package org.gvsig.fmap.dal.feature; |
---|---|---|---|
2 | |||
3 | 46419 | fdiaz | import org.gvsig.fmap.dal.DALLocator; |
4 | import org.gvsig.fmap.dal.DataManager; |
||
5 | import org.gvsig.tools.dataTypes.CoercionException; |
||
6 | import org.gvsig.tools.dataTypes.DataType; |
||
7 | import org.gvsig.tools.dynobject.Tags; |
||
8 | import org.slf4j.Logger; |
||
9 | import org.slf4j.LoggerFactory; |
||
10 | |||
11 | 44189 | jjdelcerro | /**
|
12 | *
|
||
13 | * @author jjdelcerro
|
||
14 | */
|
||
15 | public abstract class AbstractDataProfile implements DataProfile { |
||
16 | |||
17 | 46419 | fdiaz | protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractDataProfile.class); |
18 | |||
19 | 44253 | jjdelcerro | private final String id; |
20 | 44189 | jjdelcerro | private final String name; |
21 | private final Class dataClass; |
||
22 | 46419 | fdiaz | private final DataProfile delegated; |
23 | 44189 | jjdelcerro | |
24 | 44253 | jjdelcerro | public AbstractDataProfile(String id, String name, Class dataClass) { |
25 | this.id = id;
|
||
26 | 44189 | jjdelcerro | this.name = name;
|
27 | this.dataClass = dataClass;
|
||
28 | 46419 | fdiaz | DataManager dataManager = DALLocator.getDataManager(); |
29 | this.delegated = dataManager.getDataProfile(id);
|
||
30 | 44189 | jjdelcerro | } |
31 | 44253 | jjdelcerro | |
32 | public AbstractDataProfile(String name, Class dataClass) { |
||
33 | this(name, name, dataClass);
|
||
34 | } |
||
35 | |||
36 | 44189 | jjdelcerro | @Override
|
37 | 44253 | jjdelcerro | public String getID() { |
38 | return this.id; |
||
39 | } |
||
40 | |||
41 | @Override
|
||
42 | 44189 | jjdelcerro | public String getName() { |
43 | return this.name; |
||
44 | } |
||
45 | |||
46 | @Override
|
||
47 | public Class getDataClass() { |
||
48 | return this.dataClass; |
||
49 | } |
||
50 | |||
51 | 46419 | fdiaz | @Override
|
52 | public Object createData(Object data, Tags tags) { |
||
53 | Object x = this.doCreateData(data, tags); |
||
54 | if(x == null && this.delegated != null){ |
||
55 | x = this.delegated.createData(data, tags);
|
||
56 | } |
||
57 | return x;
|
||
58 | } |
||
59 | |||
60 | protected Object doCreateData(Object data, Tags tags) { |
||
61 | return null; |
||
62 | } |
||
63 | |||
64 | @Override
|
||
65 | public Object coerce(DataType dataType, Object value, Tags tags) throws CoercionException { |
||
66 | Object x = this.doCoerce(dataType, value, tags); |
||
67 | if(x == null && this.delegated != null){ |
||
68 | x = this.delegated.coerce(dataType, value, tags);
|
||
69 | } |
||
70 | return x;
|
||
71 | } |
||
72 | |||
73 | protected Object doCoerce(DataType dataType, Object value, Tags tags) throws CoercionException { |
||
74 | return null; |
||
75 | } |
||
76 | |||
77 | |||
78 | 44189 | jjdelcerro | } |