KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > internal > module > CyclicDependencyHashMap


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.osgi.internal.module;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.HashMap JavaDoc;
15
16 public class CyclicDependencyHashMap {
17     private HashMap JavaDoc internal = new HashMap JavaDoc();
18
19     // Cyclic dependencies
20
Object JavaDoc put(ResolverBundle dependentOn, ResolverBundle module) {
21         ArrayList JavaDoc existing = (ArrayList JavaDoc) internal.get(dependentOn);
22         if (existing == null) {
23             ArrayList JavaDoc v = new ArrayList JavaDoc();
24             v.add(module);
25             internal.put(dependentOn, v);
26         } else {
27             if (!existing.contains(module)) {
28                 existing.add(module);
29             }
30         }
31         return null;
32     }
33
34     ArrayList JavaDoc remove(ResolverBundle dependentOn) {
35         return (ArrayList JavaDoc) internal.remove((Object JavaDoc) dependentOn);
36     }
37 }
38
Popular Tags