Package Torello.HTML.NodeSearch
Class InclusiveException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- java.lang.IllegalArgumentException
-
- Torello.HTML.NodeSearch.InclusiveException
-
- All Implemented Interfaces:
java.io.Serializable
public class InclusiveException extends java.lang.IllegalArgumentException
An Inclusive-Exception indicates that a user has tried to perform an "Inclusive Search" on an HTML Tag that cannot have sub-nodes or descendant-nodes. The most common examples of inclusive search parameters for HTML tags would be the HTML elements:DIV, P, SPAN, A, TABLE, H1..H6
.
These are the HTML elements whose primary purpose is to "surround" a block of HTML or, a some plain-text (in the case of the "anchor element"<A HREF="...">
). An inclusive search does just what one might think would be good to do with "container" HTML elements, it captures each and everyHTMLNode
between the opening and closing HTMLTagNode's
.
Inclusive Java-Script Similarity:
var divElement = document.getElementById("article-container"); var articleHTML = divElement.innerHTML;
The above two lines of "Java-Script," above, would loosely "translate" to the following java-code below:
Vector<HTMLNode> article = InnerTagGetInclusive.first (some_page, "div", "class", val -> val.equals("article-container")); String articleAsStr = Util.pageToString(article);
Examples of "Inclusive Search" that would cause athrow new InclusiveException(message)
would be using the "Inclusive Methods" in this Node-Search Package - and naming any of the following HTML Elements:<BR>
<IMG SRC="...">
<HR>
<META ...>
<INPUT ID="...">
Each of the previously listed HTML elements only have an opening tag version, they never need to be closed! AnInclusiveException
is generated if an attempt is made to find an opening-closing pair when there may not be one, according to the HTML specifications. These are sometimes called "stand-alone" or "empty" HTML elements. They are also often called "self-closing" tags.- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/HTML/NodeSearch/InclusiveException.java
- Open New Browser-Tab: Torello/HTML/NodeSearch/InclusiveException.java
File Size: 5,354 Bytes Line Count: 122 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description InclusiveException()
Constructs anInclusiveException
with no detail message.InclusiveException(String message)
Constructs anInclusiveException
with the specified detail message.InclusiveException(String message, Throwable cause)
Constructs a new exception with the specified detail message and cause.InclusiveException(Throwable cause)
Constructs a new exception with the specified cause and a detail message of(cause==null ? null : cause.toString())
(which typically contains the class and detail message of cause).
-
Method Summary
'static'
Exception Check MethodsModifier and Type Method static void
check(String... htmlTags)
-
-
-
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.
Note that Java'sjava.lang.Exception
andjava.lang.Error
classes implement theSerializable interface
, and a warning-free build expects this field be defined here.- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final long serialVersionUID = 1;
-
-
Constructor Detail
-
InclusiveException
public InclusiveException()
Constructs anInclusiveException
with no detail message.
-
InclusiveException
public InclusiveException(java.lang.String message)
Constructs anInclusiveException
with the specified detail message.- Parameters:
message
- the detail message.
-
InclusiveException
public InclusiveException(java.lang.String message, java.lang.Throwable cause)
Constructs a new exception with the specified detail message and cause.
NOTE:
The detail message associated with cause is not automatically incorporated into this exception's detail message.- Parameters:
message
- The detail message (which is saved for later retrieval by theThrowable.getMessage()
method).cause
- the cause (which is saved for later retrieval by theThrowable.getCause()
method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
-
InclusiveException
public InclusiveException(java.lang.Throwable cause)
Constructs a new exception with the specified cause and a detail message of(cause==null ? null : cause.toString())
(which typically contains the class and detail message of cause). This constructor is useful for exceptions that are little more than wrappers for other throwables.- Parameters:
cause
- The cause (which is saved for later retrieval by theThrowable.getCause()
method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
-
-
Method Detail
-
check
public static void check(java.lang.String... htmlTags)
Checks either one, or a list, of html-tags (same as theTagNode.tok
) to make sure they are not "singleton" (sometimes called'empty' HTML elements
. If the parameter(s) are empty/singleton HTML elements, this method will automatically throw anInclusiveException
.- Parameters:
htmlTags
- This may be any JavaString
(orString's
), but only Java-String's
that are found to be valid HTML 4 or 5 tags will be accepted.
NOTE: TheString...
(var-args) syntax means multiple tags may be tested. If one is found to be invalid, anInclusiveEception
is immediately thrown.- Throws:
InclusiveException
- See Also:
HTMLTags.isSingleton(String)
- Code:
- Exact Method Body:
for (String tok : htmlTags) if (tok != null) if (HTMLTags.isSingleton(tok)) throw new InclusiveException ( "The HTML Element '" + tok + "' may not have an inclusive search performed " + "with it, because it is a singleton HTML element." );
-
-