001package Torello.HTML.NodeSearch;
002
003import java.util.*;
004import java.util.regex.Pattern;
005import java.util.function.Predicate;
006
007import Torello.HTML.*;
008import Torello.HTML.NodeSearch.searchLoops.CmtNFind;
009import Torello.Java.LV;
010
011/**
012 * Identifies Vectorized-HTML indices having HTML Comments that match a user-provided criteria, 
013 * specified using a {@code String-Predicate}, Regular-Expression or {@link TextComparitor}.
014 * 
015 * <BR /><BR /><EMBED CLASS="external-html" DATA-FILE-ID=CommentNodeFind>
016 */
017@Torello.HTML.Tools.JavaDoc.JDHeaderBackgroundImg
018@Torello.HTML.Tools.JavaDoc.StaticFunctional
019public class CommentNodeFind
020{
021    private CommentNodeFind() { }
022
023    // ********************************************************************************************
024    // FIRST, LAST
025    // ********************************************************************************************
026
027    // **** first: no sPos, ePos 
028    public static int first (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)
029    { return CmtNFind.nth (html, 1, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
030    public static int first (Vector<? extends HTMLNode> html, Pattern p)
031    { return CmtNFind.nth (html, 1, new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
032    public static int first (Vector<? extends HTMLNode> html, Predicate<String> p)
033    { return CmtNFind.nth (html, 1, new LV(html, 0, -1), p); }
034
035    // **** first: CRITERIA INCLUDES sPos, ePos
036    public static int first (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)
037    { return CmtNFind.nth (html, 1, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
038    public static int first (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)
039    { return CmtNFind.nth (html, 1, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
040    public static int first (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)
041    { return CmtNFind.nth (html, 1, new LV(html, sPos, ePos), p); }
042
043    // **** last: no sPos, ePos
044    public static int last (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)
045    { return CmtNFind.nthFromEnd (html, 1, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
046    public static int last (Vector<? extends HTMLNode> html, Pattern p)
047    { return CmtNFind.nthFromEnd (html, 1, new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
048    public static int last (Vector<? extends HTMLNode> html, Predicate<String> p)
049    { return CmtNFind.nthFromEnd (html, 1, new LV(html, 0, -1), p); }
050
051    // **** last: CRITERIA INCLUDES sPos, ePos
052    public static int last (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)
053    { return CmtNFind.nthFromEnd (html, 1, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
054    public static int last (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)
055    { return CmtNFind.nthFromEnd (html, 1, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
056    public static int last (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)
057    { return CmtNFind.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 int nth (Vector<? extends HTMLNode> html, int nth, TextComparitor tc, String... compareStr)
065    { return CmtNFind.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
066    public static int nth (Vector<? extends HTMLNode> html, int nth, Pattern p)
067    { return CmtNFind.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
068    public static int nth (Vector<? extends HTMLNode> html, int nth, Predicate<String> p)
069    { return CmtNFind.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), p); }
070
071    // **** nth: CRITERIA INCLUDES sPos, ePos
072    public static int nth (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TextComparitor tc, String... compareStr)
073    { return CmtNFind.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
074    public static int nth (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Pattern p)
075    { return CmtNFind.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
076    public static int nth (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<String> p)
077    { return CmtNFind.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), p); }
078
079    // **** nthFromEnd: no sPos, ePos
080    public static int nthFromEnd (Vector<? extends HTMLNode> html, int nth, TextComparitor tc, String... compareStr)
081    { return CmtNFind.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
082    public static int nthFromEnd (Vector<? extends HTMLNode> html, int nth, Pattern p)
083    { return CmtNFind.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
084    public static int nthFromEnd (Vector<? extends HTMLNode> html, int nth, Predicate<String> p)
085    { return CmtNFind.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), p); }
086
087    // **** nthFromEnd: CRITERIA INCLUDES sPos, ePos
088    public static int nthFromEnd (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TextComparitor tc, String... compareStr)
089    { return CmtNFind.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
090    public static int nthFromEnd (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Pattern p)
091    { return CmtNFind.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
092    public static int nthFromEnd (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<String> p)
093    { return CmtNFind.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 int[] all (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)
101    { return CmtNFind.all (html, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
102    public static int[] all (Vector<? extends HTMLNode> html, Pattern p)
103    { return CmtNFind.all (html, new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
104    public static int[] all (Vector<? extends HTMLNode> html, Predicate<String> p)
105    { return CmtNFind.all (html, new LV(html, 0, -1), p); }
106
107    // **** all: CRITERIA INCLUDES sPos, ePos
108    public static int[] all (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)
109    { return CmtNFind.all (html, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
110    public static int[] all (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)
111    { return CmtNFind.all (html, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
112    public static int[] all (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)
113    { return CmtNFind.all (html, new LV(html, sPos, ePos), p); }
114
115    // **** allExcept: no sPos, ePos
116    public static int[] allExcept (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)
117    { return CmtNFind.allExcept (html, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
118    public static int[] allExcept (Vector<? extends HTMLNode> html, Pattern p)
119    { return CmtNFind.allExcept (html, new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
120    public static int[] allExcept (Vector<? extends HTMLNode> html, Predicate<String> p)
121    { return CmtNFind.allExcept (html, new LV(html, 0, -1), p); }
122
123    // **** allExcept: CRITERIA INCLUDES sPos, ePos
124    public static int[] allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)
125    { return CmtNFind.allExcept (html, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
126    public static int[] allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)
127    { return CmtNFind.allExcept (html, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
128    public static int[] allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)
129    { return CmtNFind.allExcept (html, new LV(html, sPos, ePos), p); }
130
131}