]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/userComponent/TypeConversion.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/userComponent/TypeConversion.java
new file mode 100644 (file)
index 0000000..274e65b
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************\r
+ * Copyright (c) 2012 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modeling.userComponent;\r
+\r
+import gnu.trove.map.hash.THashMap;\r
+\r
+import org.simantics.databoard.Datatypes;\r
+import org.simantics.databoard.type.ArrayType;\r
+import org.simantics.databoard.type.Datatype;\r
+\r
+public class TypeConversion {\r
+\r
+       private static final THashMap<String,Datatype> CONVERSION_MAP = \r
+                       new THashMap<String,Datatype>();\r
+       \r
+       private static void add(String sclType, Datatype dataType) {\r
+               CONVERSION_MAP.put(sclType, dataType);\r
+               CONVERSION_MAP.put("[" + sclType + "]", new ArrayType(dataType));\r
+               CONVERSION_MAP.put("Array " + sclType, new ArrayType(dataType));\r
+               CONVERSION_MAP.put("Vector " + sclType, new ArrayType(dataType));\r
+       }\r
+       \r
+       static {\r
+               add("Boolean", Datatypes.BOOLEAN);\r
+               add("Integer", Datatypes.INTEGER);\r
+               add("Long", Datatypes.LONG);\r
+               add("Float", Datatypes.FLOAT);\r
+               add("Double", Datatypes.DOUBLE);\r
+               add("String", Datatypes.STRING);\r
+       }\r
+       \r
+       /**\r
+        * This is a workaround solution currently for converting SCL types\r
+        * to datatypes.\r
+        */\r
+       public static Datatype convertSCLTypeToDatatype(String type) {\r
+               return CONVERSION_MAP.get(type);\r
+       }\r
+       \r
+}\r