Package org.htmlparser.scanners

Examples of org.htmlparser.scanners.Scanner


     * @exception ParserException If an unrecoverable error occurs.
     */
    public Node nextNode () throws ParserException
    {
        Tag tag;
        Scanner scanner;
        NodeList stack;
        Node ret;

        try
        {
            ret = mLexer.nextNode ();
            if (null != ret)
            {
                // kick off recursion for the top level node
                if (ret instanceof Tag)
                {
                    tag = (Tag)ret;
                    if (!tag.isEndTag ())
                    {
                        // now recurse if there is a scanner for this type of tag
                        scanner = tag.getThisScanner ();
                        if (null != scanner)
                        {
                            stack = new NodeList ();
                            ret = scanner.scan (tag, mLexer, stack);
                        }
                    }
                }
            }
        }
View Full Code Here


    public Tag scan (Tag tag, Lexer lexer, NodeList stack) throws ParserException
    {
        Node node;
        Tag next;
        String name;
        Scanner scanner;
        Tag ret;
       
        ret = tag;

        if (ret.isEmptyXmlTag ())
            ret.setEndTag (ret);
        else
            do
            {
                node = lexer.nextNode (false);
                if (null != node)
                {
                    if (node instanceof Tag)
                    {
                        next = (Tag)node;
                        name = next.getTagName ();
                        // check for normal end tag
                        if (next.isEndTag () && name.equals (ret.getTagName ()))
                        {
                            ret.setEndTag (next);
                            node = null;
                        }
                        else if (isTagToBeEndedFor (ret, next)) // check DTD
                        {
                            // backup one node. insert a virtual end tag later
                            lexer.setPosition (next.getStartPosition ());
                            node = null;
                        }
                        else if (!next.isEndTag ())
                        {
                            // now recurse if there is a scanner for this type of tag
                            scanner = next.getThisScanner ();
                            if (null != scanner)
                            {
                                if (mUseJVMStack)
                                {   // JVM stack recursion
                                    node = scanner.scan (next, lexer, stack);
                                    addChild (ret, node);
                                }
                                else
                                {
                                    // fake recursion:
                                    if (scanner == this)
                                    {
                                        if (next.isEmptyXmlTag ())
                                        {
                                            next.setEndTag (next);
                                            finishTag (next, lexer);
                                            addChild (ret, next);
                                        }
                                        else
                                        {
                                            stack.add (ret);
                                            ret = next;
                                        }
                                    }
                                    else
                                    {   // normal recursion if switching scanners
                                        node = scanner.scan (next, lexer, stack);
                                        addChild (ret, node);
                                    }
                                }
                            }
                            else
View Full Code Here

TOP

Related Classes of org.htmlparser.scanners.Scanner

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.