Class InnerTagRemoveInclusive


  • public class InnerTagRemoveInclusive
    extends java.lang.Object
    InnerTag Remove Inclusive - Documentation.

    InnerTagRemoveInclusive =>

    1. InnerTag: This implies that Attribute key-value pairs located within the HTML TagNode instances themselves are used as a search criteria for retrieving TagNode's.
    2. Remove: This implies that node matches are removed from the underlying input-Vector. This method will return a total count of the number of nodes removed.
    3. Inclusive: The word "Inclusive" is used to indicate that all HTMLNode's between an opening and closing HTML-tag is requested. The concept is extremely similar to the Java-Script feature / "term" '.innerHTML', although in this (JavaHTML) JAR Library, no DOM Trees are ever constructed. This method will return all nodes between the first matching TagNode element, and its closing TagNode element pair.

    Methods Available

    Method Explanation
    first (...) This will remove the first, complete, Vector<HTMLNode> sub-list or sub-page found inside the vectorized HTML page parameter that matches the specified search-criteria.
    nth (...) This will remove the nth, complete, Vector<HTMLNode> sub-list or sub-page found inside the vectorized HTML page parameter that matches the specified search-criteria.
    last (...) This will remove the last, complete, Vector<HTMLNode> sub-list or sub-page found inside the vectorized HTML page parameter that matches the specified search-criteria.
    nthFromEnd (...) This will remove the nth-from-last, complete, Vector<HTMLNode> sub-list or sub-page found inside the vectorized HTML page parameter that matches the specified search-criteria.
    all (...) This will remove the each and every, complete, Vector<HTMLNode> sub-list or sub-page found inside the vectorized HTML page parameter that matches the specified search-criteria.

    Method Parameters

    Parameter Explanation
    Vector<? extends HTMLNode> html This represents any vectorized HTML page, sub-page, or list of partial-elements.
    int nth This represents the 'nth' match of a comparison for-loop. When the method-signature used includes the parameter 'nth' , the first n-1 matches that are found - will be skipped, and the 'nth' match is, instead, returned.

    EXCEPTIONS: An NException shall throw if the value of parameter 'nth' is zero, negative, or larger than the size of the input html-Vector.
    int sPos, int ePos When these parameters are present, only HTMLNode's that are found between the specified Vector indices will be considered for matching with the search criteria.

    NOTE: In every situation where the parameters int sPos, int ePos are used, parameter 'ePos' will accept a negative value, but parameter 'sPos' will not. When 'ePos' is passed a negative-value, the internal LV ('Loop Variable Counter') will have its public final int end field set to the length of the vectorized-html page that was passed. (html.size() of parameter Vector<HTMLNode> html).

    EXCEPTIONS: An IndexOutOfBoundsException will be thrown if:

    • If sPos is negative, or if sPos is greater-than or equal-to the size of the input Vector
    • If ePos is zero, or greater than the size of the input Vector.
    • If sPos is a larger integer than ePos
    String htmlTag When this parameter is present, only HTMLNode's which are both instances of class TagNode *and* have a TagNode.tok field 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, meta as 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, an HTMLTokException will be thrown.

    Also, since this is an inclusive search, an InclusiveException will be thrown if this parameter is an HTML singleton element (and, therefore, may not have a matching, closing tag/element).
    String... htmlTags When this parameter is present, only HTMLNode's which are both instances of class TagNode *and* whose TagNode.tok field String-value matches (is equal to) at least one of the elements in this VarArgs String parameter-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, an HTMLTokException will be thrown.

    FINALLY: This parameter is only available as an option for search-methods that utilize the Predicate<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 innerTag This 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: An InnerTagKeyException will be thrown if this parameter does not represent a valid HTML attribute name.

    USE: Whenever this parameter is present, the value retrieved from the invocation of tagNode.AV(innerTag) are always passed to the text-comparing methods listed below.

    MOST COMMON: The most common example String's used for parameter 'innerTag' (also called 'attribute') would include tags such as: 'id', 'class', 'src', 'href', 'style', 'width', 'onclick', 'onload', etc...
    TextComparitor tc WORKS 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 to TextComparitor parameter 'tc'.

    ALSO WITH: This parameter also utilizes / works alongside the String... compareStr parameter for performing it's comparisons of the attribute list inside of a given HTML element TagNode.

    When this parameter is present in a method-signature parameter-list, the decision of whether a TagNode is to be included in the search result-set is defined by this parameter's BiPredicate.test(...) method. TextComparitor is a Java BiPredicate<String, String[]>, which compares the attribute-value that was retrieved with a list of compare-String's (parameter 'compareStr').
    Pattern p WORKS 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-Expression Pattern 'p'.

    When this parameter is present in the method-signature parameter-list, the decision of whether a TagNode is 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.matcher(attribute_value).find() retrieved.
    Predicate<String> p WORKS 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 Java Functional Interface Predicate parameter 'p'.

    When this parameter is present in the method-signature parameter-list, the decision of whether a TagNode is to be included in the search result-set are made by the results of the Java Predicate.test(String) method.

    Specifically: p.test(attribute_value)
    String... compareStr WORKS WITH: This parameter works in coordination with parameter TextComparitor tc. This parameter supplies the String's with which the comparisons of the attribute-value may be compared.

    For Example: If the following values (below) were passed to these search-methods:

    1. If: 'innerTag' were equal to 'class'
    2. And: 'tc' were equal to TextComparitor.C
    3. And: 'compareStr' were equal to 'MyMainClass'

    The search would match any and all TagNode instances whose CSS 'class' contained 'MyMainClass'
    Predicate<TagNode> When this parameter is present in the method-signature parameter-list, the decision of whether a TagNode is to be included in the search result-set are made by calling this Predicate's test(TagNode) method.

    Return Values:

    All method return an integer-number that represents how many elements were removed from the vectorized-html page parameter 'html'

    Static (Functional) API: The methods in this class are all (100%) defined with the Java Key-Word / Key-Concept 'static'. Furthermore, there is no way to obtain an instance of this class, because there are no public (nor private) constructors. Java's Spring-Boot, MVC feature is *not* utilized because it flies directly in the face of the light-weight data-classes philosophy. This has many advantages over the rather ornate Component Annotations (@Component, @Service, @AutoWired, etc... 'Java Beans') syntax:

    • The methods here use the key-word 'static' which means (by implication) that there is no internal-state. Without any 'internal state' there is no need for constructors in the first place! (This is often the complaint by MVC Programmers).
    • A 'Static' (Functional-Programming) API expects to use fewer data-classes, and light-weight data-classes, making it easier to understand and to program.
    • The Vectorized HTML data-model allows more user-control over HTML parse, search, update & scrape. Also, memory management, memory leakage, and the Java Garbage Collector ought to be intelligible through the 'reuse' of the standard JDK class Vector for storing HTML Web-Page data.

    The power that object-oriented programming extends to a user is (mostly) limited to data-representation. Thinking of "Services" as "Objects" (Spring-MVC, 'Java Beans') is somewhat 'over-applying' the Object Oriented Programming Model. Like most classes in the Java-HTML JAR Library, this class backtracks to a more C-Styled Functional Programming Model (no Objects) - by re-using (quite profusely) the key-word static with all of its methods, and by sticking to Java's well-understood class Vector

    Internal-State: A user may click on this class' source code (see link below) to view any and all internally defined fields class. A cursory inspection of the code would prove that this class has precisely zero internally defined global fields (Spaghetti). All variables used by the methods in this class are local fields only, and therefore this class ought to be though of as 'state-less'.

    View Actual Hi-Lited Code Files:






    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method
      static int all​(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag)
      static int all​(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag)
      static int all​(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, Predicate<String> attributeValuePred)
      static int all​(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, Pattern p)
      static int all​(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, TextComparitor tc, String... compareStr)
      static int all​(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, Predicate<String> attributeValuePred)
      static int all​(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, Pattern p)
      static int all​(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, TextComparitor tc, String... compareStr)
      static int all​(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<TagNode> p)
      static int all​(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<TagNode> p, String... htmlTags)
      static int all​(Vector<? extends HTMLNode> html, String innerTag)
      static int all​(Vector<? extends HTMLNode> html, String htmlTag, String innerTag)
      static int all​(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, Predicate<String> attributeValuePred)
      static int all​(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, Pattern p)
      static int all​(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, TextComparitor tc, String... compareStr)
      static int all​(Vector<? extends HTMLNode> html, String innerTag, Predicate<String> attributeValuePred)
      static int all​(Vector<? extends HTMLNode> html, String innerTag, Pattern p)
      static int all​(Vector<? extends HTMLNode> html, String innerTag, TextComparitor tc, String... compareStr)
      static int all​(Vector<? extends HTMLNode> html, Predicate<TagNode> p)
      static int all​(Vector<? extends HTMLNode> html, Predicate<TagNode> p, String... htmlTags)
      static int first​(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag)
      static int first​(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag)
      static int first​(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, Predicate<String> attributeValuePred)
      static int first​(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, Pattern p)
      static int first​(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, TextComparitor tc, String... compareStr)
      static int first​(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, Predicate<String> attributeValuePred)
      static int first​(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, Pattern p)
      static int first​(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, TextComparitor tc, String... compareStr)
      static int first​(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<TagNode> p)
      static int first​(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<TagNode> p, String... htmlTags)
      static int first​(Vector<? extends HTMLNode> html, String innerTag)
      static int first​(Vector<? extends HTMLNode> html, String htmlTag, String innerTag)
      static int first​(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, Predicate<String> attributeValuePred)
      static int first​(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, Pattern p)
      static int first​(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, TextComparitor tc, String... compareStr)
      static int first​(Vector<? extends HTMLNode> html, String innerTag, Predicate<String> attributeValuePred)
      static int first​(Vector<? extends HTMLNode> html, String innerTag, Pattern p)
      static int first​(Vector<? extends HTMLNode> html, String innerTag, TextComparitor tc, String... compareStr)
      static int first​(Vector<? extends HTMLNode> html, Predicate<TagNode> p)
      static int first​(Vector<? extends HTMLNode> html, Predicate<TagNode> p, String... htmlTags)
      static int last​(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag)
      static int last​(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag)
      static int last​(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, Predicate<String> attributeValuePred)
      static int last​(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, Pattern p)
      static int last​(Vector<? extends HTMLNode> html, int sPos, int ePos, String htmlTag, String innerTag, TextComparitor tc, String... compareStr)
      static int last​(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, Predicate<String> attributeValuePred)
      static int last​(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, Pattern p)
      static int last​(Vector<? extends HTMLNode> html, int sPos, int ePos, String innerTag, TextComparitor tc, String... compareStr)
      static int last​(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<TagNode> p)
      static int last​(Vector<? extends HTMLNode> html, int sPos, int ePos, Predicate<TagNode> p, String... htmlTags)
      static int last​(Vector<? extends HTMLNode> html, String innerTag)
      static int last​(Vector<? extends HTMLNode> html, String htmlTag, String innerTag)
      static int last​(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, Predicate<String> attributeValuePred)
      static int last​(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, Pattern p)
      static int last​(Vector<? extends HTMLNode> html, String htmlTag, String innerTag, TextComparitor tc, String... compareStr)
      static int last​(Vector<? extends HTMLNode> html, String innerTag, Predicate<String> attributeValuePred)
      static int last​(Vector<? extends HTMLNode> html, String innerTag, Pattern p)
      static int last​(Vector<? extends HTMLNode> html, String innerTag, TextComparitor tc, String... compareStr)
      static int last​(Vector<? extends HTMLNode> html, Predicate<TagNode> p)
      static int last​(Vector<? extends HTMLNode> html, Predicate<TagNode> p, String... htmlTags)
      static int nth​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String innerTag)
      static int nth​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String htmlTag, String innerTag)
      static int nth​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String htmlTag, String innerTag, Predicate<String> attributeValuePred)
      static int nth​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String htmlTag, String innerTag, Pattern p)
      static int nth​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String htmlTag, String innerTag, TextComparitor tc, String... compareStr)
      static int nth​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String innerTag, Predicate<String> attributeValuePred)
      static int nth​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String innerTag, Pattern p)
      static int nth​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String innerTag, TextComparitor tc, String... compareStr)
      static int nth​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<TagNode> p)
      static int nth​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<TagNode> p, String... htmlTags)
      static int nth​(Vector<? extends HTMLNode> html, int nth, String innerTag)
      static int nth​(Vector<? extends HTMLNode> html, int nth, String htmlTag, String innerTag)
      static int nth​(Vector<? extends HTMLNode> html, int nth, String htmlTag, String innerTag, Predicate<String> attributeValuePred)
      static int nth​(Vector<? extends HTMLNode> html, int nth, String htmlTag, String innerTag, Pattern p)
      static int nth​(Vector<? extends HTMLNode> html, int nth, String htmlTag, String innerTag, TextComparitor tc, String... compareStr)
      static int nth​(Vector<? extends HTMLNode> html, int nth, String innerTag, Predicate<String> attributeValuePred)
      static int nth​(Vector<? extends HTMLNode> html, int nth, String innerTag, Pattern p)
      static int nth​(Vector<? extends HTMLNode> html, int nth, String innerTag, TextComparitor tc, String... compareStr)
      static int nth​(Vector<? extends HTMLNode> html, int nth, Predicate<TagNode> p)
      static int nth​(Vector<? extends HTMLNode> html, int nth, Predicate<TagNode> p, String... htmlTags)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String innerTag)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String htmlTag, String innerTag)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String htmlTag, String innerTag, Predicate<String> attributeValuePred)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String htmlTag, String innerTag, Pattern p)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String htmlTag, String innerTag, TextComparitor tc, String... compareStr)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String innerTag, Predicate<String> attributeValuePred)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String innerTag, Pattern p)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, String innerTag, TextComparitor tc, String... compareStr)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<TagNode> p)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, int sPos, int ePos, Predicate<TagNode> p, String... htmlTags)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, String innerTag)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, String htmlTag, String innerTag)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, String htmlTag, String innerTag, Predicate<String> attributeValuePred)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, String htmlTag, String innerTag, Pattern p)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, String htmlTag, String innerTag, TextComparitor tc, String... compareStr)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, String innerTag, Predicate<String> attributeValuePred)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, String innerTag, Pattern p)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, String innerTag, TextComparitor tc, String... compareStr)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, Predicate<TagNode> p)
      static int nthFromEnd​(Vector<? extends HTMLNode> html, int nth, Predicate<TagNode> p, String... htmlTags)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait