]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/binding/factory/TypeRepository.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / binding / factory / TypeRepository.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
3  * Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.databoard.binding.factory;
13
14 import java.util.HashMap;
15 import java.util.Map;
16
17 import org.simantics.databoard.binding.reflection.BindingRequest;
18 import org.simantics.databoard.type.Datatype;
19
20 public class TypeRepository {
21
22         Map<Datatype, BindingRequest> typeMap = new HashMap<Datatype, BindingRequest>();
23         Map<String, BindingRequest> classMap = new HashMap<String, BindingRequest>();
24         
25         public synchronized void put(Datatype type, BindingRequest br) {
26                 typeMap.put(type, br);
27                 classMap.put(br.className.replace('$', '.'), br);
28         }
29         
30         public synchronized boolean containsType( Datatype type ) {
31                 return typeMap.containsKey( type );
32         }
33         
34         public synchronized BindingRequest getRequestForType(Datatype type) {
35                 return typeMap.get(type);
36         }
37         
38         public synchronized BindingRequest getRequest(String className) {
39                 if (className.indexOf('$')>=0) className = className.replace('$', '.');
40                 return classMap.get(className);
41         }
42         
43 }