| 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: NotDirectoryException.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 directory in the filesystem. |
| 26 | * @version $Revision: 1.1 $ |
| 27 | * @since RbUtils 0.1.0 |
| 28 | * @author redfish |
| 29 | */ |
| 30 | public class NotDirectoryException extends IllegalArgumentException { |
| 31 | /** Candidate <code>File</code> to be a directory. */ |
| 32 | private File candidateDirectory; |
| 33 | /** Automaticly generated. */ |
| 34 | private static final long serialVersionUID = 3258126972922901046L; |
| 35 | |
| 36 | /** |
| 37 | * Instanciates a new <code>NotDirectoryException</code>. |
| 38 | * @param candidateDirectory <code>File</code> which was supposed to be a directory in the |
| 39 | * filesystem. |
| 40 | */ |
| 41 | public NotDirectoryException(final File candidateDirectory) { |
| 42 | this.candidateDirectory = candidateDirectory; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * {@inheritDoc} |
| 47 | */ |
| 48 | public String getLocalizedMessage() { |
| 49 | // RFE a localiser |
| 50 | return getMessage(); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * {@inheritDoc} |
| 55 | */ |
| 56 | public String getMessage() { |
| 57 | // RFE a localiser |
| 58 | String path = null; |
| 59 | if (candidateDirectory != null) { |
| 60 | path = candidateDirectory.getAbsolutePath(); |
| 61 | } |
| 62 | return path + " is not a directory"; |
| 63 | } |
| 64 | } |