Package Torello.Java
Class NException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- java.lang.IndexOutOfBoundsException
-
- Torello.Java.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 classesStrIndexOf
andStrTokIndexOf
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 thepackage HTML.NodeSearch
, for the exact same purpose, but applied to HTMLVector
match-counts, rather than sub-String
match-counts.- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/Java/NException.java
- Open New Browser-Tab: Torello/Java/NException.java
File Size: 5,754 Bytes Line Count: 148 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description NException()
Constructs anNException
with no detail message.NException(int n)
Constructs a new NException with an argument indicating the value of'n'
was the problem for a message.NException(String message)
Constructs anNException
with the specified detail message.NException(String message, Throwable cause)
Constructs a new exception with the specified detail'message'
and'cause'
.NException(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 MethodsModifier and Type Method static void
check(int n)
static void
check(int n, String s)
static void
check(int n, Vector<?> v)
-
-
-
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 theSerializable
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'sjava.lang.Exception
andjava.lang.Error
classes 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;
-
-
Constructor Detail
-
NException
public NException()
Constructs anNException
with no detail message.
-
NException
public NException(java.lang.String message)
Constructs anNException
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 into this exception's detail message.- Parameters:
message
- The detail message (which is saved for later retrieval by thThrowable.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 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 theThrowable.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 ajava.lang.String
, for the purposes ofString
-Comparison Routines.- Parameters:
n
- This is the value of'n'
to checks
- This parameter is theString
against which the index-of operation is being performed.- Throws:
NException
- if'n'
is less than1
, or greater than the length of theString
.- 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 aVector
, for the purposes ofVector
-Search Routines.- Parameters:
n
- This is the value of'n'
to checkv
- This parameter is theVector
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 than1
, or greater than the size of theVector
.- 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 ofn
to check- Throws:
NException
- if'n'
is less than1
.- 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.");
-
-