1 19 20 28 29 package org.netbeans.modules.xml.retriever; 30 31 import java.net.URISyntaxException ; 32 import java.util.ArrayList ; 33 import java.util.List ; 34 35 39 public class ResourceRetrieverFactory { 40 private static ArrayList <ResourceRetriever> registeredResourceRetrievers = new ArrayList <ResourceRetriever>(); 41 42 static{ 43 registeredResourceRetrievers.add(new FileResourceRetriever()); 44 registeredResourceRetrievers.add(new URLResourceRetriever()); 45 registeredResourceRetrievers.add(new SecureURLResourceRetriever()); 46 } 47 48 public static ResourceRetriever getResourceRetriever(String baseAddress, String address) throws URISyntaxException { 49 for(ResourceRetriever retriever: registeredResourceRetrievers){ 50 if(retriever.accept(baseAddress, address)) 51 return retriever; 52 } 53 return null; 54 } 55 56 public static List <ResourceRetriever>getRegisteredResourceRetrievers(){ 57 return (List <ResourceRetriever>) registeredResourceRetrievers; 58 } 59 60 public static boolean removeRegisteredResourceRetriever(ResourceRetriever oldResourceRetriever){ 61 return registeredResourceRetrievers.remove(oldResourceRetriever); 62 } 63 64 public static void addResourceRetriever(ResourceRetriever newResourceRetriever){ 65 registeredResourceRetrievers.add(newResourceRetriever); 66 } 67 68 69 } 70 | Popular Tags |