1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | package Torello.Java; /** * Thrown when a <CODE>FileNode</CODE> operation has been invoked on an instance that represents * an Operating-System <B><CODE>Directory</CODE></B>, but that invoked-method may only be applied * to Operating-System <B><CODE>File</CODE></B> instances. This is a {@code RuntimeException}, * not a checked-exception. * * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=EXPM> */ public class FileExpectedException extends RuntimeException { /** <EMBED CLASS='external-html' DATA-FILE-ID=SVUIDEX> */ public static final long serialVersionUID = 1; /** * <EMBED CLASS='external-html' DATA-FILE-ID=EXPF> * * <BR /><BR />This public final field contains the {@code FileNode} that caused an exception * to throw. */ public final FileNode fn; /** * Constructs a new exception with the specified detail message, and one {@code public, final} * parameter: {@code fn}. * * @param message This is any message informing the user what has occurred. * * @param fn This is the instance of {@code class FileNode} that was involved in the mistake. * <EMBED CLASS='external-html' DATA-FILE-ID=EXPF_PARAM> * * @throws ExceptionCheckError If parameter {@code 'fn'} is passed null * * @see #fn */ public FileExpectedException(String message, FileNode fn) { super(message); this.fn = fn; if (this.fn == null) throw new ExceptionCheckError ("FileExpectedException constructor parameter 'fn' was passed null"); } /** * Constructs a new exception with the specified detail message, cause-chain * {@code Throwable}, and one {@code public, final} parameter: {@code fn}. * * @param message This is any message informing the user what has occurred. * * @param cause This parameter may be used when generating "multiple-exceptions" that are * modified as they are thrown. * * @param fn This is the instance of {@code class FileNode} that was involved in the mistake. * <EMBED CLASS='external-html' DATA-FILE-ID=EXPF_PARAM> * * @throws ExceptionCheckError If parameter {@code 'fn'} is passed null * * @see #fn */ public FileExpectedException(String message, Throwable cause, FileNode fn) { super(message, cause); this.fn = fn; if (this.fn == null) throw new ExceptionCheckError ("FileExpectedException constructor parameter 'fn' was passed null"); } /** * Checks whether or not the {@code FileNode} parameter passed is actually one representing a * file, not a directory. * * @param fn This may be any instance of {@code FileNode} 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 {@code 'fn'} is a file, not a directory. */ public static void check(FileNode fn) { 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 ); } } |