Package Torello.HTML

Class InnerTagKeyException

  • All Implemented Interfaces:
    java.io.Serializable

    public class InnerTagKeyException
    extends java.lang.IllegalArgumentException
    This occurs whenever a parameter specifies an Inner-Tag "Key-Value Pair" (which, in this package, are also known as Attribute-Value Pairs) that contain inappropriate characters inside the key-String.

    Reg-Ex Rules:
    All matching HTML Element Attributes must have attribute-names (inner-tags) whose nomenclature conforms to this regular-expression: [A-Za-z][\w-]+.

    All this says is that attribute-names must begin with an alphabetic character, and then the characters that follow must be "regular-expression" word-characters '\w'.

    In a regular-expression, the characters that match a \w include the letters A-Z, the (lower-case) letters a-z, the digits 0-9, and the underscore '_'. The minus-sign '-' may also be used in an attribute-name (it just may not be the first character used in an attribute-name).

    Example:
      <IMG SRC="http://example.com/pic.jpg">
      <DIV data-id="this is example data">
    

    For the above two examples, both the 'SRC' attribute-name (key-name) and the 'data-id' key-name are legitimately named. No exceptions would be thrown if a programmer initiated a search using a string to look for an inner-tag that was named 'src' nor would there be problems using a string named 'data-id' to look for the value of data-id above.

    Example:
     Properties p = new java.util.Properties();
     p.put("My Attribute Value", "data 1");
     p.put("123Attribute", "data 2");
     p.put("SpecialChars!@#$%", "data 3");
     TagNode tn = new TagNode("DIV", p, SD.DoubleQuotes, false);
    

    An InnerTagKeyException would be generated for all three cases! Each of the above inner-tag key-value pairs have key-names with illegal characters.

    Specifically:

    • Attribute-Value Pair 1: The key-name contains a space.
    • Attribute-Value Pair 2: The key-name begins with a number.
    • Attribute-Value Pair 3: The key-name has invalid, non-alpha-numeric characters!

    If a search were made using an inner-tag (attribute-name)using a String that did not meet these criteria, an InnerTagKeyException would be thrown.
    See Also:
    Serialized Form


    • Field Summary

       
      Serializable ID
      Modifier and Type Field
      static long serialVersionUID
    • Constructor Summary

      Constructors 
      Constructor Description
      InnerTagKeyException()
      Constructs an InnerTagKeyException with no detail message.
      InnerTagKeyException​(String message)
      Constructs an InnerTagKeyException with the specified detail message.
      InnerTagKeyException​(String message, Throwable cause)
      Constructs a new exception with the specified detail message and cause.
      InnerTagKeyException​(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 Methods
      Modifier and Type Method
      static void check​(String... keys)
      static void check​(String key, String value)
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        🡇     🗕  🗗  🗖
        public static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable 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's java.lang.Exception and java.lang.Error classes implement the Serializable 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

      • InnerTagKeyException

        🡅  🡇     🗕  🗗  🗖
        public InnerTagKeyException​(java.lang.String message)
        Constructs an InnerTagKeyException with the specified detail message.
        Parameters:
        message - the detail message.
      • InnerTagKeyException

        🡅  🡇     🗕  🗗  🗖
        public InnerTagKeyException​(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 the Throwable.getMessage() method).
        cause - the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown).
      • InnerTagKeyException

        🡅  🡇     🗕  🗗  🗖
        public InnerTagKeyException​(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 the Throwable.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... keys)
        This verifies that any Java-String that is intended to be use as an inner-tag conforms to the right rules. If a problem is found, then an InnerTagKeyException or NullPointerException is thrown.
        Parameters:
        keys - One or many HTML-Inner-Tag to be checked for use as an HTML-Attribute name
        Throws:
        InnerTagKeyException - If any String does not match the CHECK_KEY Regular-Expression Pattern.
        java.lang.NullPointerException - If any of the attributes / inner-tag keys passed are null.
        Code:
        Exact Method Body:
         for (String key : keys)
        
             if (key == null) throw new NullPointerException(
                 "You have passed a null as an Attribute-Name (also known as an " +
                 "'InnerTag-Key Name'), but this is not allowed."
             );
        
             else if (! AttrRegEx.ATTRIBUTE_KEY_REGEX.matcher(key).find())
                 throw new InnerTagKeyException
                     ("Inner-tag key has invalid characters: [" + key + ']');
        
      • check

        🡅     🗕  🗗  🗖
        public static void check​(java.lang.String key,
                                 java.lang.String value)
        This method is identical to the public static void check(key);, except it allows the programmer to add the key-value pair to the Exception's error message. No change to the code is present, except the exception's error message.
        Parameters:
        key - Any HTML-Inner-Tag nameto be checked for use as an HTML-Attribute
        value - This is the value taken by this key, it is included for error-logging only, but it is not checked.
        Throws:
        InnerTagKeyException - If this class does not match the CHECK_KEY Regular-Expression Pattern, than it throws.
        Code:
        Exact Method Body:
         if (key == null) throw new NullPointerException(
             "You have passed a null as an Attribute-Name (also known as an 'InnerTag-Key Name'), " +
             "but this is not allowed."
         );
        
         if (! AttrRegEx.ATTRIBUTE_KEY_REGEX.matcher(key).find()) 
             throw new InnerTagKeyException(
                 "The specified inner-tag key has invalid characters: [" + key + "]\n" +
                 "For Key-Value Pair: [" + key + ", " + value + "]"
             );