001 /*
002 * Copyright 2007 - 2008 JEuclid, http://jeuclid.sf.net
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 /* $Id: JEuclidElementMapping.java,v 1e2cc460d998 2008/09/23 09:47:56 maxberger $ */
018
019 /*
020 * Please note: This file was originally taken from the Apache FOP project,
021 * available at http://xmlgraphics.apache.org/fop/ It is therefore
022 * partially copyright (c) 1999-2007 The Apache Software Foundation.
023 *
024 * Parts of the contents are heavily inspired by work done for Barcode4J by
025 * Jeremias Maerki, available at http://barcode4j.sf.net/
026 */
027
028 package net.sourceforge.jeuclid.fop;
029
030 import java.util.HashMap;
031
032 import net.sourceforge.jeuclid.elements.AbstractJEuclidElement;
033
034 import org.apache.fop.fo.ElementMapping;
035 import org.apache.fop.fo.FONode;
036 import org.w3c.dom.DOMImplementation;
037
038 /**
039 * This class provides the element mapping for FOP.
040 *
041 * @version $Revision: 1e2cc460d998 $
042 */
043 public class JEuclidElementMapping extends ElementMapping {
044
045 /** Main constructor. */
046 public JEuclidElementMapping() {
047 this.namespaceURI = AbstractJEuclidElement.URI;
048 }
049
050 /** {@inheritDoc} */
051 @Override
052 public DOMImplementation getDOMImplementation() {
053 return ElementMapping.getDefaultDOMImplementation();
054 }
055
056 /** {@inheritDoc} */
057 @SuppressWarnings("unchecked")
058 @Override
059 protected void initialize() {
060 if (this.foObjs == null) {
061 this.foObjs = new HashMap();
062 this.foObjs.put("math", new ME());
063 this.foObjs.put(ElementMapping.DEFAULT, new MathMLMaker());
064
065 }
066 }
067
068 static final class MathMLMaker extends ElementMapping.Maker {
069
070 private MathMLMaker() {
071 }
072
073 @Override
074 public FONode make(final FONode parent) {
075 return new JEuclidObj(parent);
076 }
077 }
078
079 static final class ME extends ElementMapping.Maker {
080
081 private ME() {
082 }
083
084 @Override
085 public FONode make(final FONode parent) {
086 return new JEuclidElement(parent);
087 }
088 }
089
090 }