KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > environment > URLFactorySourceResolver


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 package org.apache.cocoon.environment;
17
18 import org.apache.excalibur.source.SourceException;
19 import org.apache.avalon.framework.component.ComponentException;
20 import org.apache.avalon.framework.component.ComponentManager;
21 import org.apache.cocoon.ProcessingException;
22 import org.apache.cocoon.components.source.URLSource;
23 import org.apache.cocoon.components.url.URLFactory;
24 import org.xml.sax.ContentHandler JavaDoc;
25 import org.xml.sax.SAXException JavaDoc;
26
27 import java.io.IOException JavaDoc;
28 import java.net.MalformedURLException JavaDoc;
29 import java.net.URL JavaDoc;
30 import java.util.Map JavaDoc;
31
32 /**
33  * A <code>SourceResolver</code> based on a <code>URLFactory</code>.
34  * @deprecated by the new source resolving
35  *
36  * @author <a HREF="mailto:sylvain@apache.org">Sylvain Wallez</a>
37  * @version CVS $Id: URLFactorySourceResolver.java 30932 2004-07-29 17:35:38Z vgritsenko $
38  */

39
40 public class URLFactorySourceResolver implements SourceResolver {
41
42     /** The component manager */
43     protected ComponentManager manager;
44
45     /** The URL factory */
46     protected URLFactory urlFactory;
47
48     /**
49      * Creates an <code>URLFactorySourceResolver</code> with a component manager.
50      * The <code>URLFactory</code> is looked up in the component manager.
51      */

52     public URLFactorySourceResolver(ComponentManager manager)
53       throws ComponentException {
54         this.manager = manager;
55         this.urlFactory = (URLFactory)manager.lookup(URLFactory.ROLE);
56     }
57
58     /**
59      * Creates an <code>URLFactorySourceResolver</code> with a component manager and
60      * a <code>URLFactory</code> that will be used to resolve URLs.
61      */

62     public URLFactorySourceResolver(URLFactory factory, ComponentManager manager) {
63         this.urlFactory = factory;
64         this.manager = manager;
65     }
66
67     /**
68      * Resolve the source.
69      *
70      * @param systemID This is either a system identifier
71      * (<code>java.net.URL</code>) or a local file.
72      */

73     public Source resolve(String JavaDoc systemID)
74       throws ProcessingException, SAXException JavaDoc, IOException JavaDoc {
75
76         URL JavaDoc url = this.urlFactory.getURL(systemID);
77         return new URLSource(url, this.manager);
78     }
79
80     /**
81      * Get a <code>Source</code> object.
82      */

83     public org.apache.excalibur.source.Source resolveURI(final String JavaDoc location)
84     throws MalformedURLException JavaDoc, IOException JavaDoc, SourceException
85     {
86         return this.resolveURI(location, null, null);
87     }
88
89     /**
90      * Get a <code>Source</code> object.
91      */

92     public org.apache.excalibur.source.Source resolveURI(final String JavaDoc location,
93                                                                 String JavaDoc baseURI,
94                                                                 final Map JavaDoc parameters)
95     throws MalformedURLException JavaDoc, IOException JavaDoc, SourceException {
96         throw new RuntimeException JavaDoc("URLFactorySourceResolver.resolveURI() is not implemented yet.");
97     }
98
99     /**
100      * Releases a resolved resource
101      */

102     public void release( final org.apache.excalibur.source.Source source ) {
103         throw new RuntimeException JavaDoc("URLFactorySourceResolver.release() is not implemented yet.");
104     }
105
106     /**
107      * Generates SAX events from the given source
108      * <b>NOTE</b> : if the implementation can produce lexical events, care should be taken
109      * that <code>handler</code> can actually
110      * directly implement the LexicalHandler interface!
111      * @param source the data
112      * @throws ProcessingException if no suitable converter is found
113      */

114     public void toSAX( org.apache.excalibur.source.Source source,
115                 ContentHandler JavaDoc handler )
116     throws SAXException JavaDoc, IOException JavaDoc, ProcessingException {
117         throw new RuntimeException JavaDoc("ProcessingException.toSAX() is not implemented yet.");
118     }
119
120     /**
121      * Generates SAX events from the given source
122      * <b>NOTE</b> : if the implementation can produce lexical events, care should be taken
123      * that <code>handler</code> can actually
124      * directly implement the LexicalHandler interface!
125      * @param source the data
126      * @throws ProcessingException if no suitable converter is found
127      */

128     public void toSAX( org.apache.excalibur.source.Source source,
129                 String JavaDoc mimeTypeHint,
130                 ContentHandler JavaDoc handler )
131     throws SAXException JavaDoc, IOException JavaDoc, ProcessingException {
132         throw new RuntimeException JavaDoc("ProcessingException.toSAX() is not implemented yet.");
133     }
134 }
135
Popular Tags