1 19 20 package org.netbeans.lib.editor.hyperlink; 21 22 import java.util.ArrayList ; 23 import java.util.Collections ; 24 import java.util.HashMap ; 25 import java.util.List ; 26 import java.util.Map ; 27 import org.netbeans.lib.editor.hyperlink.spi.HyperlinkProvider; 28 29 37 public class DefaultHyperlinkProviderManager extends HyperlinkProviderManager { 38 39 private Map mimeType2providerList = new HashMap (); 40 41 47 public synchronized void addHyperlinkProvider(String mimeType, HyperlinkProvider provider) { 48 getProviderList(mimeType, true).add(provider); 49 } 50 51 57 public synchronized void removeHyperlinkProvider(String mimeType, HyperlinkProvider provider) { 58 List providerList = getProviderList(mimeType, false); 59 if (providerList != null) { 60 providerList.remove(provider); 61 } 62 } 63 64 public synchronized List getHyperlinkProviders(String mimeType) { 65 List providers = getProviderList(mimeType, false); 66 return (providers != null) ? providers : Collections.EMPTY_LIST; 67 } 68 69 private List getProviderList(String mimeType, boolean forceCreation) { 70 List providerList = (List )mimeType2providerList.get(mimeType); 71 if (providerList == null && forceCreation) { 72 providerList = new ArrayList (); 73 mimeType2providerList.put(mimeType, providerList); 74 } 75 return providerList; 76 } 77 78 } 79 | Popular Tags |