1 11 package org.eclipse.ui.internal.about; 12 13 import java.util.ArrayList ; 14 import java.util.HashMap ; 15 import java.util.List ; 16 import java.util.Map ; 17 18 23 public class AboutFeaturesButtonManager { 24 private Map providerMap = new HashMap (); 25 26 private static class Key { 27 public String providerName; 28 29 public Long crc; 30 31 34 public Key(String providerName, Long crc) { 35 this.providerName = providerName; 36 this.crc = crc; 37 } 38 39 public boolean equals(Object o) { 40 if (!(o instanceof Key)) { 41 return false; 42 } 43 Key other = (Key) o; 44 if (!providerName.equals(other.providerName)) { 45 return false; 46 } 47 return crc.equals(other.crc); 48 } 49 50 public int hashCode() { 51 return providerName.hashCode(); 52 } 53 } 54 55 59 public boolean add(AboutBundleGroupData info) { 60 Long crc = info.getFeatureImageCrc(); 62 if (crc == null) { 63 return false; 64 } 65 66 String providerName = info.getProviderName(); 67 Key key = new Key(providerName, crc); 68 69 List infoList = (List ) providerMap.get(key); 70 if (infoList != null) { 71 infoList.add(info); 72 return false; 73 } 74 75 infoList = new ArrayList (); 76 infoList.add(info); 77 providerMap.put(key, infoList); 78 return true; 79 } 80 81 85 public AboutBundleGroupData[] getRelatedInfos(AboutBundleGroupData info) { 86 Long crc = info.getFeatureImageCrc(); 88 if (crc == null) { 89 return new AboutBundleGroupData[0]; 90 } 91 92 String providerName = info.getProviderName(); 93 Key key = new Key(providerName, crc); 94 95 List infoList = (List ) providerMap.get(key); 96 if (infoList == null) { 97 return new AboutBundleGroupData[0]; 98 } 99 100 return (AboutBundleGroupData[]) infoList 101 .toArray(new AboutBundleGroupData[0]); 102 } 103 } 104 | Popular Tags |