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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package Torello.HTML.NodeSearch;

import java.util.*;

import Torello.HTML.*;
import Torello.HTML.NodeSearch.searchLoops.TNPeek;
import Torello.Java.LV;

/**
 * Searches an HTML-{@code Vector} for HTML-Tag's that match a specified search-criteria based on
 * Tag-Name and whether the Tag is an opening or closing tag, and returns both the
 * {@code Vector}-index and the Tag itself (as instances of {@link TagNodeIndex}).
 * 
 * <BR /><BR /><EMBED CLASS="external-html" DATA-FILE-ID=TagNodePeek>
 */
@Torello.HTML.Tools.JavaDoc.JDHeaderBackgroundImg
@Torello.HTML.Tools.JavaDoc.StaticFunctional
public class TagNodePeek
{
    private TagNodePeek() { }

    public static TagNodeIndex              first                       (Vector<? extends HTMLNode> html, TC tagCriteria, String... htmlTags)
    { return                                TNPeek.nth                  (html, 1, new LV(html, 0, -1), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }

    public static TagNodeIndex              last                        (Vector<? extends HTMLNode> html, TC tagCriteria, String... htmlTags)
    { return                                TNPeek.nthFromEnd           (html, 1, new LV(html, 0, -1), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }

    public static Vector<TagNodeIndex>      all                         (Vector<? extends HTMLNode> html, TC tagCriteria, String... htmlTags)
    { return                                TNPeek.all                  (html, new LV(html, 0, -1), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }

    public static Vector<TagNodeIndex>		allExcept                   (Vector<? extends HTMLNode> html, TC tagCriteria, String... htmlTags)
    { return                                TNPeek.allExcept            (html, new LV(html, 0, -1), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }

    public static TagNodeIndex              first                       (Vector<? extends HTMLNode> html, int sPos, int ePos, TC tagCriteria, String... htmlTags)
    { return                                TNPeek.nth                  (html, 1, new LV(html, sPos, ePos), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }

    public static TagNodeIndex              last                        (Vector<? extends HTMLNode> html, int sPos, int ePos, TC tagCriteria, String... htmlTags)
    { return                                TNPeek.nthFromEnd           (html, 1, new LV(html, sPos, ePos), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }

    public static Vector<TagNodeIndex>      all                         (Vector<? extends HTMLNode> html, int sPos, int ePos, TC tagCriteria, String... htmlTags)
    { return                                TNPeek.all                  (html, new LV(html, sPos, ePos), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }

    public static Vector<TagNodeIndex>      allExcept                   (Vector<? extends HTMLNode> html, int sPos, int ePos, TC tagCriteria, String... htmlTags)
    { return                                TNPeek.allExcept            (html, new LV(html, sPos, ePos), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }

    // NEW ADDITIONS - nth and nthFromEnd

    public static TagNodeIndex              nth                         (Vector<? extends HTMLNode> html, int nth, TC tagCriteria, String... htmlTags)
    { return                                TNPeek.nth                  (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }

    public static TagNodeIndex              nthFromEnd                  (Vector<? extends HTMLNode> html, int nth, TC tagCriteria, String... htmlTags)
    { return                                TNPeek.nthFromEnd           (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }

    public static TagNodeIndex              nth                         (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TC tagCriteria, String... htmlTags)
    { return                                TNPeek.nth                  (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }

    public static TagNodeIndex              nthFromEnd                  (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TC tagCriteria, String... htmlTags)
    { return                                TNPeek.nthFromEnd           (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }

}