Package Torello.HTML
Class CommentNodeIndex
- java.lang.Object
-
- Torello.HTML.NodeIndex
-
- Torello.HTML.CommentNodeIndex
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.CharSequence
,java.lang.Cloneable
,java.lang.Comparable<NodeIndex>
public class CommentNodeIndex extends NodeIndex implements java.lang.CharSequence, java.io.Serializable, java.lang.Cloneable
CommentNodeIndex - Documentation.
CommentNodeIndex: CommentNode 'plus' the vector-index
This class has two member fields, listed below:CommentNodeIndex.n
is aninstanceof CommentNode
CommentNodeIndex.index
isint integer
, and contains theVector
-index where thisCommentNode
resides.
This class is just an extremely simple data-structure-class used, generally, for returning both the index of an instance-node ofclass 'CommentNode'
inside a vectorized-html web-page, and also theCommentNode
itself -simultaneously. The constructor of this class accepts an index, and aCommentNode,
and saves both of these datum aspublic, final
fields of this class. The'Peek'
suite of search methods inpackage NodeSearch
return instances of this class.
STALE DATA NOTE: If a vectorized-html webpage is modified after any of theseNode + Index
classes are created / instantiated, and nodes are added or removed from the webpage, then the (integer) index data inside these classes would have become stale when they are next accessed.
The followingpublic class
definitions incorporateVector
-index andVector
-node-content into a single "combined unit" class:class TagNodeIndex
class TextNodeIndex
class CommentNodeIndex
class NodeIndex
- is abstract, and the parent of the three above.class SubSection
- a sublist of nodes
It is important to remember thatVector
-position (a.k.a. "Vector
-index") information that is stored insideObject
instances of these (extremely-simple) classes will become stale, immediately if nodes are ever added or removed to the underlyingVector
from which theseNode + Index
object-classes are created. This is because the 'index' is just a pointer into theVector
! For data-retrieval operations, these classes can prove highly useful. For page-modification operations, it is better to use theHTML Iterator / HNLI
classes.- See Also:
CommentNode
,NodeIndex
,CommentNodePeek
, Serialized Form
Hi-Lited Source-Code:
- View Here: Torello/HTML/CommentNodeIndex.java
- Open New Browser-Tab: Torello/HTML/CommentNodeIndex.java
-
-
Field Summary
Fields Modifier and Type Field static Comparator<CommentNodeIndex>
comp2
static Comparator<CommentNodeIndex>
comp3
CommentNode
n
static long
serialVersionUID
-
Constructor Summary
Constructors Constructor CommentNodeIndex(int index, CommentNode commentNode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method CommentNodeIndex
clone()
-
Methods inherited from class Torello.HTML.NodeIndex
charAt, check, compareTo, equals, hashCode, length, subSequence, toString
-
-
-
-
Field Detail
-
serialVersionUID
public static final long serialVersionUID
This fulfils the SerialVersion UID requirement for all classes that implement Java'sinterface java.io.Serializable
. Using theSerializable
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:
1
public static final long serialVersionUID = 1;
-
n
public final CommentNode n
ACommentNode
node from a web-page. This node is supposed to be the same node stored at the index specified by member-fieldint 'index'
of some vectorized-html web-page in memory or on disk.
IMPORTANT: This field overrides the parent-class fieldpublic final HTMLNode n
- and it is an instance ofCommentNode,
rather thanHTMLNode
- Code:
- Exact Field Declaration Expression:
1
public final CommentNode n;
-
comp2
public static final java.util.Comparator<CommentNodeIndex> comp2
This is an "alternative Comparitor" that can be used for sorting instances of this class. It should work with theCollections.sort(List, Comparator)
method in the standard JDK packagejava.util.*;
NOTE: This version utilizes the standard JDKString.compareTo(String)
method on the comment'sString body
field.- See Also:
CommentNode.body
- Code:
- Exact Field Declaration Expression:
1 2
public static final Comparator<CommentNodeIndex> comp2 = (CommentNodeIndex cni1, CommentNodeIndex cni2) -> cni1.n.body.compareTo(cni2.n.body);
-
comp3
public static final java.util.Comparator<CommentNodeIndex> comp3
This is an "alternative Comparitor" that can be used for sorting instances of this class. It should work with theCollections.sort(List, Comparator)
method in the standard JDK packagejava.util.*;
NOTE: This version utilizes the standard JDKString.compareToIgnoreCase(String)
method.- See Also:
CommentNode.body
- Code:
- Exact Field Declaration Expression:
1 2
public static final Comparator<CommentNodeIndex> comp3 = (CommentNodeIndex cni1, CommentNodeIndex cni2) -> cni1.n.body.compareToIgnoreCase(cni2.n.body);
-
-
Constructor Detail
-
CommentNodeIndex
public CommentNodeIndex(int index, CommentNode commentNode)
Constructor for this class. Some brief/minor error checking is performed before this class is instantiated.- Parameters:
index
- This is the index of vectorized-page that containsHTMLNode 'n'
commentNode
- This is theCommentNode
being stored in this light-simple data-structure.- Throws:
java.lang.IndexOutOfBoundsException
- if index is negative, this exception is thrown.java.lang.NullPointerException
- If the parameter 'commentNode' is null.- Code:
- Exact Constructor Body:
1 2 3
super(index, commentNode); NodeIndex.check(index, commentNode); this.n = commentNode;
-
-
Method Detail
-
clone
public CommentNodeIndex clone()
Java'sinterface Cloneable
requirements. This instantiates a newCommentNodeIndex
with identicalCommentNode n
andint index
fields.- Overrides:
clone
in classjava.lang.Object
- Returns:
- A new
CommentNodeIndex
whose internal fields are identical to this one. - Code:
- Exact Method Body:
1
return new CommentNodeIndex(this.index, this.n);
-
-