- All Superinterfaces:
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ReplaceFunction extends java.io.Serializable
ReplaceFunction - Documentation.
Overload-able using lambda. This simple interface needs to receive an
HTMLNodeand also the position in a Vector where this node was retrieved. It is up to the user to compute / instantiate / provide a new node that can be used to replace the old one.
This is actually a pseudo-trivial class. The reason it was written is to make swapping out
<IMG SRC="...">nodes with image
TagNode'sthat have updated
SRCURL's. It is mostly just a "one-line for-loop." The vast majority of the classes in this HTML scrape and search package are written to eliminate the complex need for worrying too much about for-loops. All the
NodeSearch Find / Get / Removeclasses do is cycle through vector's of HTML pages looking for matches. Though the concept of a for-loop is easy for even the novice in computer-programming, when writing code, worrying about exception cases, boundary cases, case (upper-case and lower-case) all add up to make a very cumbersome search. The list of classes in NodeSearch are just glorified argument-parameter marshalling, and validity & boundary checking. This can make writing a scrape, search, or replace HTML program of your own hundreds of times more straight-forward.
This code (above) can be "replaced" with:
static final long serialVersionUIDThis fulfils the SerialVersion UID requirement for all classes that implement Java's
interface java.io.Serializable. Using the
SerializableImplementation 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.
Functional Interfaces are usually not thought of as Data Objects that need to be saved, stored and retrieved; however, having the ability to store intermediate results along with the lambda-functions that helped get those results can make debugging easier.
- See Also:
- Constant Field Values
- Exact Field Declaration Expression:
HTMLNode getReplacement(HTMLNode n, int curVecPos, int iterationCount)The intention here is to provide a "replace node" for a particular position in the original-
n- This is the "old node" that needs replacing. It will have been obtained from the original HTML page
curVecPos- The position in the original
Vector. This value can be ignored, but is provided as a matter of convenience.
iterationCount- The for-loop that will be making calls to
'getReplacement(...)'provides the a loop-count to this method. All that means is there is a "loop variable" that is updated-by-one (incremented) each time this method is called.
- A new node for to be substituted at the position identified by curArrPos.