Package Torello.Java

Class NException

  • All Implemented Interfaces:
    java.io.Serializable

    public class NException
    extends java.lang.IndexOutOfBoundsException
    Throws when a Method's (or Constructor's) integer-valued parameter (often for parameters that are actually named 'n', representing a 'count' of some form or fasion) does not adhere to some of those Method's expectations or requirements. This exception is used, extensively, by the classes StrIndexOf and StrTokIndexOf inside all methods where an integer parameter 'n' is required. (These methods all have names that begin with the three letters 'nth'). If an inappropriate value for 'n' is passed - for instance a negative value - then this exception will throw. The value of 'n' refers to the nth-instance of a substring or character, and thusly, negative-values are meaningless.

    This exception is also used in the package HTML.NodeSearch, for the exact same purpose, but applied to HTML Vector match-counts, rather than sub-String match-counts.
    See Also:
    Serialized Form


    • Field Summary

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

       
      'static' Exception Check Methods
      Modifier and Type Method
      static void check​(int n)
      static void check​(int n, String s)
      static void check​(int n, Vector<?> v)
      • 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

      • NException

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

        🡅  🡇    
        public NException​(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 in this exception's detail message.
        Parameters:
        message - The detail message (which is saved for later retrieval by th 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.)
      • NException

        🡅  🡇    
        public NException​(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.)
      • NException

        🡅  🡇    
        public NException​(int n)
        Constructs a new NException with an argument indicating the value of 'n' was the problem for a message. This is the internally used constructor.
        Parameters:
        n - This is just the value of 'n' that was passed, and caused the exception.
    • Method Detail

      • check

        🡅  🡇    
        public static void check​(int n,
                                 java.lang.String s)
        This will check a value of of parameter 'n' against a java.lang.String, for the purposes of String-Comparison Routines.
        Parameters:
        n - This is the value of 'n' to check
        s - This parameter is the String against which the index-of operation is being performed.
        Throws:
        NException - if 'n' is less than 1, or greater than the length of the String.
        Code:
        Exact Method Body:
         if (n < 1) throw new NException(n);
        
         if (n > s.length()) throw new NException(
             "The value passed to parameter 'n' [" + n + "] is greater than the compare-string length " +
             "[" + s.length() + "]"
         );
        
      • check

        🡅  🡇    
        public static void check​(int n,
                                 java.util.Vector<?> v)
        This will check a value of of parameter 'n' against a Vector, for the purposes of Vector-Search Routines.
        Parameters:
        n - This is the value of 'n' to check
        v - This parameter is the Vector against which the index-of operation is being performed.

        NOTE: 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:all option is used.
        Throws:
        NException - if 'n' is less than 1, or greater than the size of the Vector.
        Code:
        Exact Method Body:
         if (n < 1) throw new NException(n);
        
         if (n > v.size()) throw new NException(
             "The value passed to parameter 'n' [" + n + "] is greater than the vector size " +
             "[" + v.size() + "]"
         );
        
      • check

        🡅    
        public static void check​(int n)
        This will check a value of of parameter 'n' to ensure that it is a positive-Integer (greater-than zero).
        Parameters:
        n - This is the value of n to check
        Throws:
        NException - if 'n' is less than 1.
        Code:
        Exact Method Body:
         if (n < 0)  throw new NException(
             "A negative value has been passed to parameter 'n' [" + n + "], but " +
             "this is not allowed here."
         );
        
         if (n == 0) throw new NException
             ("Zero was passed to parameter 'n', but this is not allowed here.");