KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > vfs > NotFoundPath


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.vfs;
30
31 import java.io.FileNotFoundException JavaDoc;
32 import java.io.IOException JavaDoc;
33 import java.util.Map JavaDoc;
34
35 /**
36  * Always returns <code>FileNotFound</code> for any open attempt.
37  * <code>NotFoundPath</code> is a useful utility Path for MergePath when
38  * the path doesn't exist in any of the merged paths.
39  *
40  * @since Resin 1.2
41  */

42 public class NotFoundPath extends Path {
43   private String JavaDoc _url;
44
45   /**
46    * Creates new NotFoundPath
47    */

48   public NotFoundPath(String JavaDoc url)
49   {
50     super(null);
51
52     _url = url;
53     _schemeMap = SchemeMap.getNullSchemeMap();
54   }
55
56   /**
57    * Dummy return.
58    */

59   public Path schemeWalk(String JavaDoc userPath,
60              Map JavaDoc<String JavaDoc,Object JavaDoc> attributes,
61                          String JavaDoc path, int offset)
62   {
63     return this;
64   }
65
66   /**
67    * The URL is error
68    */

69   public String JavaDoc getURL()
70   {
71     return "error:" + _url;
72   }
73
74   public String JavaDoc getScheme()
75   {
76     return "error";
77   }
78
79   /**
80    * Returns the URL which can't be found.
81    */

82   public String JavaDoc getPath()
83   {
84     return _url;
85   }
86
87   /**
88    * Dummy return.
89    */

90   public Path lookupImpl(String JavaDoc userPath, Map JavaDoc<String JavaDoc,Object JavaDoc> newAttributes)
91   {
92     return this;
93   }
94
95   /**
96    * Throws a FileNotFoundException for any read.
97    */

98   public StreamImpl openReadImpl()
99     throws IOException JavaDoc
100   {
101     throw new FileNotFoundException JavaDoc(_url);
102   }
103
104   protected Path copyCache()
105   {
106     return null;
107   }
108 }
109
Popular Tags