source: trunk/src/ws/fugue88/jpath/DefaultCreator.java

Last change on this file was 6, checked in by dsowen, 21 years ago

Split out the access stuff into accesslib.
New Creator interface off-loads object creation to user.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 860 bytes
Line 
1/*
2 * Created on Sep 20, 2005
3 *
4 * $Log$
5 * Revision 1.1  2005/09/21 22:00:45  dsowen
6 * Split out the access stuff into accesslib.
7 * New Creator interface off-loads object creation to user.
8 *
9 */
10package ws.fugue88.jpath;
11
12import java.lang.reflect.Constructor;
13import java.lang.reflect.InvocationTargetException;
14
15/**
16 * @author dsowen
17 */
18public class DefaultCreator implements GraphCreator {
19
20        public Object create(final Class type, final Object root,
21                        final PathPart part) throws IllegalAccessException,
22                        InstantiationException, InvocationTargetException
23        {
24                try {
25                        final Constructor ctor = type.getDeclaredConstructor(null);
26                        ctor.setAccessible(true);
27                        return ctor.newInstance(null);
28                } catch(NoSuchMethodException e) {
29                        throw new InstantiationException("Class " + type.getName()
30                                        + " must have a no-argument constructor.");
31                }
32        }
33}
Note: See TracBrowser for help on using the repository browser.