Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JEuclid Core Source Code Files
JEuclid Source Code Files are provided 
the 
JEuclid GitHub Website.
You can browse JEuclid Source Code files below:
✍: FYIcenter
⏎ net/sourceforge/jeuclid/elements/JEuclidElementFactory.java
/*
 * Copyright 2007 - 2009 JEuclid, http://jeuclid.sf.net
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/* $Id$ */
package net.sourceforge.jeuclid.elements;
import net.sourceforge.jeuclid.elements.content.semantic.Annotation;
import net.sourceforge.jeuclid.elements.content.semantic.Semantics;
import net.sourceforge.jeuclid.elements.generic.ForeignElement;
import net.sourceforge.jeuclid.elements.generic.MathImpl;
import net.sourceforge.jeuclid.elements.presentation.enlivening.Maction;
import net.sourceforge.jeuclid.elements.presentation.general.*;
import net.sourceforge.jeuclid.elements.presentation.script.*;
import net.sourceforge.jeuclid.elements.presentation.table.*;
import net.sourceforge.jeuclid.elements.presentation.token.*;
import org.apache.batik.dom.AbstractDocument;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
/**
 * Creates MathElements from given element strings.
 * 
 * @version $Revision$
 */
public final class JEuclidElementFactory {
    /**
     * Logger for this class
     */
    private static final Log LOGGER = LogFactory
            .getLog(JEuclidElementFactory.class);
    private static final Map<String, Constructor<? extends JEuclidElement>> IMPL_CLASSES = new HashMap<String, Constructor<? extends JEuclidElement>>();;
    private JEuclidElementFactory() {
        // Empty on purpose
    }
    private static String removeNSPrefix(final String qualifiedName) {
        final int posSeparator = qualifiedName.indexOf(':');
        if (posSeparator >= 0) {
            return qualifiedName.substring(posSeparator + 1);
        }
        return qualifiedName;
    }
    /**
     * Retrieve the constructor for an JEuclidElement, if available.
     * 
     * @param nsUri
     *            namespace of the element
     * @param qualifiedName
     *            qualified name
     * @return A constructor to create the element, or null if no such
     *         constructor is available.
     */
    public static Constructor<? extends JEuclidElement> getJEuclidElementConstructor(
            final String nsUri, final String qualifiedName) {
        final String localName = JEuclidElementFactory
                .removeNSPrefix(qualifiedName);
        if ((nsUri == null) || (nsUri.length() == 0)
                || (AbstractJEuclidElement.URI.equals(nsUri))) {
            return JEuclidElementFactory.IMPL_CLASSES.get(localName);
        } else {
            return null;
        }
    }
    /**
     * Factory for MathML Elements.
     * 
     * @param nsUri
     *            namespace URI. May be null. May be ignored in the case of
     *            MathML.
     * @param qualifiedName
     *            name of the element with optional namespace prefix.
     * @param ownerDocument
     *            Document this element belongs to.
     * @return A new MathElement for this tag name.
     */
    public static Element elementFromName(final String nsUri,
            final String qualifiedName, final Document ownerDocument) {
        JEuclidElement element = null;
            final Constructor<? extends JEuclidElement> con = JEuclidElementFactory.
            getJEuclidElementConstructor(nsUri, qualifiedName);
            if (con != null) {
                try {
                    element = con.newInstance(qualifiedName,
                            ownerDocument);
                } catch (final InstantiationException e) {
                    element = null;
                } catch (final IllegalAccessException e) {
                    element = null;
                } catch (final InvocationTargetException e) {
                    element = null;
                }
            }
        
        if (element == null) {
            element = new ForeignElement(nsUri, qualifiedName,
                    (AbstractDocument) ownerDocument);
        }
        return element;
    }
    private static void addClass(final Class<? extends JEuclidElement> c) {
        try {
            final Field f = c.getField("ELEMENT");
            final String tag = (String) f.get(null);
            JEuclidElementFactory.IMPL_CLASSES.put(tag, c.getConstructor(
                    String.class, AbstractDocument.class));
        } catch (final NoSuchFieldException e) {
            JEuclidElementFactory.LOGGER.warn(c.toString(), e);
        } catch (final NoSuchMethodException e) {
            JEuclidElementFactory.LOGGER.warn(c.toString(), e);
        } catch (final IllegalAccessException e) {
            JEuclidElementFactory.LOGGER.warn(c.toString(), e);
        }
    }
    // CHECKSTYLE:OFF
    static {
        // CHECKSTYLE:ON
        JEuclidElementFactory.addClass(MathImpl.class);
        JEuclidElementFactory.addClass(Mfenced.class);
        JEuclidElementFactory.addClass(Mfrac.class);
        JEuclidElementFactory.addClass(Menclose.class);
        JEuclidElementFactory.addClass(Mphantom.class);
        JEuclidElementFactory.addClass(Msup.class);
        JEuclidElementFactory.addClass(Msub.class);
        JEuclidElementFactory.addClass(Mmultiscripts.class);
        JEuclidElementFactory.addClass(Mprescripts.class);
        JEuclidElementFactory.addClass(None.class);
        JEuclidElementFactory.addClass(Msubsup.class);
        JEuclidElementFactory.addClass(Munder.class);
        JEuclidElementFactory.addClass(Mover.class);
        JEuclidElementFactory.addClass(Munderover.class);
        JEuclidElementFactory.addClass(Mspace.class);
        JEuclidElementFactory.addClass(Ms.class);
        JEuclidElementFactory.addClass(Mstyle.class);
        JEuclidElementFactory.addClass(Msqrt.class);
        JEuclidElementFactory.addClass(Mroot.class);
        JEuclidElementFactory.addClass(Mtable.class);
        JEuclidElementFactory.addClass(Mtr.class);
        JEuclidElementFactory.addClass(Mlabeledtr.class);
        JEuclidElementFactory.addClass(Mtd.class);
        JEuclidElementFactory.addClass(Mo.class);
        JEuclidElementFactory.addClass(Mi.class);
        JEuclidElementFactory.addClass(Mn.class);
        JEuclidElementFactory.addClass(Mtext.class);
        JEuclidElementFactory.addClass(Mrow.class);
        JEuclidElementFactory.addClass(Maligngroup.class);
        JEuclidElementFactory.addClass(Malignmark.class);
        JEuclidElementFactory.addClass(Semantics.class);
        JEuclidElementFactory.addClass(Annotation.class);
        JEuclidElementFactory.addClass(Mpadded.class);
        JEuclidElementFactory.addClass(Merror.class);
        JEuclidElementFactory.addClass(Maction.class);
        JEuclidElementFactory.addClass(Mglyph.class);
    }
}
⏎ net/sourceforge/jeuclid/elements/JEuclidElementFactory.java
Or download all of them as a single archive file:
File name: jeuclid-core-3.1.14-fyi.zip File size: 325716 bytes Release date: 2019-02-24 Download
⇒ Using JEuclid 3.1.9 on macOS
⇐ Download and Install jeuclid-core-3.1.14.jar
2025-08-15, ≈13🔥, 0💬
Popular Posts:
How to download and install Apache XMLBeans-2.6.0.zip? If you want to try the XMLBeans Java library,...
commons-net-1.4.1.jar is the JAR file for Apache Commons Net 1.4.1, which implements the client side...
What Is ojdbc7.jar for Oracle 12c R1? ojdbc7.jar for Oracle 12c R1 is the JAR files of ojdbc.jar, JD...
The Jakarta-ORO Java classes are a set of text-processing Java classes that provide Perl5 compatible...
What is jxl.jar 2.6.12? jxl.jar 2.6.12 is the JAR file for Java Excel API 2.6.12, which is a Java li...