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.InnerTags.ITCount; 009import Torello.Java.LV; 010 011/** 012 * Searches Vectorized-HTML for Tag-Matches using Inner-Tag (attribute) names & values as 013 * search-criteria, and returns the number of matches that were found. 014 * 015 * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=InnerTagCount> 016 */ 017@Torello.JavaDoc.JDHeaderBackgroundImg 018@Torello.JavaDoc.StaticFunctional 019public class InnerTagCount 020{ 021 private InnerTagCount() { } 022 023 // **** Find-First, CRITERIA: htmlTag, sPos, ePos 024 public static int all(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag) 025 { return ITCount.ALL(html, new LV(html, sPos, ePos), ARGCHECK.htmlTag(htmlTag), ARGCHECK.innerTag(innerTag), ARGCHECK.TRUE); } 026 027 public static int all(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, TextComparitor tc, String... compareStr) 028 { return ITCount.ALL(html, new LV(html, sPos, ePos), ARGCHECK.htmlTag(htmlTag), ARGCHECK.innerTag(innerTag), ARGCHECK.TC(tc, compareStr)); } 029 030 public static int all(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, Pattern p) 031 { return ITCount.ALL(html, new LV(html, sPos, ePos), ARGCHECK.htmlTag(htmlTag), ARGCHECK.innerTag(innerTag), ARGCHECK.REGEX(p)); } 032 033 public static int all(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, Predicate<String> attributeValuePred) 034 { return ITCount.ALL(html, new LV(html, sPos, ePos), ARGCHECK.htmlTag(htmlTag), ARGCHECK.innerTag(innerTag), attributeValuePred); } 035 036 public static int all(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<TagNode> p, String... htmlTags) 037 { return ITCount.ALL(html, new LV(html, sPos, ePos), p, ARGCHECK.htmlTags(htmlTags)); } 038 039 040 // **** Find-All, CRITERIA: htmlTag 041 public static int all(Vector<? extends HTMLNode> html, String htmlTag, String innerTag) 042 { return ITCount.ALL(html, new LV(html, 0, -1), ARGCHECK.htmlTag(htmlTag), ARGCHECK.innerTag(innerTag), ARGCHECK.TRUE); } 043 044 public static int all(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, TextComparitor tc, String... compareStr) 045 { return ITCount.ALL(html, new LV(html, 0, -1), ARGCHECK.htmlTag(htmlTag), ARGCHECK.innerTag(innerTag), ARGCHECK.TC(tc, compareStr)); } 046 047 public static int all(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, Pattern p) 048 { return ITCount.ALL(html, new LV(html, 0, -1), ARGCHECK.htmlTag(htmlTag), ARGCHECK.innerTag(innerTag), ARGCHECK.REGEX(p)); } 049 050 public static int all(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, Predicate<String> attributeValuePred) 051 { return ITCount.ALL(html, new LV(html, 0, -1), ARGCHECK.htmlTag(htmlTag), ARGCHECK.innerTag(innerTag), attributeValuePred); } 052 053 public static int all(Vector<? extends HTMLNode> html, Predicate<TagNode> p, String... htmlTags) 054 { return ITCount.ALL(html, new LV(html, 0, -1), p, ARGCHECK.htmlTags(htmlTags)); } 055 056 057 // **** Find-First, CRITERIA: sPos, ePos 058 public static int all(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag) 059 { return ITCount.ALL(html, new LV(html, sPos, ePos), null, ARGCHECK.innerTag(innerTag), ARGCHECK.TRUE); } 060 061 public static int all(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, TextComparitor tc, String... compareStr) 062 { return ITCount.ALL(html, new LV(html, sPos, ePos), null, ARGCHECK.innerTag(innerTag), ARGCHECK.TC(tc, compareStr)); } 063 064 public static int all(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, Pattern p) 065 { return ITCount.ALL(html, new LV(html, sPos, ePos), null, ARGCHECK.innerTag(innerTag), ARGCHECK.REGEX(p)); } 066 067 public static int all(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, Predicate<String> attributeValuePred) 068 { return ITCount.ALL(html, new LV(html, sPos, ePos), null, ARGCHECK.innerTag(innerTag), attributeValuePred); } 069 070 public static int all(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<TagNode> p) 071 { return ITCount.ALL(html, new LV(html, sPos, ePos), p); } 072 073 074 // **** Find-All, ALL-CRITERIA-NULL 075 public static int all(Vector<? extends HTMLNode> html, String innerTag) 076 { return ITCount.ALL(html, new LV(html, 0, -1), null, ARGCHECK.innerTag(innerTag), ARGCHECK.TRUE); } 077 078 public static int all(Vector<? extends HTMLNode> html, String innerTag, TextComparitor tc, String... compareStr) 079 { return ITCount.ALL(html, new LV(html, 0, -1), null, ARGCHECK.innerTag(innerTag), ARGCHECK.TC(tc, compareStr)); } 080 081 public static int all(Vector<? extends HTMLNode> html, String innerTag, Pattern p) 082 { return ITCount.ALL(html, new LV(html, 0, -1), null, ARGCHECK.innerTag(innerTag), ARGCHECK.REGEX(p)); } 083 084 public static int all(Vector<? extends HTMLNode> html, String innerTag, Predicate<String> attributeValuePred) 085 { return ITCount.ALL(html, new LV(html, 0, -1), null, ARGCHECK.innerTag(innerTag), attributeValuePred); } 086 087 public static int all(Vector<? extends HTMLNode> html, Predicate<TagNode> p) 088 { return ITCount.ALL(html, new LV(html, 0, -1), p); } 089}