Package Torello.HTML

Class CommentNodeIndex

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.CharSequence, java.lang.Cloneable, java.lang.Comparable<Replaceable>, Replaceable

    public class CommentNodeIndex
    extends NodeIndex<CommentNode>
    implements java.lang.CharSequence, java.io.Serializable, java.lang.Cloneable
    This is a simple data-class whose primary reason for development was to provide a way for the NodeSearch Package classes to simultaneously return both a CommentNode instance, and a Vector-index location (for that node) - at the same time - when searching HTML web-pages for HTML comments.

    CommentNodeIndex: CommentNode 'Plus' the Vector-Index

    This class is just an extremely simple data-structure-class used, generally, for returning both the index of an instance-node of class CommentNode inside a vectorized-html web-page, and also the CommentNode itself - simultaneously.
    The constructor of this class accepts an index, and a CommentNode, and saves both of these datum as public, final fields of this class. The 'Peek' suite of search methods in package NodeSearch return instances of this class.


    Implements Replaceable:
    This class implements the Replaceable interface. This means that it may be used for efficiently modifying, updating, or replacing many segments of an HTML-Page using the method:

    ReplaceNodes.r(Vector<HTMLNode>, Iterable<Replaceable>, boolean)

    Whenever the Java HTML JAR Library's HTML-Vector's are being used to modify or update an HTML-Page, it can sometimes help to remember that shifting elements in a list (in this package a Vector<HTMLNode>) can be somewhat inefficient if there are going to be many nodes inserted and removed. This is because inserting a node into a Vector does, indeed, require shifting all nodes that occur after the insertion index-location forward!

    By first extracting HTML nodes or sub-lists using the NodeSearch-Package Peek-Operations (all of which return Replaceable instances), a user can operate on much smaller HTML Pieces. Once all updates have been made, the original Vector can be instantly rebuilt using the efficient updater method (link above).

    The Replaceable interface provides quite a number of HTML Modification methods to add, change or eliminate the original HTML found on a page. Note that when operating on a piece of HTML that has been extracted, the effects of stale index-pointers become irrelevant!
    See Also:
    CommentNode, NodeIndex, CommentNodePeek, Serialized Form


    • Field Detail

      • serialVersionUID

        🡇     🗕  🗗  🗖
        public static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable Implementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.
        See Also:
        Constant Field Values
        Code:
        Exact Field Declaration Expression:
         public static final long serialVersionUID = 1;
        
    • Constructor Detail

      • CommentNodeIndex

        🡅  🡇     🗕  🗗  🗖
        public CommentNodeIndex​(int index,
                                CommentNode commentNode)
        Constructor for this class.
        Parameters:
        index - This is the index of vectorized-page that contains commentNode
        commentNode - The CommentNode being stored in this data-structure.
        Throws:
        java.lang.IndexOutOfBoundsException - if index is negative, this exception is thrown.
        java.lang.NullPointerException - if commentNode is null.
        Code:
        Exact Constructor Body:
         super(index, commentNode);
        
    • Method Detail

      • clone

        🡅     🗕  🗗  🗖
        public CommentNodeIndex clone()
        Java's interface Cloneable requirements. This instantiates a new CommentNodeIndex with identical CommentNode n and int index fields.
        Overrides:
        clone in class java.lang.Object
        Returns:
        A new CommentNodeIndex whose internal fields are identical to this one.
        Code:
        Exact Method Body:
         return new CommentNodeIndex(this.index, this.n);