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.CommentNodes.CmtNGet;
009import Torello.Java.LV;
010
011/**
012 * Retrieves HTML Comments as {@link CommentNode}-instances, which match a search-criteria
013 * that may be specified using either a {@code String-Predicate}, Regular-Expression or
014 * {@link TextComparitor}.
015 * 
016 * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=CommentNodeGet> 
017 */
018@Torello.JavaDoc.JDHeaderBackgroundImg
019@Torello.JavaDoc.StaticFunctional
020public class CommentNodeGet
021{
022    private CommentNodeGet() { }
023
024    // ********************************************************************************************
025    // FIRST, LAST
026    // ********************************************************************************************
027
028    // **** First: no sPos, ePos 
029    public static CommentNode first (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)
030    { return CmtNGet.nth (html, 1, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
031    public static CommentNode first (Vector<? extends HTMLNode> html, Pattern p)
032    { return CmtNGet.nth (html, 1, new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
033    public static CommentNode first (Vector<? extends HTMLNode> html, Predicate<String> p)
034    { return CmtNGet.nth (html, 1, new LV(html, 0, -1), p); }
035
036    // **** First: CRITERIA INCLUDES sPos, ePos
037    public static CommentNode first (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)
038    { return CmtNGet.nth (html, 1, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
039    public static CommentNode first (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)
040    { return CmtNGet.nth (html, 1, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
041    public static CommentNode first (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)
042    { return CmtNGet.nth (html, 1, new LV(html, sPos, ePos), p); }
043
044    // **** Last: no sPos, ePos
045    public static CommentNode last (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)
046    { return CmtNGet.nthFromEnd (html, 1, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
047    public static CommentNode last (Vector<? extends HTMLNode> html, Pattern p)
048    { return CmtNGet.nthFromEnd (html, 1, new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
049    public static CommentNode last (Vector<? extends HTMLNode> html, Predicate<String> p)
050    { return CmtNGet.nthFromEnd (html, 1, new LV(html, 0, -1), p); }
051
052    // **** Last: CRITERIA INCLUDES sPos, ePos
053    public static CommentNode last (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)
054    { return CmtNGet.nthFromEnd (html, 1, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
055    public static CommentNode last (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)
056    { return CmtNGet.nthFromEnd (html, 1, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
057    public static CommentNode last (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)
058    { return CmtNGet.nthFromEnd (html, 1, new LV(html, sPos, ePos), p); }
059
060    // ********************************************************************************************
061    // NEW ADDITIONS: nth and nthFromEnd
062    // ********************************************************************************************
063
064    // **** First: no sPos, ePos 
065    public static CommentNode nth (Vector<? extends HTMLNode> html, int nth, TextComparitor tc, String... compareStr)
066    { return CmtNGet.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
067    public static CommentNode nth (Vector<? extends HTMLNode> html, int nth, Pattern p)
068    { return CmtNGet.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
069    public static CommentNode nth (Vector<? extends HTMLNode> html, int nth, Predicate<String> p)
070    { return CmtNGet.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), p); }
071
072    // **** First: CRITERIA INCLUDES sPos, ePos
073    public static CommentNode nth (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TextComparitor tc, String... compareStr)
074    { return CmtNGet.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
075    public static CommentNode nth (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Pattern p)
076    { return CmtNGet.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
077    public static CommentNode nth (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<String> p)
078    { return CmtNGet.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), p); }
079
080    // **** Last: no sPos, ePos
081    public static CommentNode nthFromEnd (Vector<? extends HTMLNode> html, int nth, TextComparitor tc, String... compareStr)
082    { return CmtNGet.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
083    public static CommentNode nthFromEnd (Vector<? extends HTMLNode> html, int nth, Pattern p)
084    { return CmtNGet.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
085    public static CommentNode nthFromEnd (Vector<? extends HTMLNode> html, int nth, Predicate<String> p)
086    { return CmtNGet.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), p); }
087
088    // **** Last: CRITERIA INCLUDES sPos, ePos
089    public static CommentNode nthFromEnd (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TextComparitor tc, String... compareStr)
090    { return CmtNGet.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
091    public static CommentNode nthFromEnd (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Pattern p)
092    { return CmtNGet.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
093    public static CommentNode nthFromEnd (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<String> p)
094    { return CmtNGet.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), p); }
095
096    // ********************************************************************************************
097    // ALL methods
098    // ********************************************************************************************
099
100    // **** All: no sPos, ePos
101    public static Vector<CommentNode> all (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)
102    { return CmtNGet.all (html, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
103    public static Vector<CommentNode> all (Vector<? extends HTMLNode> html, Pattern p)
104    { return CmtNGet.all (html, new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
105    public static Vector<CommentNode> all (Vector<? extends HTMLNode> html, Predicate<String> p)
106    { return CmtNGet.all (html, new LV(html, 0, -1), p); }
107
108
109    // **** All: CRITERIA INCLUDES sPos, ePos
110    public static Vector<CommentNode> all (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)
111    { return CmtNGet.all (html, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
112    public static Vector<CommentNode> all (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)
113    { return CmtNGet.all (html, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
114    public static Vector<CommentNode> all (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)
115    { return CmtNGet.all (html, new LV(html, sPos, ePos), p); }
116
117
118    // **** AllExcept: no sPos, ePos
119    public static Vector<CommentNode> allExcept (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)
120    { return CmtNGet.allExcept (html, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); }
121    public static Vector<CommentNode> allExcept (Vector<? extends HTMLNode> html, Pattern p)
122    { return CmtNGet.allExcept (html, new LV(html, 0, -1), ARGCHECK.REGEX(p)); }
123    public static Vector<CommentNode> allExcept (Vector<? extends HTMLNode> html, Predicate<String> p)
124    { return CmtNGet.allExcept (html, new LV(html, 0, -1), p); }
125
126
127    // **** AllExcept: CRITERIA INCLUDES sPos, ePos
128    public static Vector<CommentNode> allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)
129    { return CmtNGet.allExcept (html, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); }
130    public static Vector<CommentNode> allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)
131    { return CmtNGet.allExcept (html, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); }
132    public static Vector<CommentNode> allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)
133    { return CmtNGet.allExcept (html, new LV(html, sPos, ePos), p); }
134}