1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 }