blob: 68bca15b8c22b4455a4fc022e242a70bcc761daf [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2008 IBM Corporation and Others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tatsuya ISHIHARA - initial API and implementation
*******************************************************************************/
package org.eclipse.actf.model.dom.odf.dr3d.impl;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.actf.model.dom.odf.base.ODFDocument;
import org.eclipse.actf.model.dom.odf.base.impl.AbstractODFNodeFactory;
import org.eclipse.actf.model.dom.odf.dr3d.Dr3dConstants;
import org.w3c.dom.Element;
public class Dr3dNodeFactory extends AbstractODFNodeFactory {
private static final Map<String, Class> tagMap = new HashMap<String, Class>();
static {
tagMap.put(Dr3dConstants.ELEMENT_LIGHT, LightElementImpl.class);
tagMap.put(Dr3dConstants.ELEMENT_SCENE, SceneElementImpl.class);
}
public static Element createElement(ODFDocument odfDoc, String tagName,
Element element) {
Class cs = (Class) tagMap.get(tagName);
if (null == cs) {
return null;
}
try {
return (Element) findElementConstractor(cs).newInstance(
new Object[] { odfDoc, element });
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return null;
}
}