001 /*
002 This project provide access to non public fields
003 and methods as help for writing tests.
004 Copyright (C) 2007 Christof Lehmann
005
006 This program is free software; you can redistribute it and/or
007 modify it under the terms of the GNU General Public License
008 as published by the Free Software Foundation; either version 2
009 of the License, or (at your option) any later version.
010
011 This program is distributed in the hope that it will be useful,
012 but WITHOUT ANY WARRANTY; without even the implied warranty of
013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 GNU General Public License for more details.
015
016 You should have received a copy of the GNU General Public License
017 along with this program; if not, write to the Free Software
018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
019 */
020 package net.sf.testextensions;
021
022 /**
023 * The class <code>AccessFactory</code> generates
024 * AccessObjects from several start points.
025 * @author forge-cl
026 */
027
028 public final class AccessFactory {
029 /**
030 * This constructor prevents intiatiations of this class.
031 *
032 */
033 private AccessFactory() {
034 }
035
036 /**
037 * The method <code>newInstance</code> create a new instance of a class,
038 * using a constructor without arguments.
039 *
040 * @param aClassName
041 * the name of the class, which should be instantiated
042 * @return a instance of AccessObject for future access.
043 * @throws TestExtensionException
044 * when errors occures during intantiation
045 */
046 public static AccessObject newInstance(final String aClassName)
047 throws TestExtensionException {
048 return newInstance(aClassName, new Class[] {});
049 }
050
051 /**
052 * The method <code>newInstance</code> create a new instance of a class,
053 * using a constructor which suites to the arguments.
054 * @param aClassName the name of the class, which should be instantiated
055 * @param aParameters the parameter for the constructor
056 * @return a instance of AccessObject for future access
057 * @throws TestExtensionException when errors occures during instantiation
058 */
059 public static AccessObject newInstance(final String aClassName,
060 final Object[] aParameters) throws TestExtensionException {
061 return new AccessObjectImpl(aClassName, aParameters);
062 }
063 }