Package org.htmlparser.tags

Examples of org.htmlparser.tags.EndTag


  }

  public void testEndTagFind() {
    String testHtml = "<SCRIPT>document.write(d+\".com\")</SCRIPT>";
    int pos = testHtml.indexOf("</SCRIPT>");
    EndTag endTag = (EndTag) EndTag.find(testHtml, pos);
    assertEquals("endtag element begin", 32, endTag.elementBegin());
    assertEquals("endtag element end", 40, endTag.elementEnd());
  }
View Full Code Here


    assertFalse("custom tag should not be xml end tag", customTag.isEmptyXmlTag());

    assertStringEquals("first custom tag html", "<CUSTOM></CUSTOM>", customTag.toHtml());
    customTag = (CustomTag) node[1];
    assertStringEquals("first custom tag html", "<CUSTOM>something</CUSTOM>", customTag.toHtml());
    EndTag endTag = (EndTag) node[2];
    assertStringEquals("first custom tag html", "</CUSTOM>", endTag.toHtml());
  }
View Full Code Here

    assertType("firstChild", StringNode.class, firstChild);
    CompositeTag parent = firstChild.getParent();
    assertNotNull("first child parent should not be null", parent);
    assertSame("parent and custom tag should be the same", customTag, parent);

    EndTag endTag = (EndTag) node[2];
    assertStringEquals("first custom tag html", "</CUSTOM>", endTag.toHtml());
    assertNull("end tag should have no parent", endTag.getParent());

  }
View Full Code Here

  private void createCorrectionEndTagBefore(int pos) {
    String endTagName = tag.getTagName();
    int endTagBegin = pos;
    int endTagEnd = endTagBegin + endTagName.length() + 2;
    endTag = new EndTag(new TagData(endTagBegin, endTagEnd, endTagName, currLine));
  }
View Full Code Here

    String endTagName = tag.getTagName();
    int endTagBegin = possibleEndTagCauser.elementBegin();
    int endTagEnd = endTagBegin + endTagName.length() + 2;
    possibleEndTagCauser.setTagBegin(endTagEnd + 1);
    reader.addNextParsedNode(possibleEndTagCauser);
    endTag = new EndTag(new TagData(endTagBegin, endTagEnd, endTagName, currLine));
  }
View Full Code Here

    return newTag;
  }

  private void doChildAndEndTagCheckOn(Node currentNode) {
    if (currentNode instanceof EndTag) {
      EndTag possibleEndTag = (EndTag) currentNode;
      if (isExpectedEndTag(possibleEndTag)) {
        endTagFound = true;
        endTag = possibleEndTag;
        return;
      }
View Full Code Here

  protected Tag getReplacedEndTag(Tag tag, NodeReader reader, String currentLine) {
    // Replace tag - it was a <A> tag - replace with </a>
    String newLine = replaceFaultyTagWithEndTag(tag, currentLine);
    reader.changeLine(newLine);
    return new EndTag(new TagData(tag.elementBegin(), tag.elementBegin() + 3, tag.getTagName(), currentLine));
  }
View Full Code Here

  protected Tag getInsertedEndTag(Tag tag, NodeReader reader, String currentLine) {
    // Insert end tag
    String newLine = insertEndTagBeforeNode(tag, currentLine);
    reader.changeLine(newLine);
    return new EndTag(new TagData(tag.elementBegin(), tag.elementBegin() + 3, tag.getTagName(), currentLine));
  }
View Full Code Here

    Node node;
    MetaTag meta;
    String httpEquiv;
    String charset;
    boolean restart;
    EndTag end;
    IteratorImpl ret;

    remove_scanner = false;
    restart = false;
    ret = new IteratorImpl(reader, resourceLocn, feedback);
View Full Code Here

  public IteratorImpl createIteratorImpl(boolean remove_scanner, IteratorImpl ret) throws ParserException {
    Node node;
    MetaTag meta;
    String httpEquiv;
    String charset;
    EndTag end;
    if (null != url_conn)
      try {
        if (null == scanners.get("-m")) {
          addScanner(new MetaTagScanner("-m"));
          remove_scanner = true;
        }

        /* pre-read up to </HEAD> looking for charset directive */
        while (null != (node = ret.peek())) {
          if (node instanceof MetaTag) { // check for charset on
                          // Content-Type
            meta = (MetaTag) node;
            httpEquiv = meta.getAttribute("HTTP-EQUIV");
            if ("Content-Type".equalsIgnoreCase(httpEquiv)) {
              charset = getCharset(meta.getAttribute("CONTENT"));
              if (!charset.equalsIgnoreCase(character_set)) { // oops,
                                      // different
                                      // character
                                      // set,
                                      // restart
                character_set = charset;
                recreateReader();
                ret = new IteratorImpl(reader, resourceLocn, feedback);
              }
              // once we see the Content-Type meta tag we're
              // finished the pre-read
              break;
            }
          } else if (node instanceof EndTag) {
            end = (EndTag) node;
            if (end.getTagName().equalsIgnoreCase("HEAD"))
              // or, once we see the </HEAD> tag we're finished
              // the pre-read
              break;
          }
        }
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.EndTag

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.