Package Torello.CSS
Class ClassNameCSSException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- Torello.CSS.ClassNameCSSException
-
- All Implemented Interfaces:
java.io.Serializable
public class ClassNameCSSException extends java.lang.RuntimeException
An exception for using with a Validity-Check of a CSS Class-Name.
Regular-Expression:
The following is considered the validator for this exception'sValidity-Checkermethod.
Regular Expression:
^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$
These are the most recent test results of applying this regular expression to a series of randomly selected Java Classes.@cloudshell:~$ java Torello.Test.Y2024.M09September.ClassNameExTest "-validname": true, PASS "valid-name": true, PASS "-1invalid": false, PASS "--invalid": false, PASS "-valid": true, PASS "Good": true, PASS "9NoGood": false, PASS "No Good": false, PASS "999": false, PASS "": false, PASS "--invalid": false, PASS "-2invalid": false, PASS "inv@lid": false, PASS "inv!lid": false, PASS "123invalid": false, PASS "-": false, PASS "1": false, PASS "A": true, PASS "-A": true, PASS
Hi-Lited Source-Code:- View Here: Torello/CSS/ClassNameCSSException.java
- Open New Browser-Tab: Torello/CSS/ClassNameCSSException.java
File Size: 4,386 Bytes Line Count: 115 '\n' Characters Found
-
-
Field Summary
Fields Modifier and Type Field static longserialVersionUIDstatic PatternVALID_CSS_CLASS_NAMEstatic Predicate<String>VALID_CSS_CLASS_NAME_PRED
-
Constructor Summary
Constructors Constructor ClassNameCSSException()ClassNameCSSException(String message)ClassNameCSSException(String message, Throwable cause)ClassNameCSSException(Throwable cause)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method static voidcheck(String cssClassName)
-
-
-
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 theSerializableImplementation 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.Exceptionandjava.lang.Errorclasses 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;
-
VALID_CSS_CLASS_NAME
public static final java.util.regex.Pattern VALID_CSS_CLASS_NAME
This is a validator regular-expression. It is intended to check whether or not a CSS Class-Name is valid or not.- See Also:
VALID_CSS_CLASS_NAME_PRED- Code:
- Exact Field Declaration Expression:
public static final Pattern VALID_CSS_CLASS_NAME = // Pattern.compile("^([_a-zA-Z]|-[_a-zA-Z])[_\\-a-zA-Z0-9]*$"); Pattern.compile("^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$");
-
VALID_CSS_CLASS_NAME_PRED
public static final java.util.function.Predicate<java.lang.String> VALID_CSS_CLASS_NAME_PRED
This is the validatorReg-Exafter having been converted into ajava.util.function.Predicate<String>.- See Also:
VALID_CSS_CLASS_NAME- Code:
- Exact Field Declaration Expression:
public static final Predicate<String> VALID_CSS_CLASS_NAME_PRED = VALID_CSS_CLASS_NAME.asPredicate();
-
-
Constructor Detail
-
ClassNameCSSException
public ClassNameCSSException()
Constructs aClassNameCSSExceptionwith no detail message.
-
ClassNameCSSException
public ClassNameCSSException(java.lang.String message)
Constructs aClassNameCSSExceptionwith the specified detail message.- Parameters:
message- the detail message.
-
ClassNameCSSException
public ClassNameCSSException(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 non-existent or unknown.)
-
ClassNameCSSException
public ClassNameCSSException(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 non-existent or unknown.)
-
-
Method Detail
-
check
public static void check(java.lang.String cssClassName)
Checks if a the providedcssClassNameis a valid name according the CSS Regular-Expression that's incorporated into this class.- Parameters:
cssClassName- Any Java-String, but only a valid CSS Class-Name can prevent this method from throwing this class' exception.- Throws:
ClassNameCSSException- if the providedcssClassNameisn't a proper CSS Class-Name, according to the Regular-Expression PredicateVALID_CSS_CLASS_NAME_PREDjava.lang.NullPointerException- ifcssClassNameis null, then NPE throws.- See Also:
VALID_CSS_CLASS_NAME,VALID_CSS_CLASS_NAME_PRED
-
-