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 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  }