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.CmtNPeek; 009import Torello.Java.LV; 010 011/** 012 * "Peeks" into Vectorized-HTML for Comments matching a search-criteria and returns the 013 * {@code Vector}-index where matches are found, <I><B>and</B></I> the {@link CommentNode} at 014 * that {@code Vector}-location, as an instance of {@link CommentNodeIndex}. 015 * 016 * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=CommentNodePeek> 017 */ 018@Torello.JavaDoc.JDHeaderBackgroundImg 019@Torello.JavaDoc.StaticFunctional 020public class CommentNodePeek 021{ 022 private CommentNodePeek() { } 023 024 // ******************************************************************************************** 025 // FIRST, LAST 026 // ******************************************************************************************** 027 028 // **** First: no sPos, ePos 029 public static CommentNodeIndex first (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr) 030 { return CmtNPeek.nth (html, 1, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); } 031 public static CommentNodeIndex first (Vector<? extends HTMLNode> html, Pattern p) 032 { return CmtNPeek.nth (html, 1, new LV(html, 0, -1), ARGCHECK.REGEX(p)); } 033 public static CommentNodeIndex first (Vector<? extends HTMLNode> html, Predicate<String> p) 034 { return CmtNPeek.nth (html, 1, new LV(html, 0, -1), p); } 035 036 // **** First: CRITERIA INCLUDES sPos, ePos 037 public static CommentNodeIndex first (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr) 038 { return CmtNPeek.nth (html, 1, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); } 039 public static CommentNodeIndex first (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p) 040 { return CmtNPeek.nth (html, 1, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); } 041 public static CommentNodeIndex first (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p) 042 { return CmtNPeek.nth (html, 1, new LV(html, sPos, ePos), p); } 043 044 // **** Last: no sPos, ePos 045 public static CommentNodeIndex last (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr) 046 { return CmtNPeek.nthFromEnd (html, 1, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); } 047 public static CommentNodeIndex last (Vector<? extends HTMLNode> html, Pattern p) 048 { return CmtNPeek.nthFromEnd (html, 1, new LV(html, 0, -1), ARGCHECK.REGEX(p)); } 049 public static CommentNodeIndex last (Vector<? extends HTMLNode> html, Predicate<String> p) 050 { return CmtNPeek.nthFromEnd (html, 1, new LV(html, 0, -1), p); } 051 052 // **** Last: CRITERIA INCLUDES sPos, ePos 053 public static CommentNodeIndex last (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr) 054 { return CmtNPeek.nthFromEnd (html, 1, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); } 055 public static CommentNodeIndex last (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p) 056 { return CmtNPeek.nthFromEnd (html, 1, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); } 057 public static CommentNodeIndex last (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p) 058 { return CmtNPeek.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 CommentNodeIndex nth (Vector<? extends HTMLNode> html, int nth, TextComparitor tc, String... compareStr) 066 { return CmtNPeek.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); } 067 public static CommentNodeIndex nth (Vector<? extends HTMLNode> html, int nth, Pattern p) 068 { return CmtNPeek.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.REGEX(p)); } 069 public static CommentNodeIndex nth (Vector<? extends HTMLNode> html, int nth, Predicate<String> p) 070 { return CmtNPeek.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), p); } 071 072 // **** First: CRITERIA INCLUDES sPos, ePos 073 public static CommentNodeIndex nth (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TextComparitor tc, String... compareStr) 074 { return CmtNPeek.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); } 075 public static CommentNodeIndex nth (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Pattern p) 076 { return CmtNPeek.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); } 077 public static CommentNodeIndex nth (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<String> p) 078 { return CmtNPeek.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), p); } 079 080 // **** Last: no sPos, ePos 081 public static CommentNodeIndex nthFromEnd (Vector<? extends HTMLNode> html, int nth, TextComparitor tc, String... compareStr) 082 { return CmtNPeek.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); } 083 public static CommentNodeIndex nthFromEnd (Vector<? extends HTMLNode> html, int nth, Pattern p) 084 { return CmtNPeek.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), ARGCHECK.REGEX(p)); } 085 public static CommentNodeIndex nthFromEnd (Vector<? extends HTMLNode> html, int nth, Predicate<String> p) 086 { return CmtNPeek.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), p); } 087 088 // **** Last: CRITERIA INCLUDES sPos, ePos 089 public static CommentNodeIndex nthFromEnd (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TextComparitor tc, String... compareStr) 090 { return CmtNPeek.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); } 091 public static CommentNodeIndex nthFromEnd (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Pattern p) 092 { return CmtNPeek.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); } 093 public static CommentNodeIndex nthFromEnd (Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<String> p) 094 { return CmtNPeek.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<CommentNodeIndex> all (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr) 102 { return CmtNPeek.all (html, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); } 103 public static Vector<CommentNodeIndex> all (Vector<? extends HTMLNode> html, Pattern p) 104 { return CmtNPeek.all (html, new LV(html, 0, -1), ARGCHECK.REGEX(p)); } 105 public static Vector<CommentNodeIndex> all (Vector<? extends HTMLNode> html, Predicate<String> p) 106 { return CmtNPeek.all (html, new LV(html, 0, -1), p); } 107 108 109 // **** All: CRITERIA INCLUDES sPos, ePos 110 public static Vector<CommentNodeIndex> all (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr) 111 { return CmtNPeek.all (html, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); } 112 public static Vector<CommentNodeIndex> all (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p) 113 { return CmtNPeek.all (html, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); } 114 public static Vector<CommentNodeIndex> all (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p) 115 { return CmtNPeek.all (html, new LV(html, sPos, ePos), p); } 116 117 118 // **** AllExcept: no sPos, ePos 119 public static Vector<CommentNodeIndex> allExcept (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr) 120 { return CmtNPeek.allExcept (html, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); } 121 public static Vector<CommentNodeIndex> allExcept (Vector<? extends HTMLNode> html, Pattern p) 122 { return CmtNPeek.allExcept (html, new LV(html, 0, -1), ARGCHECK.REGEX(p)); } 123 public static Vector<CommentNodeIndex> allExcept (Vector<? extends HTMLNode> html, Predicate<String> p) 124 { return CmtNPeek.allExcept (html, new LV(html, 0, -1), p); } 125 126 127 // **** AllExcept: CRITERIA INCLUDES sPos, ePos 128 public static Vector<CommentNodeIndex> allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr) 129 { return CmtNPeek.allExcept (html, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); } 130 public static Vector<CommentNodeIndex> allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p) 131 { return CmtNPeek.allExcept (html, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); } 132 public static Vector<CommentNodeIndex> allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p) 133 { return CmtNPeek.allExcept (html, new LV(html, sPos, ePos), p); } 134}