Package Torello.HTML.NodeSearch
Class InnerTagCount
- java.lang.Object
-
- Torello.HTML.NodeSearch.InnerTagCount
-
public class InnerTagCount extends java.lang.Object
InnerTagCount 🠞InnerTag:This implies that Attribute key-value pairs located within the HTMLTagNodeinstances themselves are used as a search criteria for retrievingTagNode's.
Count:This implies that the method will count the number of matches that are found, and return that count/number as a integer.
Searches Vectorized-HTML for Tag-Matches using Inner-Tag (attribute) names & values as search-criteria, and returns the number of matches that were found.
Methods Available
Method Explanation all (...) These methods all return a positive (or zero) integer that represents a count of every TagNodematch found in the vectorized-page parameter'html'.Method Parameters
Parameter Explanation Vector<? extends HTMLNode> htmlThis represents any vectorized HTML page, sub-page, or list of partial-elements. int nthThis represents the 'nth'match of a comparisonfor-loop. When the method-signature used includes the parameter'nth', the firstn-1matches that are found - will be skipped, and the'nth'match is, instead, returned.
EXCEPTIONS: AnNExceptionshall throw if the value of parameter'nth'is zero, negative, or larger than the size of the input html-Vector.int sPos, int ePosWhen these parameters are present, only HTMLNode'sthat are found between the specifiedVectorindices will be considered for matching with the search criteria.
NOTE: In every situation where the parametersint sPos, int ePosare used, parameter'ePos'will accept a negative value, but parameter'sPos'will not. When'ePos'is passed a negative-value, the internalLV('Loop Variable Counter') will have itspublic final int endfield set to the length of the vectorized-html page that was passed. (html.size()of parameterVector<HTMLNode> html).
EXCEPTIONS: AnIndexOutOfBoundsExceptionwill be thrown if:- If
sPosis negative, or ifsPosis greater-than or equal-to the size of the inputVector - If
ePosis zero, or greater than the size of the inputVector. - If
sPosis a larger integer thanePos
String htmlTagWhen this parameter is present, only HTMLNode'swhich are both instances ofclass TagNode*and* have aTagNode.tokfield whose value is equal to this parameter'htmlTag', will be returned as matches.
COMMON EXAMPLES: Some common examples of valid'htmlTags'are:a, div, img, table, tr, metaas well as all other valid HTML element-tokens.
NOTE: This comparison is performed using a case-insensitive compare-method.
EXCEPTIONS: If this parameter is not a valid HTML element, anHTMLTokExceptionwill be thrown.String... htmlTagsWhen this parameter is present, only HTMLNode'swhich are both instances ofclass TagNode*and* whoseTagNode.tokfieldString-value matches (is equal to) at least one of the elements in thisVarArgs Stringparameter-set will be considered for a match. The same example HTML elements used in the previous parameter description apply here as well (a, div, img, table, tr, meta) etc...
NOTE: This comparison is performed using a case-insensitive compare-method.
EXCEPTIONS: If even one of the elements in this parameter-set is an invalid HTML token, anHTMLTokExceptionwill be thrown.
FINALLY: This parameter is only available as an option for search-methods that utilize thePredicate<TagNode>parameter-option too. Most of the search-method options available in this class allow only one HTML 'token' element as a search parameter option.String innerTagThis parameter is mandatory for every method here, except one's that receive a Predicate<TagNode>parameter. This parameter is used to identify the HTML-attribute or "Inner Tag" for whose values the programmer is comparing or testing.
NOTE: The comparison's performed on the HTML element for the attribute name are performed using a case-insensitive compare-method.
EXCEPTIONS: AnInnerTagKeyExceptionwill be thrown if this parameter does not represent a valid HTML attribute name.
USE: Whenever this parameter is present, the value retrieved from the invokation oftagNode.AV(innerTag)are always passed to the text-comparing methods listed below.
MOST COMMON: The most common exampleString'sused for parameter'innerTag'(also called 'attribute') would include tags such as:'id', 'class', 'src', 'href', 'style', 'width', 'onclick', 'onload', etc...TextComparitor tcWORKS WITH: This parameter works in coordination with parameter 'innerTag'. After the Attribute-value is retrieved from an HTML-element by method call:tagNode.AV(innerTag);The results from this invokation are sent toTextComparitorparameter'tc'.
ALSO WITH: This parameter also utilizes / works alongside theString... compareStrparameter for performing it's comparisons of the attribute list inside of a given HTML elementTagNode.
When this parameter is present in a method-signature parameter-list, the decision of whether aTagNodeis to be included in the search result-set is defined by this parameter'sBiPredicate.test(...)method.TextComparitoris a JavaBiPredicate<String, String[]>, which compares the attribute-value that was retrieved with a list of compare-String's(parameter'compareStr').Pattern pWORKS WITH: This parameter works in coordination with parameter 'innerTag'. After the Attribute-value is retrieved from HTML-element by method call:tagNode.AV(innerTag);The results from this call are sent to Regular-ExpressionPattern 'p'.
When this parameter is present in the method-signature parameter-list, the decision of whether aTagNodeis to be included in the search result-set are made by the regular expression generated'Matcher'against the attribute-value that was retrieved.
Specifically:p.asPredicate().test(attribute_value)Predicate<String> pWORKS WITH: This parameter works in coordination with parameter 'innerTag'. After the Attribute-value is retrieved from an HTML-element by method call:tagNode.AV(innerTag);The results from this call are sent to this JavaFunctional Interface Predicateparameter'p'.
When this parameter is present in the method-signature parameter-list, the decision of whether aTagNodeis to be included in the search result-set are made by the results of the JavaPredicate.test(String)method.
Specifically:p.test(attribute_value)String... compareStrWORKS WITH: This parameter works in coordination with parameter TextComparitor tc. This parameter supplies theString'swith which the comparisons of the attribute-value may be compared.
For Example: If the following values (below) were passed to these search-methods:- If:
'innerTag'were equal to'class' - And:
'tc'were equal toTextComparitor.C - And:
'compareStr'were equal to'MyMainClass'
The search would match any and allTagNodeinstances whose CSS'class'contained'MyMainClass'Predicate<TagNode>When this parameter is present in the method-signature parameter-list, the decision of whether a TagNodeis to be included in the search result-set are made by calling thisPredicate's test(TagNode)method.Return Values:
intreturns a count of how many TagNode's were identified on the vectorized-page parameter'html'that had attributes whose value matched the specified criteria
Hi-Lited Source-Code:This File's Source Code:
- View Here: Torello/HTML/NodeSearch/InnerTagCount.java
- Open New Browser-Tab: Torello/HTML/NodeSearch/InnerTagCount.java
File Size: 5,399 Bytes Line Count: 89 '\n' Characters Found
Actual Search Loop Class:
- View Here: SearchLoops/InnerTags/ITCount.java
- Open New Browser-Tab: SearchLoops/InnerTags/ITCount.java
File Size: 1,673 Bytes Line Count: 57 '\n' Characters Found
Argument Checker Class:
- View Here: ARGCHECK.java
- Open New Browser-Tab: ARGCHECK.java
File Size: 17,874 Bytes Line Count: 425 '\n' Characters Found
Stateless Class:This class neither contains any program-state, nor can it be instantiated. The@StaticFunctionalAnnotation may also be called 'The Spaghetti Report'.Static-Functionalclasses are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's@StatelessAnnotation.
- 1 Constructor(s), 1 declared private, zero-argument constructor
- 20 Method(s), 20 declared static
- 0 Field(s)
-
-
Method Summary
All Matches, Any HTML-Tag Will Match Attribute-Value Test Modifier and Type Method Presence-Of, Only static intall(Vector<? extends HTMLNode> html, String innerTag)String-Predicate static intall(Vector<? extends HTMLNode> html, String innerTag, Predicate<String> attributeValuePred)Regular-Expression static intall(Vector<? extends HTMLNode> html, String innerTag, Pattern p)TextComparitor static intall(Vector<? extends HTMLNode> html, String innerTag, TextComparitor tc, String... compareStr)This search expects a customized Predicate<TagNode>orAVTinstanceNONE static intall(Vector<? extends HTMLNode> html, Predicate<TagNode> p)All Matches, Specified HTML-Tag(s) Only Attribute-Value Test Modifier and Type Method Presence-Of, Only static intall(Vector<? extends HTMLNode> html, String htmlTag, String innerTag)String-Predicate static intall(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, Predicate<String> attributeValuePred)Regular-Expression static intall(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, Pattern p)TextComparitor static intall(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, TextComparitor tc, String... compareStr)This search expects a customized Predicate<TagNode>orAVTinstanceNONE static intall(Vector<? extends HTMLNode> html, Predicate<TagNode> p, String... htmlTags)All Matches, Range Limited, Any HTML-Tag Will Match Attribute-Value Test Modifier and Type Method Presence-Of, Only static intall(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag)String-Predicate static intall(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, Predicate<String> attributeValuePred)Regular-Expression static intall(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, Pattern p)TextComparitor static intall(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, TextComparitor tc, String... compareStr)This search expects a customized Predicate<TagNode>orAVTinstanceNONE static intall(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<TagNode> p)All Matches, Range Limited, Specified HTML-Tag(s) Only Attribute-Value Test Modifier and Type Method Presence-Of, Only static intall(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag)String-Predicate static intall(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, Predicate<String> attributeValuePred)Regular-Expression static intall(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, Pattern p)TextComparitor static intall(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, TextComparitor tc, String... compareStr)This search expects a customized Predicate<TagNode>orAVTinstanceNONE static intall(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<TagNode> p, String... htmlTags)
-