1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package Torello.HTML.NodeSearch.searchLoops;

import java.util.Vector;

import Torello.HTML.*;

import Torello.HTML.NodeSearch.InclusiveException;
import Torello.Java.LV;

public class TNGetL1Incl
{
    public static Vector<Vector<HTMLNode>> all (Vector<? extends HTMLNode> html, LV l, String htmlTag)
    {
        InclusiveException.check(htmlTag);

        Vector<Vector<HTMLNode>> ret = new Vector<>();
        DotPair dp;     HTMLNode n;     TagNode tn;

        for (int i = l.start; i < l.end; i++)
            if ((n = html.elementAt(i)).isTagNode())       
                if ((tn = (TagNode) n).tok.equals(htmlTag))
                    if (! tn.isClosing)
                    {
                        if ((dp = Util.Inclusive.dotPairOPT(html, i, l.end)) != null)
                        {
                            ret.addElement(DotPair.toVector(html, dp));
                            i = dp.end;  // i++ will happen immediately after this line!
                        }
                        else break;     // If there is an "opened" TagNode (such as <A>), but no matching-close node, break the loop immediately!
                                        // If this were "NOT AN L1" search, you would NOT BREAK here!  **BECAUSE** this is L1, **THEREFORE** break!
                    }
        return ret;
    }
}