Package Torello.HTML
Class TextNodeIndex
- java.lang.Object
-
- Torello.HTML.NodeIndex<TextNode>
-
- Torello.HTML.TextNodeIndex
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.CharSequence
,java.lang.Cloneable
,java.lang.Comparable<Replaceable>
,Replaceable
public class TextNodeIndex extends NodeIndex<TextNode> 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 aTextNode
instance, and aVector
-index location (for that node) - at the same time - when searching HTML web-pages for document-text.
TextNodeIndex: TextNode '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 classTextNode
inside a vectorized-html web-page, and also theTextNode
itself - simultaneously.
The constructor of this class accepts an index, and aTextNode,
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.
Implements Replaceable:
This class implements theReplaceable
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 aVector<HTMLNode>
) can be somewhat inefficient if there are going to be many nodes inserted and removed. This is because inserting a node into aVector
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-PackagePeek-Operations
(all of which returnReplaceable
instances), a user can operate on much smaller HTML Pieces. Once all updates have been made, the originalVector
can be instantly rebuilt using the efficient updater method (link above).
TheReplaceable
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:
TextNode
,NodeIndex
,TextNodePeek
, Serialized Form
Hi-Lited Source-Code:- View Here: Torello/HTML/TextNodeIndex.java
- Open New Browser-Tab: Torello/HTML/TextNodeIndex.java
File Size: 1,788 Bytes Line Count: 45 '\n' Characters Found
-
-
Constructor Summary
Constructors Constructor Description TextNodeIndex(int index, TextNode textNode)
Constructor for this class.
-
Method Summary
Methods: interface java.lang.Cloneable Modifier and Type Method TextNodeIndex
clone()
-
Methods inherited from class Torello.HTML.NodeIndex
addAllInto, addAllInto, charAt, currentNodes, currentSize, equals, firstCurrentNode, hashCode, lastCurrentNode, length, newNodeIndex, originalLocationEnd, originalLocationStart, originalSize, subSequence, toString, update
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.CharSequence
charAt, chars, codePoints, length, subSequence, toString
-
Methods inherited from interface Torello.HTML.Replaceable
clearHTML, compareTo, isSynthetic, moveAndUpdate, setHTML, setHTML
-
-
-
-
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:
public static final long serialVersionUID = 1;
-
-
Constructor Detail
-
TextNodeIndex
public TextNodeIndex(int index, TextNode textNode)
Constructor for this class.- Parameters:
index
- This is the index of vectorized-page that containstextNode
textNode
- This is theTextNode
being stored in this data-structure.- Throws:
java.lang.IndexOutOfBoundsException
- ifindex
is negative, this exception is thrown.java.lang.NullPointerException
- iftextNode
is null.- Code:
- Exact Constructor Body:
super(index, textNode);
-
-
Method Detail
-
clone
public TextNodeIndex clone()
Java'sinterface Cloneable
requirements. This instantiates a newTextNodeIndex
with identicalTextNode n
andint index
fields.- Overrides:
clone
in classjava.lang.Object
- Returns:
- A new
TextNodeIndex
whose internal fields are identical to this one. - Code:
- Exact Method Body:
return new TextNodeIndex(this.index, this.n);
-
-