KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > render > afp > extensions > AFPElementMapping


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: AFPElementMapping.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.render.afp.extensions;
21
22 import java.util.HashMap JavaDoc;
23
24 import org.apache.fop.fo.ElementMapping;
25 import org.apache.fop.fo.FONode;
26
27
28 /**
29  * AFPElementMapping object provides the ability to extract information
30  * from the formatted object that reside in the afp namespace. This is used
31  * for custom AFP extensions not supported by the FO schema. Examples include
32  * adding overlays or indexing a document using the tag logical element
33  * structured field.
34  * <p/>
35  */

36 public class AFPElementMapping extends ElementMapping {
37
38     public static final String JavaDoc PAGE = "page";
39
40     public static final String JavaDoc PAGE_GROUP = "page-group";
41
42     public static final String JavaDoc TAG_LOGICAL_ELEMENT = "tag-logical-element";
43
44     public static final String JavaDoc INCLUDE_PAGE_OVERLAY = "include-page-overlay";
45
46     public static final String JavaDoc INCLUDE_PAGE_SEGMENT = "include-page-segment";
47
48     /**
49      * The namespace used for AFP extensions
50      */

51     public static final String JavaDoc NAMESPACE = "http://xmlgraphics.apache.org/fop/extensions/afp";
52
53     /**
54      * The usual namespace prefix used for AFP extensions
55      */

56     public static final String JavaDoc NAMESPACE_PREFIX = "afp";
57
58     /** Main constructor */
59     public AFPElementMapping() {
60         this.namespaceURI = NAMESPACE;
61     }
62
63     /**
64      * Private static synchronized method to set up the element and atribute
65      * HashMaps, this defines what elements and attributes are extracted.
66      */

67     protected void initialize() {
68
69         if (foObjs == null) {
70             foObjs = new HashMap JavaDoc();
71             foObjs.put(PAGE, new AFPPageSetupMaker());
72             // foObjs.put(PAGE_GROUP, new AFPMaker());
73
foObjs.put(
74                 TAG_LOGICAL_ELEMENT,
75                 new AFPTagLogicalElementMaker());
76             foObjs.put(
77                 INCLUDE_PAGE_SEGMENT,
78                 new AFPIncludePageSegmentMaker());
79             foObjs.put(
80                 INCLUDE_PAGE_OVERLAY,
81                 new AFPIncludePageOverlayMaker());
82         }
83
84     }
85
86     static class AFPPageSetupMaker extends ElementMapping.Maker {
87         public FONode make(FONode parent) {
88             return new AFPPageSetupElement(parent);
89         }
90     }
91
92     static class AFPIncludePageOverlayMaker extends ElementMapping.Maker {
93         public FONode make(FONode parent) {
94             return new AFPElement(parent, INCLUDE_PAGE_OVERLAY);
95         }
96     }
97
98     static class AFPIncludePageSegmentMaker extends ElementMapping.Maker {
99         public FONode make(FONode parent) {
100             return new AFPElement(parent, INCLUDE_PAGE_SEGMENT);
101         }
102     }
103
104     static class AFPTagLogicalElementMaker extends ElementMapping.Maker {
105         public FONode make(FONode parent) {
106             return new AFPElement(parent, TAG_LOGICAL_ELEMENT);
107         }
108     }
109
110 }
111
Popular Tags