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
35
36
37
38
39
40
package Torello.HTML.NodeSearch.searchLoops;

import java.util.Vector;

import Torello.HTML.*;

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

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

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

        for (int i = l.start; i < l.end; i++)

            if ((tn = html.elementAt(i).openTag()) != null)
  
                if (tn.tok.equals(htmlTag))
                {
                    if ((dp = Util.Inclusive.dotPairOPT(html, i, l.end)) != null)
                    {
                        ret.addElement(new SubSection(dp, 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;
    }
}