Package Torello.Java
Class FileExpectedException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- Torello.Java.FileExpectedException
-
- All Implemented Interfaces:
java.io.Serializable
public class FileExpectedException extends java.lang.RuntimeException
FileExpectedException - Documentation.
This class is used inside theclass FileNode.
It may be used to inform a user he has attempted to perform a particular method or operation on an instance ofFileNode
that was created to function as a "directory" rather than a "file." If the method involved may only be used on files, this exception (aRuntimeException
) will be thrown.
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/FileExpectedException.java
- Open New Browser-Tab: Torello/Java/FileExpectedException.java
-
-
Field Summary
Fields Modifier and Type Field FileNode
fn
static long
serialVersionUID
-
Constructor Summary
Constructors Constructor FileExpectedException(String message, Throwable cause, FileNode fn)
FileExpectedException(String message, FileNode fn)
-
Method Summary
All Methods Static Methods Concrete Methods Modifier 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:
1
public static final long serialVersionUID = 1;
-
fn
public final FileNode fn
This field is provided to the user as a matter of convenience. All instantiations of thisException
are guaranteed to enforce and ensure that when an instance of this exception is thrown, the convenience field will not be null. If this package is extended, it is up to the programmer/user to make sure not to leave this field null when using one of these constructors. This constructor will not check whether a convenience field isnull
or not, when constructing the exception.
IMPORTANT: 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 (likeNullPointerException
) - BECAUSE THIS CONVENIENCE FIELD WAS LEFT NULL - would be an unnecessary source of headache.
This public final field contains theFileNode
that caused an exception to throw.- Code:
- Exact Field Declaration Expression:
1
public final FileNode fn;
-
-
Constructor Detail
-
FileExpectedException
public FileExpectedException(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 exceptions while checking exceptions!- See Also:
fn
-
FileExpectedException
public FileExpectedException(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.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 exceptions while checking exceptions!cause
- This parameter may be used when generating "multiple-exceptions" that are modified as they are thrown.- See Also:
fn
-
-
Method Detail
-
check
public static void check(FileNode fn)
Checks whether or not theFileNode
parameter passed is actually one representing a file, not a directory.- Parameters:
fn
- This may be any instance ofFileNode
however if it is not one that is meaning to represent an operating-system file, then this method will automatically throw an exception.- Throws:
FileExpectedException
- If parameter'fn'
is a file, not a directory.- Code:
- Exact Method Body:
1 2 3 4 5
if (fn.isDirectory) throw new FileExpectedException( "The invocation of the previous method on a FileNode that is, itself, a directory " + "and not a file instead cannot proceed.", fn );
-
-