KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > xml > SaxXercesParser


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: dream@objectweb.org
20  *
21  * Initial developer(s): Matthieu Leclercq
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.xml;
26
27 import org.apache.xerces.parsers.SAXParser;
28 import org.objectweb.fractal.api.NoSuchInterfaceException;
29 import org.objectweb.fractal.api.control.BindingController;
30 import org.objectweb.fractal.api.control.IllegalBindingException;
31 import org.objectweb.fractal.api.control.IllegalLifeCycleException;
32 import org.xml.sax.ContentHandler JavaDoc;
33
34 /**
35  * Extention of the {@link org.apache.xerces.parsers.SAXParser}to give it a
36  * Fractal component behaviour. This Fractal component has a server interface of
37  * type {@link org.xml.sax.XMLReader}and a client interface of type
38  * {@link org.xml.sax.ContentHandler}.
39  */

40 public class SaxXercesParser extends SAXParser implements BindingController
41 {
42
43   /**
44    * The name of the {@link ContentHandler}client interface.
45    */

46   public static final String JavaDoc CONTENT_HANDLER_ITF_NAME = "content-handler";
47
48   /**
49    * @see org.objectweb.fractal.api.control.BindingController#listFc()
50    */

51   public String JavaDoc[] listFc()
52   {
53     return new String JavaDoc[]{CONTENT_HANDLER_ITF_NAME};
54   }
55
56   /**
57    * @see org.objectweb.fractal.api.control.BindingController#lookupFc(java.lang.String)
58    */

59   public Object JavaDoc lookupFc(String JavaDoc clientItfName) throws NoSuchInterfaceException
60   {
61     if (clientItfName.equals(CONTENT_HANDLER_ITF_NAME))
62     {
63       return getContentHandler();
64     }
65     return null;
66   }
67
68   /**
69    * @see org.objectweb.fractal.api.control.BindingController#bindFc(java.lang.String,
70    * java.lang.Object)
71    */

72   public void bindFc(String JavaDoc clientItfName, Object JavaDoc serverItf)
73       throws NoSuchInterfaceException, IllegalBindingException,
74       IllegalLifeCycleException
75   {
76     if (clientItfName.equals(CONTENT_HANDLER_ITF_NAME))
77     {
78       setContentHandler((ContentHandler JavaDoc) serverItf);
79     }
80   }
81
82   /**
83    * @see org.objectweb.fractal.api.control.BindingController#unbindFc(java.lang.String)
84    */

85   public void unbindFc(String JavaDoc clientItfName) throws NoSuchInterfaceException,
86       IllegalBindingException, IllegalLifeCycleException
87   {
88     if (clientItfName.equals(CONTENT_HANDLER_ITF_NAME))
89     {
90       setContentHandler(null);
91     }
92   }
93
94 }
Popular Tags