KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mortbay > util > BadResource


1 // ========================================================================
2
// $Id: BadResource.java,v 1.5 2004/05/09 20:32:49 gregwilkins Exp $
3
// Copyright 1996-2004 Mort Bay Consulting Pty. Ltd.
4
// ------------------------------------------------------------------------
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
// ========================================================================
15
package org.mortbay.util;
16
17 import java.io.File JavaDoc;
18 import java.io.FileNotFoundException JavaDoc;
19 import java.io.IOException JavaDoc;
20 import java.io.InputStream JavaDoc;
21 import java.io.OutputStream JavaDoc;
22 import java.net.URL JavaDoc;
23
24
25 /* ------------------------------------------------------------ */
26 /** Bad Resource.
27  *
28  * A Resource that is returned for a bade URL. Acts as a resource
29  * that does not exist and throws appropriate exceptions.
30  *
31  * @version $Revision: 1.5 $
32  * @author Greg Wilkins (gregw)
33  */

34 class BadResource extends URLResource
35 {
36     /* ------------------------------------------------------------ */
37     private String JavaDoc _message=null;
38         
39     /* -------------------------------------------------------- */
40     BadResource(URL JavaDoc url, String JavaDoc message)
41     {
42         super(url,null);
43         _message=message;
44     }
45     
46
47     /* -------------------------------------------------------- */
48     public boolean exists()
49     {
50         return false;
51     }
52         
53     /* -------------------------------------------------------- */
54     public long lastModified()
55     {
56         return -1;
57     }
58
59     /* -------------------------------------------------------- */
60     public boolean isDirectory()
61     {
62         return false;
63     }
64
65     /* --------------------------------------------------------- */
66     public long length()
67     {
68         return -1;
69     }
70         
71         
72     /* ------------------------------------------------------------ */
73     public File JavaDoc getFile()
74     {
75         return null;
76     }
77         
78     /* --------------------------------------------------------- */
79     public InputStream JavaDoc getInputStream() throws IOException JavaDoc
80     {
81         throw new FileNotFoundException JavaDoc(_message);
82     }
83         
84     /* --------------------------------------------------------- */
85     public OutputStream JavaDoc getOutputStream()
86         throws java.io.IOException JavaDoc, SecurityException JavaDoc
87     {
88         throw new FileNotFoundException JavaDoc(_message);
89     }
90         
91     /* --------------------------------------------------------- */
92     public boolean delete()
93         throws SecurityException JavaDoc
94     {
95         throw new SecurityException JavaDoc(_message);
96     }
97
98     /* --------------------------------------------------------- */
99     public boolean renameTo( Resource dest)
100         throws SecurityException JavaDoc
101     {
102         throw new SecurityException JavaDoc(_message);
103     }
104
105     /* --------------------------------------------------------- */
106     public String JavaDoc[] list()
107     {
108         return null;
109     }
110
111     /* ------------------------------------------------------------ */
112     public String JavaDoc toString()
113     {
114         return super.toString()+"; BadResource="+_message;
115     }
116     
117 }
118
Popular Tags