KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > fo > extensions > xmp > XMPContentHandlerFactory


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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 /* $Id$ */
19
20 package org.apache.fop.fo.extensions.xmp;
21
22 import org.apache.fop.util.ContentHandlerFactory;
23 import org.apache.xmlgraphics.xmp.XMPConstants;
24 import org.apache.xmlgraphics.xmp.XMPHandler;
25 import org.xml.sax.ContentHandler JavaDoc;
26 import org.xml.sax.SAXException JavaDoc;
27
28 /**
29  * ContentHandlerFactory for the XMP root element.
30  */

31 public class XMPContentHandlerFactory implements ContentHandlerFactory {
32
33     private static final String JavaDoc[] NAMESPACES = new String JavaDoc[]
34                                          {XMPConstants.XMP_NAMESPACE, XMPConstants.RDF_NAMESPACE};
35
36     /** @see org.apache.fop.util.ContentHandlerFactory#getSupportedNamespaces() */
37     public String JavaDoc[] getSupportedNamespaces() {
38         return NAMESPACES;
39     }
40
41     /** @see org.apache.fop.util.ContentHandlerFactory#createContentHandler() */
42     public ContentHandler JavaDoc createContentHandler() throws SAXException JavaDoc {
43         return new FOPXMPHandler();
44     }
45
46     /**
47      * Local subclass of XMPHandler that implements ObjectSource for FOP integration.
48      */

49     private class FOPXMPHandler extends XMPHandler implements ObjectSource {
50
51         private ObjectBuiltListener obListener;
52         
53         public Object JavaDoc getObject() {
54             return getMetadata();
55         }
56
57         /** @see org.apache.fop.util.ContentHandlerFactory.ObjectSource */
58         public void setObjectBuiltListener(ObjectBuiltListener listener) {
59             this.obListener = listener;
60         }
61         
62         /** @see org.xml.sax.helpers.DefaultHandler#endDocument() */
63         public void endDocument() throws SAXException JavaDoc {
64             if (obListener != null) {
65                 obListener.notifyObjectBuilt(getObject());
66             }
67         }
68         
69     }
70     
71 }
72
Popular Tags