Package org.htmlparser.tags

Examples of org.htmlparser.tags.Tag


        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


    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

        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

            "@ taglib uri=\"/WEB-INF/struts.tld\" prefix=\"struts\" ",
            tag.getText());

        // The second node should be a normal tag
        assertTrue("Node 2 should be an Tag", node[1] instanceof Tag);
        Tag htag = (Tag) node[1];
        assertStringEquals(
            "Contents of the tag",
            "jsp:useBean id=\"transfer\" scope=\"session\" class=\"com.bank.PageBean\"",
            htag.getText());
        assertStringEquals(
            "html",
            "<JSP:USEBEAN ID=\"transfer\" SCOPE=\"session\" CLASS=\"com.bank.PageBean\"/>",
            htag.toHtml());
        // The third node should be an HTMLJspTag
        assertTrue("Node 3 should be an HTMLJspTag", node[2] instanceof JspTag);
        JspTag tag2 = (JspTag) node[2];
        String expected =
            "\r\n"
View Full Code Here

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

    public void testCorrectTag() {
      Tag tag = new Tag(new TagData(0,20,"font face=\"Arial,\"helvetica,\" sans-serif=\"sans-serif\" size=\"2\" color=\"#FFFFFF\"","<font face=\"Arial,\"helvetica,\" sans-serif=\"sans-serif\" size=\"2\" color=\"#FFFFFF\">"));
    tagParser.correctTag(tag);
    assertStringEquals("Corrected Tag","font face=\"Arial,helvetica,\" sans-serif=\"sans-serif\" size=\"2\" color=\"#FFFFFF\"",tag.getText());
   
View Full Code Here

        parser = new AttributeParser();
    }

    public void getParameterTableFor(String tagContents)
    {
        tag = new Tag(new TagData(0, 0, tagContents, ""));
        table = parser.parseAttributes(tag);

    }
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

                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);
View Full Code Here

  public void testBodyTagBug1() throws ParserException {
    createParser("<BODY aLink=#ff0000 bgColor=#ffffff link=#0000cc onload=setfocus() text=#000000\nvLink=#551a8b>");
    parseAndAssertNodeCount(1);
    // The node should be an Tag
    assertTrue("Node should be a Tag", node[0] instanceof Tag);
    Tag tag = (Tag) node[0];
    assertEquals("Contents of the tag",
        "BODY aLink=#ff0000 bgColor=#ffffff link=#0000cc onload=setfocus() text=#000000\r\nvLink=#551a8b", tag
            .getText());
  }
View Full Code Here

  public void testLargeTagBug() throws ParserException {
    createParser("<MYTAG abcd\n" + "efgh\n" + "ijkl\n" + "mnop>");
    parseAndAssertNodeCount(1);
    // The node should be an Tag
    assertTrue("Node should be a Tag", node[0] instanceof Tag);
    Tag tag = (Tag) node[0];
    assertEquals("Contents of the tag", "MYTAG abcd\r\nefgh\r\nijkl\r\nmnop", tag.getText());

  }
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.