--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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.databoard.binding.factory;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.simantics.databoard.binding.reflection.BindingRequest;\r
+import org.simantics.databoard.type.Datatype;\r
+\r
+public class TypeRepository {\r
+\r
+ Map<Datatype, BindingRequest> typeMap = new HashMap<Datatype, BindingRequest>();\r
+ Map<String, BindingRequest> classMap = new HashMap<String, BindingRequest>();\r
+ \r
+ public synchronized void put(Datatype type, BindingRequest br) {\r
+ typeMap.put(type, br);\r
+ classMap.put(br.className.replace('$', '.'), br);\r
+ }\r
+ \r
+ public synchronized boolean containsType( Datatype type ) {\r
+ return typeMap.containsKey( type );\r
+ }\r
+ \r
+ public synchronized BindingRequest getRequestForType(Datatype type) {\r
+ return typeMap.get(type);\r
+ }\r
+ \r
+ public synchronized BindingRequest getRequest(String className) {\r
+ if (className.indexOf('$')>=0) className = className.replace('$', '.');\r
+ return classMap.get(className);\r
+ }\r
+ \r
+}\r