Package Torello.HTML.NodeSearch
Class TextNodePeek
- java.lang.Object
-
- Torello.HTML.NodeSearch.TextNodePeek
-
public class TextNodePeek extends java.lang.Object
TextNodePeek 🠞TextNode:This implies thatTagNodeelements are ignored completely in this search, and instead, the "text" (a.k.a. 'page-content'), represented as instances ofTextNode, are searched.
Peek:This implies that BOTH theVector-index / indices where a match occurred, AND the theHTMLNodeat that index are SIMULTANEOUSLY returned by these methods - using the data-type classesNodeIndexandSubSection.
"Peeks" into Vectorized-HTML for text matching a search-criteria and returns theVector-index where matches are found, and theTextNodeat thatVector-location, as an instance ofTextNodeIndex.
Methods Available
Method Explanation first (...) This will retrieve the first TextNodematch found in the vectorized-page parameter'html', along with the underlyingHTMLNode Vector-Index where this match was found. This object-reference andintare returned as the result, wrapped in the Wrapper-ClassTextNodeIndex.nth (...) This will retrieve the nth TextNodematch found in the vectorized-page parameter'html', along with the underlyingHTMLNode Vector-Index where this match was found. This object-reference andintare returned as the result, wrapped in the Wrapper-ClassTextNodeIndex.last (...) This will retrieve the last TextNodematch found in the vectorized-page parameter'html', along with the underlyingHTMLNode Vector-Index where this match was found. This object-reference andintare returned as the result, wrapped in the Wrapper-ClassTextNodeIndex.nthFromEnd (...) This will retrieve the nth-from-last TextNodematch found in the vectorized-page parameter'html', along with the underlyingHTMLNode Vector-Index where this match was found. This object-reference andintare returned as the result, wrapped in the Wrapper-ClassTextNodeIndex.all (...) This will return a Vector<TextNodeIndex>that contains everyTextNodethat matches the specified search-criteria found inside the vectorized-page parameter'html'. Each match is wrapped in the Wrapper-ClassTextNodeIndexthat stores (encapsulates) both theTextNodeobject-reference as well as theintindex to the HTMLVectorwhere the match was found. These results are then added into the returnVector<TextNodeIndex>.allExcept (...) This will return a Vector<TextNodeIndex>that contains everyTextNodethat does not match the specified search-criteria found inside the vectorized-page parameter'html'. Each 'un-match' is wrapped in the Wrapper-ClassTextNodeIndexthat stores (encapsulates) both theTextNodeobject-reference as well as theintindex to the HTMLVectorwhere the match was found. These results are then added into the returnVector<TextNodeIndex>.Method Parameters
Parameter Explanation Vector<? 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
TextComparitor tcWORKS WITH: This parameter utilizes / works-with parameter String... compareStrto perform the requested comparisons. The comparisons are computed using theTextNode.str String-field of aTextNode.
When this parameter is present in the method-signature parameter-list, the decision of whether aTextNodeis to be included in the search result-set is defined by this parameter'sFunctionalInterface Predicate 'test'method.TextComparitoris a JavaBiPredicate<String, String[]>which compares its firstString-parameter against theString'sin its second.Pattern pThis parameter references Java's "Regular Expression" processing engine. If the method-signature includes the java.util.regex.Patternparameter, the search-loops will use the standard Regular-Expression pattern matching routine:p.asPredicate().test(text_node.str)when deciding whichTextNode's"match" this search-criteria.Predicate<String> pWhen this parameter is present in the method-signature parameter-list, the decision of whether a TextNodeis to be included in the search result-set are made by the results of the JavaPredicate.test(String)method.
Specifically:p.test(text_node.str)String... compareStrWORKS WITH: This parameter works in coordination with TextComparitor tc. This parameter supplies the strings with which the comparisons of theTextNode.strfield may be compared.Return Values:
TextNodeIndexrepresents a matchedTextNode, and it's position/vector-index, from the html vectorized-page parameter'html'- A return value of
nullimplies no matches were found. Vector<TextNodeIndex>- A vector ofTextNodeIndexrepresents all matches from the vectorized-page parameter'html'. Theclass TextNodeIndexis a return-value way of encapsulating both theTextNodeand it's index into the underlyingHTMLNode Vector.- A zero-length
Vector<TextNodeIndex>means no matches were found on the page or sub-page. Empty Vectors are returned from any method where the possibility existed for multiple-matches being provided as a result-set.
Hi-Lited Source-Code:This File's Source Code:
- View Here: Torello/HTML/NodeSearch/TextNodePeek.java
- Open New Browser-Tab: Torello/HTML/NodeSearch/TextNodePeek.java
File Size: 9,115 Bytes Line Count: 134 '\n' Characters Found
Actual Search Loop Class:
- View Here: SearchLoops/TextNodes/TxNPeek.java
- Open New Browser-Tab: SearchLoops/TextNodes/TxNPeek.java
File Size: 1,945 Bytes Line Count: 70 '\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
- 36 Method(s), 36 declared static
- 0 Field(s)
-
-
Method Summary
All Matches Modifier and Type Method static Vector<TextNodeIndex>all(Vector<? extends HTMLNode> html, Predicate<String> p)static Vector<TextNodeIndex>all(Vector<? extends HTMLNode> html, Pattern p)static Vector<TextNodeIndex>all(Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)All Matches, Range Limited Modifier and Type Method static Vector<TextNodeIndex>all(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)static Vector<TextNodeIndex>all(Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)static Vector<TextNodeIndex>all(Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)All Non-Matches Modifier and Type Method static Vector<TextNodeIndex>allExcept(Vector<? extends HTMLNode> html, Predicate<String> p)static Vector<TextNodeIndex>allExcept(Vector<? extends HTMLNode> html, Pattern p)static Vector<TextNodeIndex>allExcept(Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)All Non-Matches, Range Limited Modifier and Type Method static Vector<TextNodeIndex>allExcept(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)static Vector<TextNodeIndex>allExcept(Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)static Vector<TextNodeIndex>allExcept(Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)First Match Modifier and Type Method static TextNodeIndexfirst(Vector<? extends HTMLNode> html, Predicate<String> p)static TextNodeIndexfirst(Vector<? extends HTMLNode> html, Pattern p)static TextNodeIndexfirst(Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)First Match, Range Limited Modifier and Type Method static TextNodeIndexfirst(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)static TextNodeIndexfirst(Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)static TextNodeIndexfirst(Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)Last Match Modifier and Type Method static TextNodeIndexlast(Vector<? extends HTMLNode> html, Predicate<String> p)static TextNodeIndexlast(Vector<? extends HTMLNode> html, Pattern p)static TextNodeIndexlast(Vector<? extends HTMLNode> html, TextComparitor tc, String... compareStr)Last Match, Range Limited Modifier and Type Method static TextNodeIndexlast(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<String> p)static TextNodeIndexlast(Vector<? extends HTMLNode> html, int sPos, int ePos, Pattern p)static TextNodeIndexlast(Vector<? extends HTMLNode> html, int sPos, int ePos, TextComparitor tc, String... compareStr)Nth Match Modifier and Type Method static TextNodeIndexnth(Vector<? extends HTMLNode> html, int nth, Predicate<String> p)static TextNodeIndexnth(Vector<? extends HTMLNode> html, int nth, Pattern p)static TextNodeIndexnth(Vector<? extends HTMLNode> html, int nth, TextComparitor tc, String... compareStr)Nth Match, Range Limited Modifier and Type Method static TextNodeIndexnth(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<String> p)static TextNodeIndexnth(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Pattern p)static TextNodeIndexnth(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TextComparitor tc, String... compareStr)Nth Match From End Modifier and Type Method static TextNodeIndexnthFromEnd(Vector<? extends HTMLNode> html, int nth, Predicate<String> p)static TextNodeIndexnthFromEnd(Vector<? extends HTMLNode> html, int nth, Pattern p)static TextNodeIndexnthFromEnd(Vector<? extends HTMLNode> html, int nth, TextComparitor tc, String... compareStr)Nth Match From End, Range Limited Modifier and Type Method static TextNodeIndexnthFromEnd(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<String> p)static TextNodeIndexnthFromEnd(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Pattern p)static TextNodeIndexnthFromEnd(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, TextComparitor tc, String... compareStr)
-