Пример #1
0
  /**
   * Called by loadContents to load a link on the page.
   *
   * @param index The index to begin loading at.
   * @param tag The beginning tag.
   */
  protected final void loadLink(final int index, final Tag tag) {
    final Link link = new Link(this.page);
    final String href = tag.getAttributeValue("href");

    if (href != null) {
      link.setTarget(new Address(this.base, href));
      link.setBegin(index);
      link.setEnd(findEndTag(index + 1, tag));
      this.page.addContent(link);
    }
  }
Пример #2
0
  /**
   * Navigate to a new page based on a link.
   *
   * @param link The link to navigate to.
   */
  public final void navigate(final Link link) {

    final Address address = link.getTarget();

    if (address.getUrl() != null) {
      navigate(address.getUrl());
    } else {
      navigate(address.getOriginal());
    }
  }