Package org.htmlparser.tags

Examples of org.htmlparser.tags.BaseHrefTag


    {
        String html = "<base target=\"_top\">";
        createParser(html);
        parseAndAssertNodeCount(1);
        assertTrue("Should be a base tag but was "+node[0].getClass().getName(),node[0] instanceof BaseHrefTag);
        BaseHrefTag baseTag = (BaseHrefTag)node[0];
        assertStringEquals("Base Tag HTML", html, baseTag.toHtml());
    }
View Full Code Here


  public BaseHrefTagTest(String name) {
    super(name);
  }

  public void testConstruction() {
    BaseHrefTag baseRefTag = new BaseHrefTag(new TagData(0, 0, "", ""), "http://www.abc.com");
    assertEquals("Expected Base URL", "http://www.abc.com", baseRefTag.getBaseUrl());
  }
View Full Code Here

  public void testNotHREFBaseTag() throws ParserException {
    createParser("<base target=\"_top\">");
    parser.registerScanners();
    parseAndAssertNodeCount(1);
    assertTrue("Should be a base tag but was " + node[0].getClass().getName(), node[0] instanceof BaseHrefTag);
    BaseHrefTag baseTag = (BaseHrefTag) node[0];
    assertStringEquals("Base Tag HTML", "<BASE TARGET=\"_top\">", baseTag.toHtml());
  }
View Full Code Here

    parser.addScanner(new TitleScanner("-t"));
    parser.addScanner(linkScanner.createBaseHREFScanner("-b"));
    parseAndAssertNodeCount(7);
    // Base href tag should be the 4th tag
    assertTrue(node[3] instanceof BaseHrefTag);
    BaseHrefTag baseRefTag = (BaseHrefTag) node[3];
    assertEquals("Base HREF Url", "http://www.abc.com", baseRefTag.getBaseUrl());
  }
View Full Code Here

    String absoluteBaseUrl = "";
    if (baseUrl != null && baseUrl.length() > 0) {
      absoluteBaseUrl = LinkProcessor.removeLastSlash(baseUrl.trim());
      processor.setBaseUrl(absoluteBaseUrl);
    }
    return new BaseHrefTag(tagData, absoluteBaseUrl);
  }
View Full Code Here

          // is probably a mistake. Plus it's bad to
          // have important content after the closing
          // body tag. Peter Lin 10-9-03
          e = body.elements();
        } else if (node instanceof BaseHrefTag) {
          BaseHrefTag baseHref = (BaseHrefTag) node;
          String baseref = baseHref.getBaseUrl().toString();
          try {
            if (!baseref.equals(""))// Bugzilla 30713
            {
              baseUrl = new URL(baseUrl, baseHref.getBaseUrl() + "/");
            }
          } catch (MalformedURLException e1) {
            throw new HTMLParseException(e1);
          }
        } else if (node instanceof ImageTag) {
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.BaseHrefTag

Copyright © 2018 www.massapicom. 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.