1 /*******************************************************************************
2 * Copyright (c) 2007, 2013 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.objmap.graph.annotations.factories;
14 import org.simantics.db.ReadGraph;
15 import org.simantics.db.Resource;
16 import org.simantics.layer0.Layer0;
18 public class DataTypeUtils {
20 public static Resource dataTypeOfClass(ReadGraph g, Class<?> clazz) {
21 Layer0 b = Layer0.getInstance(g);
22 if(clazz.equals(Double.class) || clazz.equals(double.class))
24 else if(clazz.equals(String.class))
26 else if(clazz.equals(Integer.class) || clazz.equals(int.class))
28 else if(clazz.equals(Float.class) || clazz.equals(float.class))
30 else if(clazz.equals(Boolean.class) || clazz.equals(boolean.class))
32 else if(clazz.equals(Long.class) || clazz.equals(long.class))
34 else if(clazz.equals(Byte.class) || clazz.equals(byte.class))
37 else if(clazz.equals(double[].class))
39 else if(clazz.equals(int[].class))
40 return b.IntegerArray;
41 else if(clazz.equals(byte[].class))
43 else if(clazz.equals(float[].class))
45 else if(clazz.equals(boolean[].class))
46 return b.BooleanArray;
47 else if(clazz.equals(String[].class))
49 else if(clazz.equals(long[].class))
52 System.out.println("Couldn't find a data type for " + clazz);