Package net.vidageek.crawler.page

Source Code of net.vidageek.crawler.page.OkPage

/**
*
*/
package net.vidageek.crawler.page;

import java.util.ArrayList;
import java.util.List;

import net.vidageek.crawler.Page;
import net.vidageek.crawler.Status;
import net.vidageek.crawler.link.DefaultLinkFinder;
import net.vidageek.crawler.link.FrameLinkFinder;
import net.vidageek.crawler.link.IframeLinkFinder;

/**
* @author jonasabreu
*
*/
public class OkPage implements Page {

  private final String url;
  private final String content;

  public OkPage(final String url, final String content) {
    if ((url == null) || (url.trim().length() == 0)) {
      throw new IllegalArgumentException("url cannot be null");
    }
    this.url = url;
    this.content = content;
  }

  public List<String> getLinks() {

    List<String> list = new ArrayList<String>();
    list.addAll(new DefaultLinkFinder(content).getLinks());
    list.addAll(new IframeLinkFinder(content).getLinks());
    list.addAll(new FrameLinkFinder(content).getLinks());

    return list;
  }

  public String getUrl() {
    return url;
  }

  public String getContent() {
    return content;
  }

  public Status getStatusCode() {
    return Status.OK;
  }

  public String getCharset() {
    return "UTF-8";
  }
}
TOP

Related Classes of net.vidageek.crawler.page.OkPage

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.