KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > source > SourceResolverAdapter


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.cocoon.components.source;
18
19 import java.io.IOException JavaDoc;
20 import java.net.MalformedURLException JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import org.apache.cocoon.ProcessingException;
24 import org.apache.cocoon.environment.Source;
25 import org.apache.cocoon.environment.SourceResolver;
26 import org.xml.sax.SAXException JavaDoc;
27
28 /**
29  * An adapter for the Excalibur SourceResolver.
30  *
31  * @version CVS $Id: SourceResolverAdapter.java 55454 2004-10-24 18:02:39Z cziegeler $
32  */

33 public class SourceResolverAdapter implements SourceResolver
34 {
35     private org.apache.excalibur.source.SourceResolver resolver;
36
37     public SourceResolverAdapter(org.apache.excalibur.source.SourceResolver resolver) {
38         this.resolver = resolver;
39     }
40
41     /**
42      * Get a <code>Source</code> object.
43      * This is a shortcut for <code>resolve(location, null, null)</code>
44      * @throws org.apache.excalibur.source.SourceException if the source cannot be resolved
45      */

46     public org.apache.excalibur.source.Source resolveURI( String JavaDoc location )
47         throws MalformedURLException JavaDoc, IOException JavaDoc, org.apache.excalibur.source.SourceException {
48   
49         return this.resolver.resolveURI(location);
50     }
51
52     /**
53      * Get a <code>Source</code> object.
54      * @param location - the URI to resolve. If this is relative it is either
55      * resolved relative to the base parameter (if not null)
56      * or relative to a base setting of the source resolver
57      * itself.
58      * @param base - a base URI for resolving relative locations. This
59      * is optional and can be <code>null</code>.
60      * @param parameters - Additional parameters for the URI. The parameters
61      * are specific to the used protocol.
62      * @throws org.apache.excalibur.source.SourceException if the source cannot be resolved
63      */

64     public org.apache.excalibur.source.Source resolveURI( String JavaDoc location,
65                                                           String JavaDoc base,
66                                                           Map JavaDoc parameters )
67         throws MalformedURLException JavaDoc, IOException JavaDoc, org.apache.excalibur.source.SourceException {
68
69         return this.resolver.resolveURI(location, base, parameters);
70     }
71
72     /**
73      * Releases a resolved resource
74      */

75     public void release( org.apache.excalibur.source.Source source ) {
76         this.resolver.release(source);
77     }
78
79     /**
80      * Resolve the source.
81      * @param systemID This is either a system identifier
82      * (<code>java.net.URL</code> or a local file.
83      * @deprecated Use the resolveURI methods instead
84      */

85     public Source resolve(String JavaDoc systemID)
86         throws ProcessingException, SAXException JavaDoc, IOException JavaDoc {
87
88         throw new RuntimeException JavaDoc("Method SourceResolver.resolve(String) is deprecated");
89     }
90 }
91
Popular Tags