001    /* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil -*-
002     *
003     * $Id$
004     *
005     * Copyright (c) 2010-2011 Edugility LLC.
006     *
007     * Permission is hereby granted, free of charge, to any person
008     * obtaining a copy of this software and associated documentation
009     * files (the "Software"), to deal in the Software without
010     * restriction, including without limitation the rights to use, copy,
011     * modify, merge, publish, distribute, sublicense and/or sell copies
012     * of the Software, and to permit persons to whom the Software is
013     * furnished to do so, subject to the following conditions:
014     * 
015     * The above copyright notice and this permission notice shall be
016     * included in all copies or substantial portions of the Software.
017     * 
018     * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
019     * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
020     * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
021     * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
022     * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
023     * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
024     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
025     * DEALINGS IN THE SOFTWARE.
026     *
027     * The original copy of this license is available at
028     * http://www.opensource.org/license/mit-license.html.
029     */
030    package com.edugility.jpa.maven.plugin;
031    
032    import java.io.File;
033    import java.io.IOException;
034    
035     /**
036      * An {@link IOException} that results from a {@link File} failing
037      * validation of some kind.
038      *
039      * @author <a href="mailto:ljnelson@gmail.com">Laird Nelson</a>
040      *
041      * @version 1.0-SNAPSHOT
042      *
043      * @since 1.0-SNAPSHOT
044      *
045      * @see DirectoryException
046      */
047    public abstract class FileException extends IOException {
048    
049      /**
050       * The {@link File} that failed validation.  This field may be
051       * {@code null}.
052       */
053      private final File file;
054    
055      /**
056       * Creates a new {@link FileException}.
057       *
058       * @param file the {@link File} whose validation failure caused this
059       * {@link FileException} to be thrown; may be {@code null}
060       */
061      protected FileException(final File file) {
062        this(file, (Throwable)null, (String)null);
063      }
064    
065      /**
066       * Creates a new {@link FileException}.
067       *
068       * @param file the {@link File} whose validation failure caused this
069       * {@link FileException} to be thrown; may be {@code null}
070       *
071       * @param message a detail message further explaining this {@link
072       * FileException}; may be {@code null}
073       */
074      protected FileException(final File file, final String message) {
075        this(file, (Throwable)null, message);
076      }
077    
078      /**
079       * Creates a new {@link FileException}.
080       *
081       * @param file the {@link File} whose validation failure caused this
082       * {@link FileException} to be thrown; may be {@code null}
083       *
084       * @param cause the {@link Throwable} that contributed to this
085       * {@link FileException}'s cause; may be {@code null}
086       *
087       * @param message a detail message further explaining this {@link
088       * FileException}; may be {@code null}
089       */
090      protected FileException(final File file, final Throwable cause, final String message) {
091        super(message, cause);
092        this.file = file;
093      }
094    
095      /**
096       * Returns the {@link File} whose validation failure caused this
097       * {@link FileException} to be thrown.
098       *
099       * <p>This method may return {@code null}.</p>
100       *
101       * @return the {@link File} whose validation failure caused this
102       * {@link FileException} to be thrown, or {@code null}
103       */
104      public File getFile() {
105        return this.file;
106      }
107    
108    }