View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2005 Kevin Rogers
4   //
5   // This file is part of MillScript.
6   //
7   // MillScript is free software; you can redistribute it and/or modify it under
8   // the terms of the GNU General Public License as published by the Free
9   // Software Foundation; either version 2 of the License, or (at your option)
10  // any later version.
11  //
12  // MillScript is distributed in the hope that it will be useful, but WITHOUT
13  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  // more details.
16  //
17  // You should have received a copy of the GNU General Public License along with
18  // MillScript; if not, write to the Free Software Foundation, Inc., 59 Temple
19  // Place, Suite 330, Boston, MA  02111-1307  USA
20  ////////////////////////////////////////////////////////////////////////////////
21  package org.millscript.commons.vfs.alerts;
22  
23  import org.millscript.commons.alert.Alert;
24  import org.millscript.commons.vfs.VEntry;
25  
26  /**
27   * This class implements an Alert for use in situations like where a
28   * <code>FileNotFoundException</code> has been thrown, or when a virtual
29   * filesystem entry cannot be found.
30   */
31  public class VEntryNotFoundAlert extends VFSAlert {
32  
33      /**
34       * This is the ID from the first release for future compatibility.
35       */
36      private static final long serialVersionUID = 4049924848405262384L;
37  
38      /**
39       * Constructs a new virtual file not found alert with no explanation.
40       */
41      public VEntryNotFoundAlert() {
42          this( null );
43      }
44  
45      /**
46       * Constructs a new virtual file not found alert with the specified
47       * explanation.
48       *
49       * @param exp   the explanation for the alert
50       */
51      public VEntryNotFoundAlert( final String exp ) {
52          this( "Entry not found", exp );
53      }
54  
55      /**
56       * Constructs a new alert with the specified complaint and explanation.
57       * This constructor is for private use, to allow us to provide an exception
58       * hierarchy.
59       *
60       * @param comp  the alerts complaint
61       * @param exp   the explanation for the alert
62       */
63      protected VEntryNotFoundAlert( final String comp, final String exp ) {
64          super( comp, exp );
65      }
66  
67      public VEntryNotFoundAlert culpritEntry( final String entryName ) {
68          return (VEntryNotFoundAlert) this.culprit( "entry name", entryName );
69      }
70  
71      public static Alert entryDoesNotExist() {
72          return new VEntryNotFoundAlert( "Required entry does not exist" );
73      }
74  
75      public static Alert entryDoesNotExist( final String entryName ) {
76          return new VEntryNotFoundAlert( "Required entry does not exist" ).culpritEntry( entryName );
77      }
78  
79      public static Alert entryDoesNotExist( final VEntry entry ) {
80          return new VEntryNotFoundAlert( "Required entry does not exist" ).decorate( entry );
81      }
82  
83      public static Alert entryIsNotAFile( final String entryName ) {
84          return new VEntryNotFoundAlert( "Required entry exists but is not a file" ).culpritEntry( entryName );
85      }
86  
87      public static Alert entryIsNotAFile( final VEntry entry ) {
88          return new VEntryNotFoundAlert( "Required entry exists but is not a file" ).decorate( entry );
89      }
90  
91      public static Alert entryIsNotAFileOrFolder( final String entryName ) {
92          return new VEntryNotFoundAlert( "Required entry exists but is not a file or a folder!?" ).culpritEntry( entryName );
93      }
94  
95      public static Alert entryIsNotAFileOrFolder( final VEntry entry ) {
96          return new VEntryNotFoundAlert( "Required entry exists but is not a file or a folder!?" ).decorate( entry );
97      }
98  
99      public static Alert entryIsNotAFolder( final String entryName ) {
100         return new VEntryNotFoundAlert( "Required entry exists but is not a folder" ).culpritEntry( entryName );
101     }
102 
103     public static Alert entryIsNotAFolder( final VEntry entry ) {
104         return new VEntryNotFoundAlert( "Required entry exists but is not a folder" ).decorate( entry );
105     }
106 
107 }