Package org.htmlparser

Examples of org.htmlparser.Text


        String text = "Testing &\nRefactoring";
        createParser(text);
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertType("first node",Text.class,node[0]);
        Text stringNode = (Text)node[0];
        assertStringEquals("text",text,stringNode.toPlainTextString());
    }
View Full Code Here


        Node node;
        Tag tag;
        String paramName;
        String paramValue;
        Vector attributes;
        Text string;

        kids = getChildren ();
        if (null == kids)
            kids = new NodeList ();
        else
            // erase appletParams from kids
            for (int i = 0; i < kids.size (); )
            {
                node = kids.elementAt (i);
                if (node instanceof Tag)
                    if (((Tag)node).getTagName ().equals ("PARAM"))
                    {
                        kids.remove (i);
                        // remove whitespace too
                        if (i < kids.size ())
                        {
                            node = kids.elementAt (i);
                            if (node instanceof Text)
                            {
                                string = (Text)node;
                                if (0 == string.getText ().trim ().length ())
                                    kids.remove (i);
                            }  
                        }
                    }
                    else
View Full Code Here

            if (node instanceof Text)
            {
                // Node is a plain string
                // Cast it to an HTMLText
                Text stringNode = (Text)node;
                // Retrieve the data from the object
                buffer.append (stringNode.getText ());
            }
            else if (node instanceof LinkTag)
            {
                // Node is a link
                // Cast it to an HTMLLinkTag
View Full Code Here

        assertType("first child",AnotherTag.class,node);
        AnotherTag anotherTag = (AnotherTag)node;
        assertEquals("another tag children count",1,anotherTag.getChildCount());
        node = anotherTag.childAt(0);
        assertType("nested child",Text.class,node);
        Text text = (Text)node;
        assertEquals("text","Hello",text.toPlainTextString());
    }
View Full Code Here

        assertType("first child",AnotherTag.class,node);
        AnotherTag anotherTag = (AnotherTag)node;
        assertEquals("another tag children count",1,anotherTag.getChildCount());
        node = anotherTag.childAt(0);
        assertType("nested child",Text.class,node);
        Text text = (Text)node;
        assertEquals("text","Hello",text.toPlainTextString());
    }
View Full Code Here

        assertEquals("ending loc",8,customTag.getEndPosition ());
        assertEquals("starting line position",0,customTag.getStartingLineNumber());
        assertEquals("ending line position",0,customTag.getEndingLineNumber());
        AnotherTag anotherTag = (AnotherTag)customTag.childAt(0);
        assertEquals("anotherTag child count",1,anotherTag.getChildCount());
        Text stringNode = (Text)anotherTag.childAt(0);
        assertStringEquals("anotherTag child text","something",stringNode.toPlainTextString());
        assertStringEquals(
            "first custom tag html",
            "<custom><another>something</another></custom>",
            customTag.toHtml()
        );
View Full Code Here

                "<a>"
        );
        parseAndAssertNodeCount(4);
        // The first node should be a Text
        assertTrue("First node should be a Text",node[0] instanceof Text);
        Text stringNode = (Text)node[0];
        assertEquals("Text of the Text","Site Comments?",stringNode.getText());
        assertTrue("Second node should be a tag",node[1] instanceof Tag);
        assertTrue("Third node should be a link",node[2] instanceof LinkTag);
        // LinkScanner.evaluate() says no HREF means it isn't a link:
        assertTrue("Fourth node should be a tag",node[3] instanceof Tag);
    }
View Full Code Here

        String exp = new String("http://ads.samachar.com/bin/redirect/tech.txt?http://www.samachar.com/technical.html");
        //assertEquals("Length of link tag",exp.length(), linkTag.getLink().length());
        assertStringEquals("Link URL of link tag",exp,linkTag.getLink());
        assertEquals("Link Text of link tag"," Journalism 3.0",linkTag.getLinkText());
        assertTrue("Eight node should be a string node",node[7] instanceof Text);
        Text stringNode = (Text)node[7];
        assertEquals("String node contents"," by Rajesh Jain",stringNode.getText());
    }
View Full Code Here

        assertTrue("Second data node shouls be a String Node",dataNode[1] instanceof Text);

        // Check the contents of each data node
        ImageTag imageTag = (ImageTag)dataNode[0];
        assertEquals("Image URL","http://www.yahoo.com/abcd.jpg",imageTag.getImageURL());
        Text stringNode = (Text)dataNode[1];
        assertEquals("String Contents","Hello World",stringNode.getText());
    }
View Full Code Here

        assertTrue("Node 0 should be a tag",node[0] instanceof Tag);
        Tag tag = (Tag)node[0];
        assertEquals("Tag Contents",html,tag.toHtml());
        assertEquals("Node 0 should have one child", 1, tag.getChildren ().size ());
        assertTrue("The child should be a string node", tag.getChildren ().elementAt (0) instanceof Text);
        Text stringNode = (Text)tag.getChildren ().elementAt (0);
        assertEquals("Text Contents","Revision",stringNode.getText());
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.Text

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.