KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > server > componentsmatch > Package


1
2 package org.netbeans.server.componentsmatch;
3
4 import java.util.Map JavaDoc;
5 import java.util.Set JavaDoc;
6 import java.util.TreeMap JavaDoc;
7
8 /**
9  * Package with assigned components.
10  * @author pzajac
11  */

12 public final class Package {
13     Map JavaDoc<Component,Component> components = new TreeMap JavaDoc<Component,Component>();
14     String JavaDoc name;
15     
16     Component firstComponent;
17     /** Creates a new instance of Package */
18     
19     public Package(String JavaDoc name) {
20         this.name = name;
21     }
22     
23     public void addComponent(Component comp) {
24         Component oldComp = components.get(comp);
25         if (oldComp == null) {
26             components.put(comp,comp);
27         } else {
28             oldComp.add(comp);
29         }
30         firstComponent = null;
31     }
32     
33     /** @return component with bigger issues count
34      */

35     public Component getFirstComponent() {
36         if (firstComponent == null) {
37             for (Component c : components.keySet()) {
38               if (firstComponent == null) {
39                   firstComponent = c;
40               } else if (c.getIssues() > firstComponent.getIssues()) {
41                   firstComponent = c;
42               }
43             }
44         }
45         return firstComponent;
46     }
47     
48     public String JavaDoc getName() {
49         return name;
50     }
51     
52     public Set JavaDoc<Component> getComponents() {
53         return components.keySet();
54     }
55 }
56
Popular Tags