KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > language > markup > LogicsheetFilter


1 /*
2  * Copyright 1999-2005 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.components.language.markup;
17
18 import org.xml.sax.SAXException JavaDoc;
19 import org.xml.sax.XMLReader JavaDoc;
20 import org.xml.sax.helpers.XMLFilterImpl JavaDoc;
21
22 import java.util.Map JavaDoc;
23
24 /**
25  * This filter listen for source SAX events, and registers all declared
26  * namespaces into a <code>Map</code> object.
27  *
28  * @see org.xml.sax.XMLFilter
29  * @see org.xml.sax.ContentHandler
30  * @version $Id: LogicsheetFilter.java 306625 2005-10-06 13:07:58Z vgritsenko $
31  */

32 public class LogicsheetFilter extends XMLFilterImpl JavaDoc {
33     private Map JavaDoc namespaces;
34
35     /**
36      * The filter needs an initialized <code>Map</code> object where it
37      * can store the found namespace declarations.
38      * @param originalNamepaceURIs a initialized <code>Map</code> instance.
39      */

40     public void setNamespaceMap(Map JavaDoc originalNamepaceURIs) {
41         this.namespaces = originalNamepaceURIs;
42     }
43
44     public void setParent(XMLReader JavaDoc reader) {
45         super.setParent(reader);
46         reader.setContentHandler(this);
47     }
48
49     public void startPrefixMapping(String JavaDoc prefix, String JavaDoc uri)
50     throws SAXException JavaDoc {
51         if (namespaces != null) {
52             namespaces.put(uri, prefix);
53         }
54         super.startPrefixMapping(prefix, uri);
55     }
56 }
57
Popular Tags