001package Torello.HTML.NodeSearch;
002
003import java.util.*;
004
005import Torello.HTML.*;
006import Torello.HTML.NodeSearch.searchLoops.TNPeek;
007import Torello.Java.LV;
008
009/**
010 * Searches an HTML-{@code Vector} for HTML-Tag's that match a specified search-criteria based on
011 * Tag-Name and whether the Tag is an opening or closing tag, and returns both the
012 * {@code Vector}-index and the Tag itself (as instances of {@link TagNodeIndex}).
013 * 
014 * <BR /><BR /><EMBED CLASS="external-html" DATA-FILE-ID=TagNodePeek>
015 */
016@Torello.HTML.Tools.JavaDoc.JDHeaderBackgroundImg
017@Torello.HTML.Tools.JavaDoc.StaticFunctional
018public class TagNodePeek
019{
020    private TagNodePeek() { }
021
022    public static TagNodeIndex              first                       (Vector<? extends HTMLNode> html, TC tagCriteria, String... htmlTags)
023    { return                                TNPeek.nth                  (html, 1, new LV(html, 0, -1), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }
024
025    public static TagNodeIndex              last                        (Vector<? extends HTMLNode> html, TC tagCriteria, String... htmlTags)
026    { return                                TNPeek.nthFromEnd           (html, 1, new LV(html, 0, -1), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }
027
028    public static Vector<TagNodeIndex>      all                         (Vector<? extends HTMLNode> html, TC tagCriteria, String... htmlTags)
029    { return                                TNPeek.all                  (html, new LV(html, 0, -1), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }
030
031    public static Vector<TagNodeIndex>      allExcept                   (Vector<? extends HTMLNode> html, TC tagCriteria, String... htmlTags)
032    { return                                TNPeek.allExcept            (html, new LV(html, 0, -1), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }
033
034    public static TagNodeIndex              first                       (Vector<? extends HTMLNode> html, int sPos, int ePos, TC tagCriteria, String... htmlTags)
035    { return                                TNPeek.nth                  (html, 1, new LV(html, sPos, ePos), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }
036
037    public static TagNodeIndex              last                        (Vector<? extends HTMLNode> html, int sPos, int ePos, TC tagCriteria, String... htmlTags)
038    { return                                TNPeek.nthFromEnd           (html, 1, new LV(html, sPos, ePos), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }
039
040    public static Vector<TagNodeIndex>      all                         (Vector<? extends HTMLNode> html, int sPos, int ePos, TC tagCriteria, String... htmlTags)
041    { return                                TNPeek.all                  (html, new LV(html, sPos, ePos), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }
042
043    public static Vector<TagNodeIndex>      allExcept                   (Vector<? extends HTMLNode> html, int sPos, int ePos, TC tagCriteria, String... htmlTags)
044    { return                                TNPeek.allExcept            (html, new LV(html, sPos, ePos), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }
045
046    // NEW ADDITIONS - nth and nthFromEnd
047
048    public static TagNodeIndex              nth                         (Vector<? extends HTMLNode> html, int nth, TC tagCriteria, String... htmlTags)
049    { return                                TNPeek.nth                  (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }
050
051    public static TagNodeIndex              nthFromEnd                  (Vector<? extends HTMLNode> html, int nth, TC tagCriteria, String... htmlTags)
052    { return                                TNPeek.nthFromEnd           (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }
053
054    public static TagNodeIndex              nth                         (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TC tagCriteria, String... htmlTags)
055    { return                                TNPeek.nth                  (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }
056
057    public static TagNodeIndex              nthFromEnd                  (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TC tagCriteria, String... htmlTags)
058    { return                                TNPeek.nthFromEnd           (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), tagCriteria, ARGCHECK.htmlTags(htmlTags)); }
059
060}