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 java.net.URI;
24
25 /**
26 * Thrown to indicate a URI is not supported.
27 */
28 public class UnsupportedURIAlert extends VFSAlert {
29
30 /**
31 * This is the ID from the first release for future compatibility.
32 */
33 private static final long serialVersionUID = 3256438088669344561L;
34
35 /**
36 * Constructs a new unsupported URI alert with no explanation.
37 */
38 public UnsupportedURIAlert() {
39 this( null );
40 }
41
42 /**
43 * Constructs a new unsupported URI alert with the specified explanation.
44 *
45 * @param exp the explanation for the alert
46 */
47 public UnsupportedURIAlert( final String exp ) {
48 this( "Unsupported URI", exp );
49 }
50
51 /**
52 * Constructs a new alert with the specified complaint and explanation.
53 * This constructor is for private use, to allow us to provide an exception
54 * hierarchy.
55 *
56 * @param comp the alerts complaint
57 * @param exp the explanation for the alert
58 */
59 protected UnsupportedURIAlert( final String comp, final String exp ) {
60 super( comp, exp );
61 }
62
63 public static UnsupportedURIAlert mustBeAbsolute( final URI uri ) {
64 return (UnsupportedURIAlert) new UnsupportedURIAlert(
65 "The specified URI must be absolute(e.g. include a scheme like http or file)"
66 ).culpritURI( uri );
67 }
68
69 public static UnsupportedURIAlert mustBeRelative( final URI uri ) {
70 return (UnsupportedURIAlert) new UnsupportedURIAlert(
71 "The specified URI must be relative(e.g. must not have a scheme part)"
72 ).culpritURI( uri );
73 }
74
75 public static UnsupportedURIAlert mustNotBeOpaque( final URI uri ) {
76 return (UnsupportedURIAlert) new UnsupportedURIAlert(
77 "The specified URI must not be opaque(e.g. the path must start with a slash)"
78 ).culpritURI( uri );
79 }
80
81 }