| 1 | /* |
| 2 | * Copyright 2005-2006 The RbUtils Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | // $Id: NotFileException.java,v 1.1 2006/08/24 21:32:39 redfish Exp $ |
| 19 | |
| 20 | package org.ktc.rbutils.api.file; |
| 21 | |
| 22 | import java.io.File; |
| 23 | |
| 24 | /** |
| 25 | * Exception thrown when a <code>File</code> is not a file in the filesystem. |
| 26 | * @since RbUtils 0.7.4 |
| 27 | * @version $Revision: 1.1 $ |
| 28 | * @author redfish |
| 29 | */ |
| 30 | public class NotFileException extends IllegalArgumentException { |
| 31 | |
| 32 | /** Candidate <code>File</code> to be a file. */ |
| 33 | private File candidateFile; |
| 34 | /** Automaticly generated. */ |
| 35 | private static final long serialVersionUID = -1223518114779569935L; |
| 36 | |
| 37 | /** |
| 38 | * Instanciates a new <code>NotFileException</code>. |
| 39 | * @param candidateFile <code>File</code> which was supposed to be a file in the |
| 40 | * filesystem. |
| 41 | */ |
| 42 | public NotFileException(final File candidateFile) { |
| 43 | this.candidateFile = candidateFile; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * {@inheritDoc} |
| 48 | */ |
| 49 | public String getLocalizedMessage() { |
| 50 | // RFE a localiser |
| 51 | return getMessage(); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * {@inheritDoc} |
| 56 | */ |
| 57 | public String getMessage() { |
| 58 | // RFE a localiser |
| 59 | String path = null; |
| 60 | if (candidateFile != null) { |
| 61 | path = candidateFile.getAbsolutePath(); |
| 62 | } |
| 63 | return path + " is not a file"; |
| 64 | } |
| 65 | |
| 66 | } |