Package Torello.Java

Class NException

  • All Implemented Interfaces:
    java.io.Serializable

    public class NException
    extends java.lang.IndexOutOfBoundsException
    NException - Documentation.

    This exception is used by class StrIndexOf in all of the methods in which a int n is required. These are the methods whose names begins with the 3-letter 'nth'. If an inappropriate value for int n is passed, then this exception will throw. Since the value of 'n' refers to the nth-instance of a substring or character. This exception is also used in the package HTML.NodeSearch, for the exact same purpose, but applied to HTML Vector's.
    See Also:
    Serialized Form



    • Method Summary

      All Methods Static Methods Concrete 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:
        1
        public static final long serialVersionUID = 1;
        
    • Constructor Detail

      • NException

        public NException()
        Constructs an NException with no detail message.
      • 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:
        1
        2
        3
        4
        5
        6
         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:
        1
        2
        3
        4
        5
        6
         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:
        1
        2
        3
        4
        5
        6
        7
         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.");