Package Torello.HTML.NodeSearch
Class ARGCHECK
- java.lang.Object
-
- Torello.HTML.NodeSearch.ARGCHECK
-
public class ARGCHECK extends java.lang.Object
This class is used internally to do argument validity-checks, and guarantees consistent exception-message reporting.
This class is a'public'class in this package not because of its exceptional usability or usefullness, but rather so that it remains visible in case a programmer wishes to see how the validity-checking mechanisms work in this'NodeSearch'package.
Hi-Lited Source-Code:- View Here: Torello/HTML/NodeSearch/ARGCHECK.java
- Open New Browser-Tab: Torello/HTML/NodeSearch/ARGCHECK.java
File Size: 17,874 Bytes Line Count: 425 '\n' Characters Found
Stateless Class:This class neither contains any program-state, nor can it be instantiated. The@StaticFunctionalAnnotation may also be called 'The Spaghetti Report'.Static-Functionalclasses are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's@StatelessAnnotation.
- 1 Constructor(s), 1 declared private, zero-argument constructor
- 13 Method(s), 13 declared static
- 2 Field(s), 2 declared static, 2 declared final
-
-
Field Summary
Fields Modifier and Type Field protected static TextComparitor[]CSSTCsstatic Predicate<String>TRUE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method static StringhtmlTag(String htmlTag)static String[]htmlTags(String... htmlTags)static intindex(Vector<? extends HTMLNode> page, int index)static StringinnerTag(String innerTag)static intn(int nth, Vector<?> v)static Predicate<String>REGEX(Pattern p)static Predicate<CommentNode>REGEX_CNP(Pattern p)static Predicate<TextNode>REGEX_TXNP(Pattern p)static Predicate<CommentNode>SP_TO_CNP(Predicate<String> p)static Predicate<TextNode>SP_TO_TXNP(Predicate<String> p)static Predicate<String>TC(TextComparitor tc, String... compareStr)static Predicate<CommentNode>TC_CNP(TextComparitor tc, String... compareStr)static Predicate<TextNode>TC_TXNP(TextComparitor tc, String... compareStr)
-
-
-
Field Detail
-
TRUE
public static final java.util.function.Predicate<java.lang.String> TRUE
- Code:
- Exact Field Declaration Expression:
public static final Predicate<String> TRUE = (String innerTagValue) -> true;
-
CSSTCs
protected static final TextComparitor[] CSSTCs
This just keeps a short list of all the instance-objects ofclass TextComparitorthat perform the "CSS Class" Checks. TheseTextComparitor's, when used with avar-args String[] arrayinput, should have a finer-grain of exception checking and error checking performed on their inputs. Checking to ensure CSS ClassString'sinside of HTML Elements are only checked against valid CSS-Names is possible in this argument-checking class.- Code:
- Exact Field Declaration Expression:
protected static final TextComparitor[] CSSTCs = { TextComparitor.C, TextComparitor.C_OR, TextComparitor.C_AND, TextComparitor.C_NAND, TextComparitor.C_XOR };
-
-
Method Detail
-
n
public static int n(int nth, java.util.Vector<?> v)
Internally Used. Checks for valid values of'nth'to the search methodsnthandnthFromEnd.- Parameters:
nth- This is a number identify which search-match to return. Ifn = 3, the third match shall be returned. Remember to ensure that a negative number is not passed, nor a number too large.v- This should be the html-Vectoron which a search is being performed.The symbols<?>appended to the (almost) 'raw-type' here, are only there to prevent the java-compiler from issuing warnings regarding the use of "Raw Types." This warning is, actually, only issued if the command-line option-Xlint:alloption is used.- Throws:
NException- When a negative value for'nth'is passed, or'nth'is greater than the size of theVector.- Code:
- Exact Method Body:
NException.check(nth, v); return nth;
-
htmlTag
public static java.lang.String htmlTag(java.lang.String htmlTag)
Internally Used. Checks for valid and invalid HTML Token arguments to all search methods. Calls JavaStringmethodtoLowerCase()on HTML Token and returns it. All HTML tokens are stored in lower-case form internally, for quicker comparisons.- Parameters:
htmlTag- Make sure the user is searching for a valid HTMT Element. If new tags have been added to the javaCollection(internally represented byclass java.util.TreeSet), make sure the check those too.- Throws:
HTMLTokException- When an invalid HTML Token Element is passed.java.lang.NullPointerException- If any of the provided input reference parameters are null.- See Also:
HTMLTags- Code:
- Exact Method Body:
HTMLTokException.check(htmlTag); return htmlTag.toLowerCase();
-
htmlTags
public static java.lang.String[] htmlTags(java.lang.String... htmlTags)
Internally Used. Checks multiple HTML Token arguments to all search methods for validity. Calls JavaStringmethodString.toLowerCase()on each HTML Token and returns the array of tokens - all in lower-case. All HTML tokens are stored in lower-case form internally, for quicker comparisons.
Save Var-Args:
Here, the Var-ArgsString[]-Array parameter'htmlTags'is not modified at all. Upon invocation, this method creates a new instance of the importedString[]-Array (using lower-casedString'sstored in place of the originals).
All Java-String'sare immutable, and here new lower-caseString'sare being saved to a newly instantiated array. The original input parameter will not be modified.- Parameters:
htmlTags- These are a list of html-tags to be checked.- Throws:
HTMLTokException- When any invalid HTML Token Element is passed.java.lang.NullPointerException- If any of the provided input reference parameters are null.- See Also:
HTMLTags,HTMLTokException.check(String[])- Code:
- Exact Method Body:
HTMLTokException.check(htmlTags); String[] ret = new String[htmlTags.length]; for (int i=0; i < htmlTags.length; i++) ret[i] = htmlTags[i].toLowerCase(); return ret;
-
innerTag
public static java.lang.String innerTag(java.lang.String innerTag)
Internally Used. Checks validity of inner-tag arguments to search routines. Returns lower-case version of the inner-tag.- Throws:
InnerTagKeyException- If an inner-tag value is invalid.java.lang.NullPointerException- If any of the provided input reference parameters are null.- See Also:
InnerTagKeyException.check(String[])- Code:
- Exact Method Body:
InnerTagKeyException.check(innerTag); return innerTag.toLowerCase();
-
TC
public static final java.util.function.Predicate<java.lang.String> TC (TextComparitor tc, java.lang.String... compareStr)
Internally Used. Checks validity of theTextComparitor String's, and theTextComparitor. Wraps theTextComparitorand itsString... compareStrarguments into a Java LambdaPredicate<String>.- Parameters:
tc- Any valid instance ofTextComparitorcompareStr- Avarargs String[] arrayof test-String's.- Returns:
- This returns a
String-Predicatethat uses the providedTextComparitorand its associated'compareStr' String[] arraylist to test inputString's. - Throws:
TCCompareStrException- This is thrown for invalid search parameters. Review theExceptionclass itself for what constitutes invalid parameter data.CSSStrException- If one of the provided comparisonString'sis not a valid CSS name, and theTextComparitorpassed is a CSS Class TestTextComparitor.java.lang.NullPointerException- If any of the provided input reference parameters are null.- See Also:
TCCompareStrException.check(String[]),TextComparitor,TextComparitor.test(String, String[])- Code:
- Exact Method Body:
if (tc == null) throw new NullPointerException( "You have passed a null value to the parameter TextComparitor here, " + "but this is not allowed." ); TCCompareStrException.check(compareStr); for (TextComparitor cssTC : CSSTCs) if (cssTC == tc) { CSSStrException.check(compareStr); break; } // String[] cmpStr = compareStr.clone(); // MADNESS, ISN'T IT? return (String innerTagValue) -> tc.test(innerTagValue, compareStr);
-
TC_TXNP
public static final java.util.function.Predicate<TextNode> TC_TXNP (TextComparitor tc, java.lang.String... compareStr)
Internally Used. Checks validity of theTextComparitor String's, and theTextComparitor. Wraps theTextComparitorand itsString... compareStrarguments into a Java LambdaPredicate<String>.- Parameters:
tc- Any valid instance ofTextComparitorcompareStr- Avarargs String[] arrayof test-String's.- Returns:
- This returns a
Predicate<TextNode>that uses the providedTextComparitorandcompareStr'sto test inputTextNode'susing the'TextNode.str'field. - Throws:
TCCompareStrException- This is thrown for invalid search parameters. Review theExceptionclass itself for what constitutes invalid parameter data.CSSStrException- If one of the providedcompareStr'sis not a valid CSS name, and theTextComparitorpassed is a CSS Class TestTextComparitor.java.lang.NullPointerException- If any of the provided input reference parameters are null.- See Also:
TCCompareStrException.check(String[]),TextComparitor,TextComparitor.test(String, String[]),HTMLNode.str,HTMLNode.str- Code:
- Exact Method Body:
if (tc == null) throw new NullPointerException( "You have passed a null value to the parameter TextComparitor here, " + "but this is not allowed." ); TCCompareStrException.check(compareStr); for (TextComparitor cssTC : CSSTCs) if (cssTC == tc) { CSSStrException.check(compareStr); break; } // String[] cmpStr = compareStr.clone(); // MADNESS, ISN'T IT? return (TextNode txn) -> tc.test(txn.str, compareStr);
-
TC_CNP
public static final java.util.function.Predicate<CommentNode> TC_CNP (TextComparitor tc, java.lang.String... compareStr)
Internally Used. Checks validity of theTextComparitor String's, and theTextComparitor. Wraps theTextComparitorand itsString... compareStrarguments into a Java LambdaPredicate.- Parameters:
tc- Any valid instance ofTextComparitorcompareStr- Avarargs String[] arrayof test-String's.- Returns:
- This returns a
Predicate<CommentNode>that uses the providedTextComparitorandcompareStr'sto test inputCommentNode'susing theCommentNode.bodyfield. - Throws:
TCCompareStrException- This is thrown for invalid search parameters. Review theExceptionclass itself for what constitutes invalid parameter data.CSSStrException- If one of the providedcompareStr'sis not a valid CSS name, and theTextComparitorpassed is a CSS Class TestTextComparitor.java.lang.NullPointerException- If any of the provided input reference parameters are null.- See Also:
TCCompareStrException.check(String[]),TextComparitor,TextComparitor.test(String, String[]),CommentNode.body- Code:
- Exact Method Body:
if (tc == null) throw new NullPointerException( "You have passed a null value to the parameter TextComparitor here, " + "but this is not allowed." ); TCCompareStrException.check(compareStr); for (TextComparitor cssTC : CSSTCs) if (cssTC == tc) { CSSStrException.check(compareStr); break; } // String[] cmpStr = compareStr.clone(); // MADNESS, ISN'T IT? return (CommentNode cn) -> tc.test(cn.body, compareStr);
-
REGEX
public static final java.util.function.Predicate<java.lang.String> REGEX (java.util.regex.Pattern p)
Internally Used. Checks that a Java RegexPatternis not null. Wraps the reg-exPatterninto a Java LambdaPredicate<String>Tester Expression.- Parameters:
p- This may be any valid input regular-expressionPattern.- Returns:
- This shall return a
Predicate<String>that tests inputString'sagainst the regular-expression. - Throws:
java.lang.NullPointerException- If any of the provided input reference parameters are null.- Code:
- Exact Method Body:
if (p == null) throw new NullPointerException( "You have passed a null value to a search-method's regular-expression 'Pattern' " + "parameter, but this is not allowed." ); return p.asPredicate(); // return (String innerTagValue) -> p.matcher(innerTagValue).find();
-
REGEX_TXNP
public static final java.util.function.Predicate<TextNode> REGEX_TXNP (java.util.regex.Pattern p)
Internally Used. Checks that a Java RegexPatternis not null. Wraps the reg-exPatterninto a Java LambdaPredicate<TextNode>Tester Expression.- Parameters:
p- This may be any valid input regular-expressionPattern.- Returns:
- This shall return a
Predicate<TextNode>that tests inputTextNode's(using theTextNode.str- inherited fromHTMLNode.strfield) against the regular-expression. - Throws:
java.lang.NullPointerException- If any of the provided input reference parameters are null.- See Also:
HTMLNode.str,HTMLNode.str- Code:
- Exact Method Body:
if (p == null) throw new NullPointerException( "You have passed a null value to a search-method's regular-expression 'Pattern' " + "parameter, but this is not allowed." ); Predicate<String> pred = p.asPredicate(); return (TextNode txn) -> pred.test(txn.str); // return (TextNode txn) -> p.matcher(txn.str).find();
-
REGEX_CNP
public static final java.util.function.Predicate<CommentNode> REGEX_CNP (java.util.regex.Pattern p)
Internally Used. Checks that a Java RegexPatternis not null. Wraps the reg-exPatterninto a Java LambdaPredicate<CommentNode>Tester Expression.- Parameters:
p- This may be any valid input regular-expression pattern.- Returns:
- This shall return a
CommentNode-Predicatethat tests inputCommentNode's(using theCommentNode.bodyfield) against the regular-expression. - Throws:
java.lang.NullPointerException- If any of the provided input reference parameters are null.- See Also:
CommentNode.body- Code:
- Exact Method Body:
if (p == null) throw new NullPointerException( "You have passed a null value to a search-method's regular-expression 'Pattern' " + "parameter, but this is not allowed." ); Predicate<String> pred = p.asPredicate(); return (CommentNode cn) -> pred.test(cn.body); // return (CommentNode cn) -> p.matcher(cn.body).find();
-
SP_TO_TXNP
public static final java.util.function.Predicate<TextNode> SP_TO_TXNP (java.util.function.Predicate<java.lang.String> p)
Internally Used. Checks that a Java RegexPatternis not null. Wraps the reg-exPatterninto a Java LambdaPredicate<TextNode>Tester Expression.- Parameters:
p- This may be any validString-Predicate- Returns:
- This shall return a
TextNode-Predicatethat "wraps" the inputString-Predicateand uses the fieldTextNode.str(inherited fromHTMLNode.str) as a value for the wrapped, "original,"String-Predicatetest. - Throws:
java.lang.NullPointerException- If any of the provided input reference parameters are null.- See Also:
HTMLNode.str,HTMLNode.str- Code:
- Exact Method Body:
if (p == null) throw new NullPointerException( "You have passed a null value to a search-method's String-Predicate 'p' parameter, " + "but this is not allowed." ); return (TextNode txn) -> p.test(txn.str);
-
SP_TO_CNP
public static final java.util.function.Predicate<CommentNode> SP_TO_CNP (java.util.function.Predicate<java.lang.String> p)
Internally Used. Checks that a Java RegexPatternis not null. Wraps the reg-exPatterninto a Java LambdaPredicate<CommentNode>Tester Expression.- Parameters:
p- This may be any validString-Predicate- Returns:
- This shall return a
CommentNode-Predicatethat "wraps" the inputString-Predicateand uses the fieldCommentNode.bodyas a value for the wrapped, "original,"String-Predicatetest. - Throws:
java.lang.NullPointerException- If any of the provided input reference parameters are null.- See Also:
CommentNode.body- Code:
- Exact Method Body:
if (p == null) throw new NullPointerException( "You have passed a null value to a search-method's String-Predicate 'p' parameter, " + "but this is not allowed." ); return (CommentNode cn) -> p.test(cn.body);
-
index
public static int index(java.util.Vector<? extends HTMLNode> page, int index)
Internally Used. Checks to ensure that an index-parameter, when use in conjunction with theclass Surrounding(which is sometimes referred to by the term 'Container') find methods is properly within the bounds of the HTML page.- Parameters:
page- This may be any valid vectorized-html page or sub-page.index- This is expected to be an index into the 'page' parameter-vector. If this is not a valid index, then this method shall throw an exception.- Returns:
- This method returns the exact-value of input parameter 'index'
- Throws:
java.lang.NullPointerException- If any of the provided input reference parameters are null.java.lang.IndexOutOfBoundsException- If the 'index' parameter is not a valid index into the 'page' parameter, then this exception will be thrown.- Code:
- Exact Method Body:
if (index < 0) throw new IndexOutOfBoundsException( "The index you passed [" + index + "] into vectorized-HTML page was negative, " + "this is not allowed here." ); if (index >= page.size()) throw new IndexOutOfBoundsException( "The index you passed [" + index + "] into vectorized-HTML page was is greater than " + "the vector's size [" + page.size() + "]" ); return index;
-
-