Package org.htmlparser

Examples of org.htmlparser.Tag


    {
        NodeFactory factory;
        PrototypicalNodeFactory proto;
        Set names;
        String name;
        Tag tag;

        mFilter = (NodeClassFilter)filter;

        factory = context.getNodeFactory ();
        if (factory instanceof PrototypicalNodeFactory)
        {
            proto = (PrototypicalNodeFactory)factory;
            // iterate over the classes
            names = proto.getTagNames ();
            for (Iterator iterator = names.iterator (); iterator.hasNext (); )
            {
                name = (String)iterator.next ();
                tag = proto.get (name);
                mClass.addItem (tag.getClass ().getName ());
            }
        }
        mClass.setSelectedItem (mFilter.getMatchClass ().getName ());
    }
View Full Code Here


    {
        HashMap images;
        HashMap links;
        boolean ina; // true when within a <A></A> pair
        Node node;
        Tag tag;
        String name;
        Tag startatag;
        Tag imgtag;
        String href;
        String src;
        URL url;
        URL[][] ret;

        images = new HashMap ();
        links = new HashMap ();
        ina = false;
        startatag = null;
        imgtag = null;
        while (null != (node = lexer.nextNode ()))
        {
            if (node instanceof Tag)
            {
                tag = (Tag)node;
                name = tag.getTagName ();
                if ("A".equals (name))
                {
                    if (tag.isEndTag ())
                    {
                        ina = false;
                        if (null != imgtag)
                        {
                            // evidence of a thumb
                            href = startatag.getAttribute ("HREF");
                            if (null != href)
                            {
                                if (isImage (href))
                                {
                                    src = imgtag.getAttribute ("SRC");
                                    if (null != src)
                                        try
                                        {
                                            url = new URL (docbase, href);
                                            // eliminate duplicates
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

    public void assertXmlEquals(String displayMessage, String expected, String actual) throws Exception
    {
        Node nextExpectedNode;
        Node nextActualNode;
        Tag tag1;
        Tag tag2;

        expected = removeEscapeCharacters(expected);
        actual   = removeEscapeCharacters(actual);

        Parser expectedParser = Parser.createParser(expected, null);
View Full Code Here

    /**
     * Return a following tag if node is an empty XML tag.
     */
    private Tag fixIfXmlEndTag (Page page, Node node)
    {
        Tag ret;

        ret = null;
        if (node instanceof Tag)
        {
            Tag tag = (Tag)node;
            if (tag.isEmptyXmlTag())
            {
                tag.setEmptyXmlTag (false);
                ret = new TagNode (page, tag.getStartPosition (), tag.getEndPosition (), tag.getAttributesEx ());
            }
        }
       
        return (ret);
    }
View Full Code Here

        parseAndAssertNodeCount(2);
        // The first node should be a Remark
        assertTrue("First node should be a string node",node[0] instanceof Text);
        assertTrue("Second node should be a Tag",node[1] instanceof Tag);
        Text stringNode = (Text)node[0];
        Tag tag = (Tag)node[1];
        assertEquals("Text contents","&nbsp;",stringNode.getText());
        assertEquals("Tag Contents","![endif]",tag.getText());

    }
View Full Code Here

        "-\n"+
        "ssd -->");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a Tag but was "+node[0],node[0] instanceof Tag);
        Tag tag = (Tag)node[0];
        assertStringEquals("Expected contents","!\n"+
        "-\n"+
        "-\n"+
        "ssd --",tag.getText());
    }
View Full Code Here

            // loop inside the tags of the same type
            NodeList links = getLinks (inputModified, tags[i], recursive);
            for (int j=0; j<links.size(); j++)
            {
                CompositeTag beginTag = (CompositeTag)links.elementAt(j);
                Tag endTag = beginTag.getEndTag();

                // positions of begin and end tags
                int beginTagBegin = beginTag.getStartPosition ();
                int endTagBegin = beginTag.getEndPosition ();
                int beginTagEnd = endTag.getStartPosition ();
                int endTagEnd = endTag.getEndPosition ();

                if (insideTag)
                {
                    dummyString = modifyDummyString (new String(dummyString), beginTagBegin, endTagEnd);
                }
View Full Code Here

        // loop inside the tags of the same type
        NodeList links = getLinks (input, filter, recursive);
        for (int j=0; j<links.size(); j++)
        {
            CompositeTag beginTag = (CompositeTag)links.elementAt(j);
            Tag endTag = beginTag.getEndTag();

            // positions of begin and end tags
            int beginTagBegin = beginTag.getStartPosition ();
            int endTagBegin = beginTag.getEndPosition ();
            int beginTagEnd = endTag.getStartPosition ();
            int endTagEnd = endTag.getEndPosition ();

            if (insideTag)
            {
                dummyString = modifyDummyString (new String(dummyString), beginTagBegin, endTagEnd);
            }
View Full Code Here

            // loop inside the tags of the same type
            NodeList links = getLinks (inputModified, tags[i], recursive);
            for (int j=0; j<links.size(); j++)
            {
                CompositeTag beginTag = (CompositeTag)links.elementAt(j);
                Tag endTag = beginTag.getEndTag();

                // positions of begin and end tags
                int beginTagBegin = beginTag.getStartPosition ();
                int endTagBegin = beginTag.getEndPosition ();
                int beginTagEnd = endTag.getStartPosition ();
                int endTagEnd = endTag.getEndPosition ();


                if (insideTag)
                {
                    dummyString = modifyDummyString (new String(dummyString), beginTagBegin, endTagEnd);
View Full Code Here

TOP

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