KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > components > registry > ComponentTypeMap


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.components.registry;
12
13 import java.util.Collection JavaDoc;
14 import java.util.HashMap JavaDoc;
15 import java.util.Map JavaDoc;
16
17 import org.eclipse.ui.internal.components.framework.ClassIdentifier;
18
19 /**
20  * @since 3.1
21  */

22 public class ComponentTypeMap {
23    
24     /**
25      * map of String (fully qualified class names) onto List. The Lists cont
26      */

27     private Map JavaDoc types = new HashMap JavaDoc();
28     private Map JavaDoc keys = new HashMap JavaDoc();
29     
30     public void put(ClassIdentifier key, Object JavaDoc value) {
31         types.put(key.getTypeName(), value);
32         keys.put(key.getTypeName(), key);
33     }
34     
35     public Object JavaDoc get(Class JavaDoc key) {
36         return types.get(key.getName());
37     }
38     
39     public Object JavaDoc get(ClassIdentifier key) {
40         return types.get(key.getTypeName());
41     }
42     
43     public void remove(ClassIdentifier key) {
44         types.remove(key.getTypeName());
45         keys.remove(key.getTypeName());
46     }
47     
48     public ClassIdentifier[] getTypes() {
49         Collection JavaDoc keys = this.keys.values();
50         
51         return (ClassIdentifier[]) keys.toArray(new ClassIdentifier[keys.size()]);
52     }
53
54     public boolean containsKey(Class JavaDoc key) {
55         return types.containsKey(key.getName());
56     }
57     
58     /**
59      * @since 3.1
60      *
61      * @return
62      */

63     public boolean isEmpty() {
64         return types.isEmpty();
65     }
66     
67 }
68
Popular Tags