View Javadoc
1   package com.ljs.ootp.extract.html;
2   
3   import com.ljs.ootp.extract.html.loader.PageLoader;
4   import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
5   import org.jsoup.nodes.Document;
6   
7   /**
8    *
9    * @author lstephen
10   */
11  public final class UrlLoadingPage implements Page {
12  
13      private final String url;
14  
15      private final PageLoader loader;
16  
17      private UrlLoadingPage(String url, PageLoader loader) {
18          this.url = url;
19          this.loader = loader;
20      }
21  
22      @Override
23      public Document load() {
24          return loader.load(url);
25      }
26  
27      @Override
28      public String toString() {
29          return ReflectionToStringBuilder.reflectionToString(this);
30      }
31  
32      public static Loading using(final PageLoader loader) {
33          return new Loading() {
34              @Override
35              public UrlLoadingPage loading(String url) {
36                  return new UrlLoadingPage(url, loader);
37              }
38          };
39      }
40  
41      public interface Loading {
42          UrlLoadingPage loading(String url);
43      }
44  
45  }