View Javadoc

1   package ch.odi.justblog.api;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   import ch.odi.justblog.api.blogger.BloggerApi;
7   
8   /***
9    * The place where APIs are registered.
10   *
11   * @author oglueck
12   */
13  public final class ApiRegistry {
14      private static Map apis = new HashMap();
15      
16      static {
17          internalApis();
18      }
19      
20      /***
21       * Singleton.
22       */
23      private ApiRegistry() {
24      }
25      
26      public static void register(BlogApi api) {
27          apis.put(api.getRsdName().toLowerCase(), api);
28      }
29      
30      public static boolean isSupported(String apiName) {
31          return (get(apiName) != null);
32      }
33      
34      public static BlogApi get(String apiName) {
35          return (BlogApi) apis.get(apiName.toLowerCase());
36      }
37      
38      private static void internalApis() {
39          register(new BloggerApi());
40      }
41  
42  }