2 // ========================================================================
3 // Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
19 package org.eclipse.jetty.util.resource;
22 import java.io.FileNotFoundException;
23 import java.io.IOException;
24 import java.io.InputStream;
28 /* ------------------------------------------------------------ */
31 * A Resource that is returned for a bade URL. Acts as a resource
32 * that does not exist and throws appropriate exceptions.
36 class BadResource extends URLResource
38 /* ------------------------------------------------------------ */
39 private String _message=null;
41 /* -------------------------------------------------------- */
42 BadResource(URL url, String message)
49 /* -------------------------------------------------------- */
51 public boolean exists()
56 /* -------------------------------------------------------- */
58 public long lastModified()
63 /* -------------------------------------------------------- */
65 public boolean isDirectory()
70 /* --------------------------------------------------------- */
78 /* ------------------------------------------------------------ */
85 /* --------------------------------------------------------- */
87 public InputStream getInputStream() throws IOException
89 throw new FileNotFoundException(_message);
92 /* --------------------------------------------------------- */
94 public boolean delete()
95 throws SecurityException
97 throw new SecurityException(_message);
100 /* --------------------------------------------------------- */
102 public boolean renameTo( Resource dest)
103 throws SecurityException
105 throw new SecurityException(_message);
108 /* --------------------------------------------------------- */
110 public String[] list()
115 /* ------------------------------------------------------------ */
117 public void copyTo(File destination)
120 throw new SecurityException(_message);
123 /* ------------------------------------------------------------ */
125 public String toString()
127 return super.toString()+"; BadResource="+_message;