Package org.htmlparser.tags

Examples of org.htmlparser.tags.Tag


    int state = TAG_BEFORE_PARSING_STATE;
    int i = position;
    char ch;
    char[] ignorechar = new char[1];
    // holds the character we're looking for when in TAG_IGNORE_DATA_STATE
    Tag tag = new Tag(new TagData(position, 0, reader.getLastLineNumber(), 0, "", input, "", false));

    Bool encounteredQuery = new Bool(false);
    while (i < tag.getTagLine().length() && state != TAG_FINISHED_PARSING_STATE && state != TAG_ILLEGAL_STATE) {
      ch = tag.getTagLine().charAt(i);
      state = automataInput(encounteredQuery, i, state, ch, tag, i, ignorechar);
      i = incrementCounter(i, reader, state, tag);
    }
    if (state == TAG_FINISHED_PARSING_STATE) {
      String tagLine = tag.getTagLine();
      if (i > 1 && tagLine.charAt(i - 2) == '/') {
        tag.setEmptyXmlTag(true);
        String tagContents = tag.getText();
        tag.setText(tagContents.substring(0, tagContents.length() - 1));
      }
      return tag;
    } else
      return null;
  }
View Full Code Here


    return possibleEndTag.getTagName().equals(tag.getTagName());
  }

  private void doEmptyXmlTagCheckOn(Node currentNode) {
    if (currentNode instanceof Tag) {
      Tag possibleEndTag = (Tag) currentNode;
      if (isXmlEndTag(tag)) {
        endTag = possibleEndTag;
        endTagFound = true;
      }
    }
View Full Code Here

  }

  public static boolean isXMLTagFound(Node node, String tagName) {
    boolean xmlTagFound = false;
    if (node instanceof Tag) {
      Tag tag = (Tag) node;
      if (tag.getText().toUpperCase().indexOf(tagName) == 0) {
        xmlTagFound = true;
      }
    }
    return xmlTagFound;
  }
View Full Code Here

    }
    return xmlTagFound;
  }

  public final Tag createScannedNode(Tag tag, String url, NodeReader reader, String currLine) throws ParserException {
    Tag thisTag = scan(tag, url, reader, currLine);
    thisTag.setThisScanner(this);
    thisTag.setAttributes(tag.getAttributes());
    return thisTag;
  }
View Full Code Here

          // There is a filter. Find if the associated filter of this
          // node
          // matches the specified filter
          if (!(node instanceof Tag))
            continue;
          Tag tag = (Tag) node;
          TagScanner scanner = tag.getThisScanner();
          if (scanner == null)
            continue;

          String tagFilter = scanner.getFilter();
          if (tagFilter == null)
View Full Code Here

        node = remarkNodeParser.find(this, line, posInLine);
        if (node != null)
          return node;
        node = Tag.find(this, line, posInLine);
        if (node != null) {
          Tag tag = (Tag) node;
          try {
            node = tag.scan(parser.getScanners(), url, this);
            return node;
          } catch (Exception e) {
            StringBuffer msgBuffer = new StringBuffer();
            msgBuffer.append(DECIPHER_ERROR + "\n" + "    Tag being processed : " + tag.getTagName() + "\n"
                + "    Current Tag Line : " + tag.getTagLine());
            appendLineDetails(msgBuffer);
            ParserException ex = new ParserException(msgBuffer.toString(), e);

            parser.getFeedback().error(msgBuffer.toString(), ex);
            throw ex;
View Full Code Here

    assertStringEquals(displayMessage, expectedNodeName, actualNodeName);
  }

  public void assertTagEquals(String displayMessage, Node expected, Node actual) {
    if (expected instanceof Tag) {
      Tag expectedTag = (Tag) expected;
      Tag actualTag = (Tag) actual;
      assertTagNameMatches(displayMessage, expectedTag, actualTag);
      assertAttributesMatch(displayMessage, expectedTag, actualTag);
    }
  }
View Full Code Here

        + actual;
  }

  private void fixIfXmlEndTag(Parser parser, Node node) {
    if (node instanceof Tag) {
      Tag tag = (Tag) node;
      if (tag.isEmptyXmlTag()) {
        // Add end tag
        String currLine = parser.getReader().getCurrentLine();
        int pos = parser.getReader().getLastReadPosition();
        currLine = currLine.substring(0, pos + 1) + "</" + tag.getTagName() + ">"
            + currLine.substring(pos + 1, currLine.length());
        parser.getReader().changeLine(currLine);
      }
    }
  }
View Full Code Here

  private void assertTagEquals(String displayMessage, Node expectedNode, Node actualNode,
      NodeIterator actualEnumeration) throws ParserException {

    if (expectedNode instanceof Tag) {
      Tag expectedTag = (Tag) expectedNode;
      Tag actualTag = (Tag) actualNode;
      if (isTagAnXmlEndTag(expectedTag)) {
        if (!isTagAnXmlEndTag(actualTag)) {
          assertAttributesMatch(displayMessage, expectedTag, actualTag);
          Node tempNode = actualEnumeration.nextNode();
          assertTrue("should be an end tag but was " + tempNode.getClass().getName(),
              tempNode instanceof EndTag);
          actualTag = (EndTag) tempNode;
          String expectedTagName = ParserUtils.removeChars(expectedTag.getTagName(), '/');
          assertEquals("expected end tag", expectedTagName, actualTag.getTagName());

        }
      } else
        assertAttributesMatch(displayMessage, expectedTag, actualTag);
    }
View Full Code Here

  protected void setUp() {
    helper = new CompositeTagScannerHelper(null, null, null, null, null, false);
  }

  public void testIsXmlEndTagForRealXml() {
    Tag tag = new Tag(new TagData(0, 0, "something/", ""));
    assertTrue("should be an xml end tag", helper.isXmlEndTag(tag));
  }
View Full Code Here

TOP

Related Classes of org.htmlparser.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.