01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.cocoon.components.source;
19:
20: import java.io.IOException;
21: import java.net.MalformedURLException;
22: import java.util.Map;
23:
24: import org.apache.cocoon.ProcessingException;
25: import org.apache.cocoon.environment.Source;
26: import org.apache.cocoon.environment.SourceResolver;
27: import org.xml.sax.SAXException;
28:
29: /**
30: * An adapter for the Excalibur SourceResolver.
31: *
32: * @version CVS $Id: SourceResolverAdapter.java 433543 2006-08-22 06:22:54Z crossley $
33: */
34: public class SourceResolverAdapter implements SourceResolver {
35: private org.apache.excalibur.source.SourceResolver resolver;
36:
37: public SourceResolverAdapter(
38: org.apache.excalibur.source.SourceResolver resolver) {
39: this .resolver = resolver;
40: }
41:
42: /**
43: * Get a <code>Source</code> object.
44: * This is a shortcut for <code>resolve(location, null, null)</code>
45: * @throws org.apache.excalibur.source.SourceException if the source cannot be resolved
46: */
47: public org.apache.excalibur.source.Source resolveURI(String location)
48: throws MalformedURLException, IOException,
49: org.apache.excalibur.source.SourceException {
50:
51: return this .resolver.resolveURI(location);
52: }
53:
54: /**
55: * Get a <code>Source</code> object.
56: * @param location - the URI to resolve. If this is relative it is either
57: * resolved relative to the base parameter (if not null)
58: * or relative to a base setting of the source resolver
59: * itself.
60: * @param base - a base URI for resolving relative locations. This
61: * is optional and can be <code>null</code>.
62: * @param parameters - Additional parameters for the URI. The parameters
63: * are specific to the used protocol.
64: * @throws org.apache.excalibur.source.SourceException if the source cannot be resolved
65: */
66: public org.apache.excalibur.source.Source resolveURI(
67: String location, String base, Map parameters)
68: throws MalformedURLException, IOException,
69: org.apache.excalibur.source.SourceException {
70:
71: return this .resolver.resolveURI(location, base, parameters);
72: }
73:
74: /**
75: * Releases a resolved resource
76: */
77: public void release(org.apache.excalibur.source.Source source) {
78: this .resolver.release(source);
79: }
80:
81: /**
82: * Resolve the source.
83: * @param systemID This is either a system identifier
84: * (<code>java.net.URL</code> or a local file.
85: * @deprecated Use the resolveURI methods instead
86: */
87: public Source resolve(String systemID) throws ProcessingException,
88: SAXException, IOException {
89:
90: throw new RuntimeException(
91: "Method SourceResolver.resolve(String) is deprecated");
92: }
93: }
|