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.TextNodes.TxNRemove; 009import Torello.Java.LV; 010 011/** 012 * Removes {@link TextNode} instances from Vectorized-HTML that match a search-criteria specified 013 * by a {@code String-Predicate}, Regular Expression or {@link TextComparitor}. 014 * 015 * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=TextNodeRemove> 016 */ 017@Torello.JavaDoc.JDHeaderBackgroundImg 018@Torello.JavaDoc.StaticFunctional 019public class TextNodeRemove 020{ 021 private TextNodeRemove() { } 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 TxNRemove.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 TxNRemove.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 TxNRemove.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 TxNRemove.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 TxNRemove.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 TxNRemove.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 TxNRemove.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 TxNRemove.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 TxNRemove.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 TxNRemove.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 TxNRemove.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 TxNRemove.nthFromEnd (html, 1, new LV(html, sPos, ePos), p); } 058 059 // ******************************************************************************************** 060 // NEW ADDITIONS: nth and nthFromEnd 061 // ******************************************************************************************** 062 063 // **** first: no sPos, ePos 064 public static int nth (Vector<? extends HTMLNode> html, int nth, TextComparitor tc, String... compareStr) 065 { return TxNRemove.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 TxNRemove.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 TxNRemove.nth (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), p); } 070 071 // **** first: 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 TxNRemove.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 TxNRemove.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 TxNRemove.nth (html, ARGCHECK.n(nth, html), new LV(html, sPos, ePos), p); } 078 079 // **** last: no sPos, ePos 080 public static int nthFromEnd (Vector<? extends HTMLNode> html, int nth, TextComparitor tc, String... compareStr) 081 { return TxNRemove.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 TxNRemove.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 TxNRemove.nthFromEnd (html, ARGCHECK.n(nth, html), new LV(html, 0, -1), p); } 086 087 // **** last: 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 TxNRemove.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 TxNRemove.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 TxNRemove.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 TxNRemove.all (html, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); } 102 public static int all (Vector<? extends HTMLNode> html, Pattern p) 103 { return TxNRemove.all (html, new LV(html, 0, -1), ARGCHECK.REGEX(p)); } 104 public static int all (Vector<? extends HTMLNode> html, Predicate<String> p) 105 { return TxNRemove.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 TxNRemove.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 TxNRemove.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 TxNRemove.all (html, new LV(html, sPos, ePos), p); } 114 115 116 // **** allExcept: no sPos, ePos 117 public static int allExcept (Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr) 118 { return TxNRemove.allExcept (html, new LV(html, 0, -1), ARGCHECK.TC(tc, compareStr)); } 119 public static int allExcept (Vector<? extends HTMLNode> html, Pattern p) 120 { return TxNRemove.allExcept (html, new LV(html, 0, -1), ARGCHECK.REGEX(p)); } 121 public static int allExcept (Vector<? extends HTMLNode> html, Predicate<String> p) 122 { return TxNRemove.allExcept (html, new LV(html, 0, -1), p); } 123 124 // **** allExcept: CRITERIA INCLUDES sPos, ePos 125 public static int allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr) 126 { return TxNRemove.allExcept (html, new LV(html, sPos, ePos), ARGCHECK.TC(tc, compareStr)); } 127 public static int allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p) 128 { return TxNRemove.allExcept (html, new LV(html, sPos, ePos), ARGCHECK.REGEX(p)); } 129 public static int allExcept (Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p) 130 { return TxNRemove.allExcept (html, new LV(html, sPos, ePos), p); } 131}