Merge branch 'features/r2_11_2/JAL-3821_reinstate_patch' into develop
[jalview.git] / unused / javajs / util / AjaxURLStreamHandlerFactory.java
1 package javajs.util;
2
3 import java.net.URLStreamHandler;
4 import java.net.URLStreamHandlerFactory;
5 import java.util.Hashtable;
6 import java.util.Map;
7
8
9 /**
10  * 
11  * For handling URL file IO via AJAX in JavaScript version
12  * 
13  */
14
15 public class AjaxURLStreamHandlerFactory implements URLStreamHandlerFactory {
16
17         Map<String, AjaxURLStreamHandler> htFactories = new Hashtable<String, AjaxURLStreamHandler>();
18         
19         public AjaxURLStreamHandlerFactory() {
20          // for reflection;
21         }
22         
23         @Override
24   public URLStreamHandler createURLStreamHandler(String protocol) {
25                 AjaxURLStreamHandler fac = htFactories.get(protocol);
26                 if (fac == null)
27                         htFactories.put(protocol, fac = new AjaxURLStreamHandler(protocol));
28                 return (fac.protocol == null ? null : fac);
29         }
30
31 }