Package Torello.Java
Class DirExpectedException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- Torello.Java.FileNodeException
-
- Torello.Java.DirExpectedException
-
- All Implemented Interfaces:
java.io.Serializable
public class DirExpectedException extends FileNodeException
Thrown when aFileNode
operation has been invoked on an instance that represents an Operating-SystemFile
, but that invoked-method may only be applied to Operating-SystemDirectory
instances. This is aRuntimeException
, not a checked-exception.
This class provides somepublic final
"inspection & convenience" fields which should guarantee to avoid havingnull
values when thisException
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
Hi-Lited Source-Code:- View Here: Torello/Java/DirExpectedException.java
- Open New Browser-Tab: Torello/Java/DirExpectedException.java
File Size: 3,333 Bytes Line Count: 92 '\n' Characters Found
-
-
Field Summary
Serializable ID Modifier and Type Field static long
serialVersionUID
'final'
Exception Convenience FieldsModifier and Type Field FileNode
fn
-
Constructor Summary
Constructors Constructor Description DirExpectedException(String message, Throwable cause, FileNode fn)
Constructs a new exception with the specified detail message, cause-chainThrowable
, and onepublic, final
parameter:fn
.DirExpectedException(String message, FileNode fn)
Constructs a new exception with the specified detail message, and onepublic, final
parameter:fn
.
-
Method Summary
'static'
Exception Check MethodsModifier and Type Method static void
check(FileNode fn)
-
-
-
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;
-
fn
public final FileNode fn
This field is provided to the user as a matter of convenience. All instances of thisException
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 particularException
, that analysis causes another exception throw (NullPointerException
) - BECAUSE THIS CONVENIENCE FIELD WAS LEFT NULL - you would likely get pretty angry.
Thispublic final
field contains theFileNode
that caused an exception to throw.
-
-
Constructor Detail
-
DirExpectedException
public DirExpectedException(java.lang.String message, FileNode fn)
Constructs a new exception with the specified detail message, and onepublic, final
parameter:fn
.- Parameters:
message
- This is any message informing the user what has occurred.fn
- This is the instance ofclass FileNode
that was involved in the mistake.
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 ofTorello.Java.ExceptionCheckError
will throw.- Throws:
ExceptionCheckError
- If parameter'fn'
is passed null- See Also:
fn
-
DirExpectedException
public DirExpectedException(java.lang.String message, java.lang.Throwable cause, FileNode fn)
Constructs a new exception with the specified detail message, cause-chainThrowable
, and onepublic, final
parameter:fn
.- Parameters:
message
- This is any message informing the user what has occurred.cause
- This parameter may be used when generating "multiple-exceptions" that are modified as they are thrown.fn
- This is the instance ofclass FileNode
that was involved in the mistake.
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 ofTorello.Java.ExceptionCheckError
will throw.- Throws:
ExceptionCheckError
- If parameter'fn'
is passed null- See Also:
fn
-
-
Method Detail
-
check
public static void check(FileNode fn)
Checks whether or not theFileNode
parameter passed is actually one representing a directory, not a file.- Parameters:
fn
- This may be any instance ofFileNode
however if it is not one that is meaning to represent an operating-system directory, then this method will automatically throw an exception.- Throws:
DirExpectedException
- If parameter'fn'
is a file, not a directory.- Code:
- Exact Method Body:
if (! fn.isDirectory) throw new DirExpectedException( "The invokation of the previous method on a FileNode that is, itself, a file and " + "not a directory cannot proceed.", fn );
-
-