6 * Copyright (C) 2006 The Jmol Development Team
8 * Contact: jmol-developers@lists.sf.net
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28 public class Interface {
30 public static Object getInterface(String name) {
32 Class<?> x = Class.forName(name);
33 return (x == null ? null : x.newInstance());
34 } catch (Exception e) {
35 System.out.println("Interface.getInterface Error creating instance for " + name + ": \n" + e);
40 public static Object getInstanceWithParams(String name, Class[] classes, Object... params) {
42 Class<?> cl = Class.forName(name);
43 return cl.getConstructor(classes).newInstance(params);
44 } catch (Exception e) {
45 System.out.println("Interface.getInterfaceWithParams Error creating instance for " + name + ": \n" + e);