Package org.encog.parse.tags

Examples of org.encog.parse.tags.Tag


    while (count < this.page.getDataSize()) {
      final DataUnit du = this.page.getDataUnit(count);

      if (du instanceof TagDataUnit) {
        final Tag nextTag = ((TagDataUnit) du).getTag();
        if (tag.getName().equalsIgnoreCase(nextTag.getName())) {
          if (nextTag.getType() == Tag.Type.END) {
            if (depth == 0) {
              return count;
            } else {
              depth--;
            }
          } else if (nextTag.getType() == Tag.Type.BEGIN) {
            depth++;
          }
        }
      }
      count++;
View Full Code Here


   */
  protected final void loadContents() {
    for (int index = 0; index < this.page.getDataSize(); index++) {
      final DataUnit du = this.page.getDataUnit(index);
      if (du instanceof TagDataUnit) {
        final Tag tag = ((TagDataUnit) du).getTag();

        if (tag.getType() != Tag.Type.END) {
          if (tag.getName().equalsIgnoreCase("a")) {
            loadLink(index, tag);
          } else if (tag.getName().equalsIgnoreCase("title")) {
            loadTitle(index, tag);
          } else if (tag.getName().equalsIgnoreCase("form")) {
            loadForm(index, tag);
          } else if (tag.getName().equalsIgnoreCase("input")) {
            loadInput(index, tag);
          }

        }

        if (tag.getType() == Tag.Type.BEGIN) {
          if (tag.getName().equalsIgnoreCase("div")) {
            loadDiv(index, tag);
          } else if (tag.getName().equalsIgnoreCase("span")) {
            loadSpan(index, tag);
          }
        }

        if (tag.getType() == Tag.Type.END) {
          if (tag.getName().equalsIgnoreCase("div")) {
            if (this.lastHierarchyElement != null) {
              this.lastHierarchyElement =
                this.lastHierarchyElement
                  .getParent();
            }
          } else if (tag.getName().equalsIgnoreCase("span")) {
            if (this.lastHierarchyElement != null) {
              this.lastHierarchyElement =
                this.lastHierarchyElement
                  .getParent();
            }
View Full Code Here

    // parse the results
    int ch;
    while ((ch = parse.read()) != -1) {
      if (ch == 0) {
        final Tag tag = parse.getTag();
        if (tag.getName().equalsIgnoreCase("url")) {
          buffer.setLength(0);
          capture = true;
        } else if (tag.getName().equalsIgnoreCase("/url")) {
          result.add(new URL(buffer.toString()));
          buffer.setLength(0);
          capture = false;
        }
      } else {
View Full Code Here

    TestCase.assertTrue(parse.getTag().getName().equalsIgnoreCase("b"));
    TestCase.assertTrue(parse.getTag().getType()==Tag.Type.BEGIN);
    TestCase.assertTrue(parse.read()=='1');
    TestCase.assertTrue(parse.read()=='2');
    TestCase.assertTrue(parse.read()==0);
    Tag tag = parse.getTag();
    TestCase.assertTrue(tag.getName().equalsIgnoreCase("b"));
    TestCase.assertTrue(tag.getType()==Tag.Type.END);
    TestCase.assertEquals(tag.toString(),"</b>");
    TestCase.assertTrue(parse.read()=='1');
  }
View Full Code Here

  {
    String html="<img src=\"picture.gif\" alt=\"A Picture\">";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    TestCase.assertTrue(parse.read()==0);
    Tag tag = parse.getTag();
    TestCase.assertNotNull(tag);
    TestCase.assertTrue(tag.getName().equals("img"));
    //TestCase.assertTrue(html.equals(tag.toString()));
    TestCase.assertTrue(tag.getAttributeValue("src").equals("picture.gif"));
    TestCase.assertTrue(tag.getAttributeValue("alt").equals("A Picture"));
  }
View Full Code Here

  {
    String html="<img src=picture.gif alt=APicture>";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    TestCase.assertTrue(parse.read()==0);
    Tag tag = parse.getTag();
    TestCase.assertNotNull(tag);
    TestCase.assertTrue(tag.getName().equals("img"));
    TestCase.assertTrue(tag.getAttributeValue("src").equals("picture.gif"));
    TestCase.assertTrue(tag.getAttributeValue("alt").equals("APicture"));
  }
View Full Code Here

    String html="<br/>";
    String htmlName = "br";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    TestCase.assertTrue(parse.read()==0);
    Tag tag = parse.getTag();
    TestCase.assertNotNull(tag);
    TestCase.assertTrue(tag.getType()==Tag.Type.BEGIN);
    TestCase.assertTrue(tag.getName().equals(htmlName));
    parse.readToTag();
    tag = parse.getTag();
    TestCase.assertNotNull(tag);
    TestCase.assertTrue(tag.getType()==Tag.Type.END);
    TestCase.assertTrue(tag.getName().equals(htmlName));
  }
View Full Code Here

  {
    String html = "<!DOCTYPE \"test\">";
    ByteArrayInputStream bis = new ByteArrayInputStream(html.getBytes());
    ReadHTML parse = new ReadHTML(bis);
    TestCase.assertTrue(parse.read()==0);
    Tag tag = parse.getTag();
    TestCase.assertEquals(tag.toString(), html);
  }
View Full Code Here

    while (count < this.page.getDataSize()) {
      final DataUnit du = this.page.getDataUnit(count);

      if (du instanceof TagDataUnit) {
        final Tag nextTag = ((TagDataUnit) du).getTag();
        if (tag.getName().equalsIgnoreCase(nextTag.getName())) {
          if (nextTag.getType() == Tag.Type.END) {
            if (depth == 0) {
              return count;
            } else {
              depth--;
            }
          } else if (nextTag.getType() == Tag.Type.BEGIN) {
            depth++;
          }
        }
      }
      count++;
View Full Code Here

   */
  protected final void loadContents() {
    for (int index = 0; index < this.page.getDataSize(); index++) {
      final DataUnit du = this.page.getDataUnit(index);
      if (du instanceof TagDataUnit) {
        final Tag tag = ((TagDataUnit) du).getTag();

        if (tag.getType() != Tag.Type.END) {
          if (tag.getName().equalsIgnoreCase("a")) {
            loadLink(index, tag);
          } else if (tag.getName().equalsIgnoreCase("title")) {
            loadTitle(index, tag);
          } else if (tag.getName().equalsIgnoreCase("form")) {
            loadForm(index, tag);
          } else if (tag.getName().equalsIgnoreCase("input")) {
            loadInput(index, tag);
          }

        }

        if (tag.getType() == Tag.Type.BEGIN) {
          if (tag.getName().equalsIgnoreCase("div")) {
            loadDiv(index, tag);
          } else if (tag.getName().equalsIgnoreCase("span")) {
            loadSpan(index, tag);
          }
        }

        if (tag.getType() == Tag.Type.END) {
          if (tag.getName().equalsIgnoreCase("div")) {
            if (this.lastHierarchyElement != null) {
              this.lastHierarchyElement =
                this.lastHierarchyElement
                  .getParent();
            }
          } else if (tag.getName().equalsIgnoreCase("span")) {
            if (this.lastHierarchyElement != null) {
              this.lastHierarchyElement =
                this.lastHierarchyElement
                  .getParent();
            }
View Full Code Here

TOP

Related Classes of org.encog.parse.tags.Tag

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.