KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > ipanema > person > edit > AbstractPersonDataFieldEditorFactory


1 /*
2  * Created on Nov 26, 2004
3  * by alex
4  *
5  */

6 package com.nightlabs.ipanema.person.edit;
7
8 import com.nightlabs.ipanema.person.AbstractPersonDataField;
9
10 /**
11  * Abstract base class for all {@link PersonDataFieldEditorFactory}s
12  *
13  * @author Alexander Bieber <alex[AT]nightlabs[DOT]de>
14  */

15 public abstract class AbstractPersonDataFieldEditorFactory implements PersonDataFieldEditorFactory {
16
17     /**
18      * Default constructor does nothing.
19      */

20     public AbstractPersonDataFieldEditorFactory() { }
21     
22     /**
23      * @see com.nightlabs.ipanema.person.edit.PersonDataFieldEditor#getTargetPersonDataType()
24      */

25     public abstract Class JavaDoc getTargetPersonDataFieldType();
26
27     /**
28      * @see com.nightlabs.ipanema.person.edit.PersonDataFieldEditor#getEditorType()
29      */

30     public abstract String JavaDoc getEditorType();
31     
32     public abstract Class JavaDoc getPersonDataFieldEditorClass();
33
34     /**
35      * Default implementation instatiates a new instance of getEditorClass.getNewInstance()
36      * invokes setData(data) and returnes the new instance.
37      *
38      */

39     public PersonDataFieldEditor createPersonDataFieldEditor(AbstractPersonDataField data, boolean setData) {
40         PersonDataFieldEditor editor;
41         try {
42             editor = (PersonDataFieldEditor)getPersonDataFieldEditorClass().newInstance();
43         } catch (Throwable JavaDoc t) {
44             IllegalStateException JavaDoc ill = new IllegalStateException JavaDoc("Error instantiating "+getPersonDataFieldEditorClass().getName());
45             ill.initCause(t);
46             throw ill;
47         }
48         if (setData)
49             editor.setData(data);
50         return editor;
51     }
52     
53 }
54
Popular Tags