1 | else↵ | | 1 | protected IConverter createConverter(Object fromType, Object toType)↵
|
| | | 2 | {↵
|
2 | if (toType == String.class)↵ | | 3 | if (fromType == String.class)↵
|
3 | {↵ | | 4 | {↵
|
4 | if (fromType instanceof EAttribute)↵ | | 5 | if (toType instanceof EAttribute)↵
|
5 | {↵ | | 6 | {↵
|
6 | final EAttribute eAttribute = (EAttribute)fromType;↵ | | 7 | final EAttribute eAttribute = (EAttribute)toType;↵
|
7 | final EDataType eDataType = eAttribute.getEAttributeType();↵ | | 8 | final EDataType eDataType = eAttribute.getEAttributeType();↵
|
8 | final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance();↵ | | 9 | final EFactory eFactory = eDataType.getEPackage().getEFactoryInstance();↵
|
9 | return↵ | | 10 | return↵
|
10 | new Converter(fromType, toType)↵ | | 11 | new Converter(fromType, toType)↵
|
11 | {↵ | | 12 | {↵
|
12 | public Object convert(Object fromObject)↵ | | 13 | public Object convert(Object fromObject)↵
|
13 | {↵ | | 14 | {↵
|
14 | return eFactory.convertToString(eDataType, fromObject↵ | | 15 | String value = fromObject == null ? null : fromObject.toString();↵
|
| | | 16 | if (eAttribute.isMany())↵
|
| | | 17 | {↵
|
| | | 18 | List<Object> result = new ArrayList<Object>();↵
|
| | | 19 | if (value != null)↵
|
| | | 20 | {↵
|
| | | 21 | for (String element : value.split(" "))↵
|
| | | 22 | {↵
|
| | | 23 | result.add(eFactory.createFromString(eDataType, element));↵
|
| | | 24 | }↵
|
| | | 25 | }↵
|
| | | 26 | return result;↵
|
| | | 27 | }↵
|
| | | 28 | else↵
|
| | | 29 | {↵
|
15 | );↵ | | 30 | return eFactory.createFromString(eDataType, value);↵
|
16 | | | 31 |
|