1 /*
2 * Copyright 2007 - 2008 JEuclid, http://jeuclid.sf.net
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
17 /* $Id: JEuclidElementMapping.java,v 1e2cc460d998 2008/09/23 09:47:56 maxberger $ */
18
19 /*
20 * Please note: This file was originally taken from the Apache FOP project,
21 * available at http://xmlgraphics.apache.org/fop/ It is therefore
22 * partially copyright (c) 1999-2007 The Apache Software Foundation.
23 *
24 * Parts of the contents are heavily inspired by work done for Barcode4J by
25 * Jeremias Maerki, available at http://barcode4j.sf.net/
26 */
27
28 package net.sourceforge.jeuclid.fop;
29
30 import java.util.HashMap;
31
32 import net.sourceforge.jeuclid.elements.AbstractJEuclidElement;
33
34 import org.apache.fop.fo.ElementMapping;
35 import org.apache.fop.fo.FONode;
36 import org.w3c.dom.DOMImplementation;
37
38 /**
39 * This class provides the element mapping for FOP.
40 *
41 * @version $Revision: 1e2cc460d998 $
42 */
43 public class JEuclidElementMapping extends ElementMapping {
44
45 /** Main constructor. */
46 public JEuclidElementMapping() {
47 this.namespaceURI = AbstractJEuclidElement.URI;
48 }
49
50 /** {@inheritDoc} */
51 @Override
52 public DOMImplementation getDOMImplementation() {
53 return ElementMapping.getDefaultDOMImplementation();
54 }
55
56 /** {@inheritDoc} */
57 @SuppressWarnings("unchecked")
58 @Override
59 protected void initialize() {
60 if (this.foObjs == null) {
61 this.foObjs = new HashMap();
62 this.foObjs.put("math", new ME());
63 this.foObjs.put(ElementMapping.DEFAULT, new MathMLMaker());
64
65 }
66 }
67
68 static final class MathMLMaker extends ElementMapping.Maker {
69
70 private MathMLMaker() {
71 }
72
73 @Override
74 public FONode make(final FONode parent) {
75 return new JEuclidObj(parent);
76 }
77 }
78
79 static final class ME extends ElementMapping.Maker {
80
81 private ME() {
82 }
83
84 @Override
85 public FONode make(final FONode parent) {
86 return new JEuclidElement(parent);
87 }
88 }
89
90 }