KickJava   Java API By Example, From Geeks To Geeks.

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


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.fo.FONode;
23 import org.apache.fop.fo.FObj;
24 import org.apache.fop.fo.extensions.ExtensionAttachment;
25 import org.apache.fop.util.ContentHandlerFactory;
26 import org.apache.fop.util.ContentHandlerFactory.ObjectBuiltListener;
27 import org.apache.xmlgraphics.xmp.Metadata;
28
29 /**
30  * Abstract base class for the XMP and RDF root nodes.
31  */

32 public abstract class AbstractMetadataElement extends FONode implements ObjectBuiltListener {
33
34     private XMPMetadata attachment;
35     
36     /**
37      * Main constructor.
38      * @param parent the parent formatting object
39      */

40     public AbstractMetadataElement(FONode parent) {
41         super(parent);
42     }
43     
44     /**
45      * @see org.apache.fop.fo.FONode#getContentHandlerFactory()
46      */

47     public ContentHandlerFactory getContentHandlerFactory() {
48         return new XMPContentHandlerFactory();
49     }
50     
51     /** @see org.apache.fop.fo.FONode#getExtensionAttachment() */
52     public ExtensionAttachment getExtensionAttachment() {
53         if (parent instanceof FObj) {
54             if (attachment == null) {
55                 attachment = new XMPMetadata();
56             }
57             return attachment;
58         } else {
59             return super.getExtensionAttachment();
60         }
61     }
62
63     /** @see org.apache.fop.fo.XMLObj#notifyObjectBuilt(java.lang.Object) */
64     public void notifyObjectBuilt(Object JavaDoc obj) {
65         attachment.setMetadata((Metadata)obj);
66     }
67
68     
69 }
70
Popular Tags