]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling/src/org/simantics/modeling/userComponent/TypeConversion.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / userComponent / TypeConversion.java
1 /*******************************************************************************\r
2  * Copyright (c) 2012 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.modeling.userComponent;\r
13 \r
14 import gnu.trove.map.hash.THashMap;\r
15 \r
16 import org.simantics.databoard.Datatypes;\r
17 import org.simantics.databoard.type.ArrayType;\r
18 import org.simantics.databoard.type.Datatype;\r
19 \r
20 public class TypeConversion {\r
21 \r
22         private static final THashMap<String,Datatype> CONVERSION_MAP = \r
23                         new THashMap<String,Datatype>();\r
24         \r
25         private static void add(String sclType, Datatype dataType) {\r
26                 CONVERSION_MAP.put(sclType, dataType);\r
27                 CONVERSION_MAP.put("[" + sclType + "]", new ArrayType(dataType));\r
28                 CONVERSION_MAP.put("Array " + sclType, new ArrayType(dataType));\r
29                 CONVERSION_MAP.put("Vector " + sclType, new ArrayType(dataType));\r
30         }\r
31         \r
32         static {\r
33                 add("Boolean", Datatypes.BOOLEAN);\r
34                 add("Integer", Datatypes.INTEGER);\r
35                 add("Long", Datatypes.LONG);\r
36                 add("Float", Datatypes.FLOAT);\r
37                 add("Double", Datatypes.DOUBLE);\r
38                 add("String", Datatypes.STRING);\r
39         }\r
40         \r
41         /**\r
42          * This is a workaround solution currently for converting SCL types\r
43          * to datatypes.\r
44          */\r
45         public static Datatype convertSCLTypeToDatatype(String type) {\r
46                 return CONVERSION_MAP.get(type);\r
47         }\r
48         \r
49 }\r