/**
 * 
 */
package helper;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Hashtable;

/**
 * @author aquast
 *
 */
public interface LabelResolver {

    public String lookup(String urlString, String Language);

    public static class Factory {

        private static Hashtable<String, LabelResolver> lResolver = new Hashtable<String, LabelResolver>();

        public static LabelResolver getInstance(String urlString) {
            LabelResolver lResolv = null;
            URL url = createUrlFromString(urlString);
            play.Logger.debug("Domain extracted from urlString: " + url.getHost());
            lResolv = getLabelResolver(url.getHost());

            return lResolv;
        }

        public static boolean existsLabelResolver(String urlString) {
            URL url = createUrlFromString(urlString);
            return lResolver.containsKey(url.getHost());
        }

        private static URL createUrlFromString(String urlString) {
            URL url = null;
            try {
                url = new URL(urlString);
            } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return url;
        }

        private static LabelResolver getLabelResolver(String domain) {

            // put all known Class that implements the Interface into Hashtable
            lResolver.put(CrossrefLabelResolver.DOMAIN, new CrossrefLabelResolver());
            lResolver.put(OrcidLabelResolver.DOMAIN, new OrcidLabelResolver());
            lResolver.put(GeonamesLabelResolver.DOMAIN, new GeonamesLabelResolver());
            lResolver.put(GndLabelResolver.DOMAIN, new GndLabelResolver());
            lResolver.put(OpenStreetMapLabelResolver.DOMAIN, new OpenStreetMapLabelResolver());
            lResolver.put(LobidLabelResolver.DOMAIN, new LobidLabelResolver());

            // return LabelResolver in accordance to the Domain requested
            return lResolver.get(domain);
        }

    }

}

@@ -275,117 +275,8 @@
  %7B%0A%0A
-        private static Hashtable%3CString, LabelResolver%3E lResolver = new Hashtable%3CString, LabelResolver%3E();%0A%0A
     
@@ -749,32 +749,39 @@
          return 
+getLabe
 lResolver.contai
@@ -773,16 +773,23 @@
 Resolver
+Table()
 .contain
@@ -1178,24 +1178,42 @@
 ivate static
+ Hashtable%3CString,
  LabelResolv
@@ -1210,24 +1210,25 @@
 abelResolver
+%3E
  getLabelRes
@@ -1236,26 +1236,115 @@
 lver
-(String domain) %7B%0A
+Table() %7B%0A%0A            Hashtable%3CString, LabelResolver%3E lResolver = new Hashtable%3CString, LabelResolver%3E();
 %0A   
@@ -1920,25 +1920,24 @@
 esolver());%0A
-%0A
             
@@ -1939,19 +1939,16 @@
     
- //
  return 
 Labe
@@ -1943,20 +1943,16 @@
  return 
-Labe
 lResolve
@@ -1956,46 +1956,91 @@
 lver
- in accordance to the Domain requested
+;%0A        %7D%0A%0A        private static LabelResolver getLabelResolver(String domain) %7B
 %0A   
@@ -2047,32 +2047,39 @@
          return 
+getLabe
 lResolver.get(do
@@ -2071,16 +2071,23 @@
 Resolver
+Table()
 .get(dom

make Hashtable lResolver accessible to all methods