View Javadoc
1   package us.codecraft.webmagic.pipeline;
2   
3   import us.codecraft.webmagic.ResultItems;
4   import us.codecraft.webmagic.Task;
5   
6   import java.util.ArrayList;
7   import java.util.List;
8   
9   /**
10   * @author code4crafter@gmail.com
11   * @since 0.4.0
12   */
13  public class ResultItemsCollectorPipeline implements CollectorPipeline<ResultItems> {
14  
15      private List<ResultItems> collector = new ArrayList<ResultItems>();
16  
17      @Override
18      public synchronized void process(ResultItems resultItems, Task task) {
19          collector.add(resultItems);
20      }
21  
22      @Override
23      public List<ResultItems> getCollected() {
24          return collector;
25      }
26  }