1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in 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
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.objmap.annotations.factories;
\r
14 import org.simantics.db.ReadGraph;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.layer0.Layer0;
\r
18 public class DataTypeUtils {
\r
20 public static Resource dataTypeOfClass(ReadGraph g, Class<?> clazz) {
\r
21 Layer0 b = Layer0.getInstance(g);
\r
22 if(clazz.equals(Double.class) || clazz.equals(double.class))
\r
24 else if(clazz.equals(String.class))
\r
26 else if(clazz.equals(Integer.class) || clazz.equals(int.class))
\r
28 else if(clazz.equals(Float.class) || clazz.equals(float.class))
\r
30 else if(clazz.equals(Boolean.class) || clazz.equals(boolean.class))
\r
32 else if(clazz.equals(Long.class) || clazz.equals(long.class))
\r
34 else if(clazz.equals(Byte.class) || clazz.equals(byte.class))
\r
37 else if(clazz.equals(double[].class))
\r
38 return b.DoubleArray;
\r
39 else if(clazz.equals(int[].class))
\r
40 return b.IntegerArray;
\r
41 else if(clazz.equals(byte[].class))
\r
43 else if(clazz.equals(float[].class))
\r
44 return b.FloatArray;
\r
45 else if(clazz.equals(boolean[].class))
\r
46 return b.BooleanArray;
\r
47 else if(clazz.equals(String[].class))
\r
48 return b.StringArray;
\r
49 else if(clazz.equals(long[].class))
\r
52 System.out.println("Couldn't find a data type for " + clazz);
\r