Class TCCompareStrException

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    CSSStrException

    public class TCCompareStrException
    extends java.lang.IllegalArgumentException
    'Text-Comparitor Compare-String Exception' is thrown by the argument marshalling and validity checking code when attempts are made to search HTML-Vector's using an invalid input-String[] parameter.

    This class does some passed-parameter checking for the HTML-Search routines, such as: FIND, GET, REMOVE, POLL, etc... If one is using the class TextComparitor, it is important to remember that it usually works in coordination with Java's Varargs syntax which allows anywhere from '0' to 'n' String's.

    This class of Exception will be thrown if any one of them is null, or if zero arguments were passed to the Varargs syntax.

    This class provides some public final "inspection & convenience" fields which should guarantee to avoid having null values when this Exception is thrown by an internal method. If as a programmer, you intended to extend use of this class, make sure to pass valid-information & valid-data, to the constructors of this class.
    See Also:
    Serialized Form


    • Field Summary

       
      Serializable ID
      Modifier and Type Field
      static long serialVersionUID
       
      'final' Exception Convenience Fields
      Modifier and Type Field
      Vector<String> compareStrVec
      int i
    • Constructor Summary

      Constructors 
      Constructor Description
      TCCompareStrException​(String message, String[] compareStr, int i)
      Constructs a new exception with the specified detail message, and the two public, final parameters: compareStr and i.
      TCCompareStrException​(String message, Throwable cause, String[] compareStr, int i)
      Constructs a new exception with the specified detail message, cause-chain throwable, and the two public, final parameters: compareStr and i.
    • Method Summary

       
      'static' Exception Check Methods
      Modifier and Type Method
      static void check​(String... compareStr)
      • 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;
        
      • compareStrVec

        🡅  🡇     🗕  🗗  🗖
        public final java.util.Vector<java.lang.String> compareStrVec
        This field is provided to the user as a matter of convenience. All instances of this Exception ought to guarantee that when an instance is thrown - any & all "Convenience Fields" have been properly set.

        If this package is extended, or if this exception is used elsewhere, try to remember to not to accidentally leave this field null when using this class' constructors.

        In Summary:
        All this is really trying to explain is that, when debugging your code, if in the analysis of a particular Exception, that analysis causes another exception throw (NullPointerException) - BECAUSE THIS CONVENIENCE FIELD WAS LEFT NULL - you would likely get pretty angry.

        This should contain the list of compare-String's passed for a parameter list to a TextComparitor.
      • i

        🡅  🡇     🗕  🗗  🗖
        public final int i


        This field is intended to store the index into the 'compareStrVec' of the compare-String that caused the exception throw in the first place.
    • Constructor Detail

      • TCCompareStrException

        🡅  🡇     🗕  🗗  🗖
        public TCCompareStrException​(java.lang.String message,
                                     java.lang.String[] compareStr,
                                     int i)
        Constructs a new exception with the specified detail message, and the two public, final parameters: compareStr and i.
        Parameters:
        message - the detail message.
        compareStr - This SHOULD BE the list of compare-String's that were passed to a TextComparitor that may have contained a null value, or was empty.

        This parameter should not be left null. If it were accidentally left null, this could force exception-handling code to to throw an exception itself - while checking exceptions! Note that checking the input to this constructor does occur, and if this parameter is passed a null value, an instance of Torello.Java.ExceptionCheckError will throw.
        i - This is the index into the 'compareStr' var-args parameter list that caused the exception to throw.
        See Also:
        compareStrVec, i
      • TCCompareStrException

        🡅  🡇     🗕  🗗  🗖
        public TCCompareStrException​(java.lang.String message,
                                     java.lang.Throwable cause,
                                     java.lang.String[] compareStr,
                                     int i)
        Constructs a new exception with the specified detail message, cause-chain throwable, and the two public, final parameters: compareStr and i.
        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.)
        compareStr - This SHOULD BE the list of compare-String's that were passed to a TextComparitor that may have contained a null value, or was empty.

        This parameter should not be left null. If it were accidentally left null, this could force exception-handling code to to throw an exception itself - while checking exceptions! Note that checking the input to this constructor does occur, and if this parameter is passed a null value, an instance of Torello.Java.ExceptionCheckError will throw.
        i - This is the index into the 'compareStr' var-args parameter list that caused the exception to throw.
        See Also:
        compareStrVec, i
    • Method Detail

      • check

        🡅     🗕  🗗  🗖
        public static void check​(java.lang.String... compareStr)
        This will do a simple test of the compare-String's to make sure none of them are null, and that there are at least one String in the String[] array.

        Explanation:
        It is a subtle issue, but likely better to throw exceptions when one of the Varargs to a String comparison is 'null'. Since there is likely no general-convention or agreement on what null in the presence of logical AND, OR, NOT, XOR, NAND really means, throwing a StrCmprException when even one var-args string-parameter is 'null' actually makes the most sense.
        Parameters:
        compareStr - This should be the var-args parameter that was passed to a search method
        Throws:
        TCCompareStrException - If any of the elements of 'compareStr' is null, or if the String[] array is zero-length.
        Code:
        Exact Method Body:
         if (compareStr == null) throw new NullPointerException
             ("The compareStr varags parameter, itself, was null.");
        
         if (compareStr.length == 0) throw new TCCompareStrException(
             "You have passed zero-arguments to a search-method's var-args String... " +
             "parameter.  You must pass at least one non-null compare-string",
             compareStr, 0
         );
        
         for (int i=0; i < compareStr.length; i++)
             if (compareStr[i] == null) throw new TCCompareStrException(
                 "One of the compare-strings passed to a search-method's var-args " +
                 "String... parameter was null.  This is not allowed.",
                 compareStr, i
             );