View Javadoc
1   package com.ljs.ootp.extract.html;
2   
3   import com.ljs.ootp.extract.html.loader.JsoupLoader;
4   import com.ljs.ootp.extract.html.loader.DiskCachingLoader;
5   import com.ljs.ootp.extract.html.loader.PageLoader;
6   import com.ljs.ootp.extract.html.loader.InMemoryCachedLoader;
7   
8   /**
9    *
10   * @author lstephen
11   */
12  public final class PageFactory {
13  
14      private static final PageLoader DEFAULT_PAGE_LOADER =
15          InMemoryCachedLoader.wrap(
16              DiskCachingLoader.wrap(
17                  new JsoupLoader()));
18  
19      private final PageLoader loader;
20  
21      private PageFactory(PageLoader loader) {
22          this.loader = loader;
23      }
24  
25      public Page getPage(String root, String page) {
26          return UrlLoadingPage.using(loader).loading(root + page);
27      }
28  
29      public static PageFactory create() {
30          return create(DEFAULT_PAGE_LOADER);
31      }
32  
33      public static PageFactory create(PageLoader loader) {
34          return new PageFactory(loader);
35      }
36  
37  }