001package Torello.HTML.NodeSearch;
002
003import java.util.Vector;
004import java.util.regex.Pattern;
005import java.util.function.Predicate;
006
007import Torello.HTML.*;
008import Torello.HTML.NodeSearch.searchLoops.CmtNPoll;
009import Torello.Java.LV;
010
011/**
012 * Searches for, and extracts, HTML Comments from Vectorized-HTML that match a user-specified
013 * search-criteria, <I>and returns those extracted node or nodes</I>.
014 * 
015 * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=CommentNodePoll> 
016 */
017@Torello.JavaDoc.JDHeaderBackgroundImg
018@Torello.JavaDoc.StaticFunctional
019public class CommentNodePoll
020{
021    private CommentNodePoll() { }
022
023    // ********************************************************************************************
024    // FIRST, LAST
025    // ********************************************************************************************
026
027    // **** first: no sPos, ePos 
028    public static CommentNode first (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)
029    { return CmtNPoll.nth (html, 1, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
030    public static CommentNode first (Vector<? extends HTMLNode> html, Pattern p)
031    { return CmtNPoll.nth (html, 1, new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
032    public static CommentNode first (Vector<? extends HTMLNode> html, Predicate<String> p)
033    { return CmtNPoll.nth (html, 1, new LV(html, 0, -1), p); }
034
035    // **** first: CRITERIA INCLUDES sPos, ePos
036    public static CommentNode first (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)
037    { return CmtNPoll.nth (html, 1, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
038    public static CommentNode first (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)
039    { return CmtNPoll.nth (html, 1, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
040    public static CommentNode first (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)
041    { return CmtNPoll.nth (html, 1, new LV(html, sPos, ePos), p); }
042
043    // **** last: no sPos, ePos
044    public static CommentNode last (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)
045    { return CmtNPoll.nthFromEnd (html, 1, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
046    public static CommentNode last (Vector<? extends HTMLNode> html, Pattern p)
047    { return CmtNPoll.nthFromEnd (html, 1, new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
048    public static CommentNode last (Vector<? extends HTMLNode> html, Predicate<String> p)
049    { return CmtNPoll.nthFromEnd (html, 1, new LV(html, 0, -1), p); }
050
051    // **** last: CRITERIA INCLUDES sPos, ePos
052    public static CommentNode last (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)
053    { return CmtNPoll.nthFromEnd (html, 1, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
054    public static CommentNode last (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)
055    { return CmtNPoll.nthFromEnd (html, 1, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
056    public static CommentNode last (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)
057    { return CmtNPoll.nthFromEnd (html, 1, new LV(html, sPos, ePos), p); }
058
059    // ********************************************************************************************
060    // NEW ADDITIONS: nth and nthFromEnd
061    // ********************************************************************************************
062
063    // **** nth: no sPos, ePos 
064    public static CommentNode nth (Vector<? extends HTMLNode> html, int nth, TextComparitor tc, String... compareStr)
065    { return CmtNPoll.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
066    public static CommentNode nth (Vector<? extends HTMLNode> html, int nth, Pattern p)
067    { return CmtNPoll.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
068    public static CommentNode nth (Vector<? extends HTMLNode> html, int nth, Predicate<String> p)
069    { return CmtNPoll.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), p); }
070
071    // **** nth: CRITERIA INCLUDES sPos, ePos
072    public static CommentNode nth (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TextComparitor tc, String... compareStr)
073    { return CmtNPoll.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
074    public static CommentNode nth (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Pattern p)
075    { return CmtNPoll.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
076    public static CommentNode nth (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<String> p)
077    { return CmtNPoll.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), p); }
078
079    // **** nthFromEnd: no sPos, ePos
080    public static CommentNode nthFromEnd (Vector<? extends HTMLNode> html, int nth, TextComparitor tc, String... compareStr)
081    { return CmtNPoll.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
082    public static CommentNode nthFromEnd (Vector<? extends HTMLNode> html, int nth, Pattern p)
083    { return CmtNPoll.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
084    public static CommentNode nthFromEnd (Vector<? extends HTMLNode> html, int nth, Predicate<String> p)
085    { return CmtNPoll.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), p); }
086
087    // **** nthFromEnd: CRITERIA INCLUDES sPos, ePos
088    public static CommentNode nthFromEnd (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TextComparitor tc, String... compareStr)
089    { return CmtNPoll.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
090    public static CommentNode nthFromEnd (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Pattern p)
091    { return CmtNPoll.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
092    public static CommentNode nthFromEnd (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<String> p)
093    { return CmtNPoll.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), p); }
094
095    // ********************************************************************************************
096    // ALL methods
097    // ********************************************************************************************
098
099    // **** all: no sPos, ePos
100    public static Vector<CommentNode> all (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)
101    { return CmtNPoll.all (html, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
102    public static Vector<CommentNode> all (Vector<? extends HTMLNode> html, Pattern p)
103    { return CmtNPoll.all (html, new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
104    public static Vector<CommentNode> all (Vector<? extends HTMLNode> html, Predicate<String> p)
105    { return CmtNPoll.all (html, new LV(html, 0, -1), p); }
106
107    // **** all: CRITERIA INCLUDES sPos, ePos
108    public static Vector<CommentNode> all (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)
109    { return CmtNPoll.all (html, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
110    public static Vector<CommentNode> all (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)
111    { return CmtNPoll.all (html, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
112    public static Vector<CommentNode> all (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)
113    { return CmtNPoll.all (html, new LV(html, sPos, ePos), p); }
114
115
116    // **** allExcept: no sPos, ePos
117    public static Vector<CommentNode> allExcept (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)
118    { return CmtNPoll.allExcept (html, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
119    public static Vector<CommentNode> allExcept (Vector<? extends HTMLNode> html, Pattern p)
120    { return CmtNPoll.allExcept (html, new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
121    public static Vector<CommentNode> allExcept (Vector<? extends HTMLNode> html, Predicate<String> p)
122    { return CmtNPoll.allExcept (html, new LV(html, 0, -1), p); }
123
124    // **** allExcept: CRITERIA INCLUDES sPos, ePos
125    public static Vector<CommentNode> allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)
126    { return CmtNPoll.allExcept (html, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
127    public static Vector<CommentNode> allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)
128    { return CmtNPoll.allExcept (html, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
129    public static Vector<CommentNode> allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)
130    { return CmtNPoll.allExcept (html, new LV(html, sPos, ePos), p); }
131}