01: /**
02: * Title: OpenUSS - Open Source University Support System
03: * Description: Layout Formatter
04: * Copyright: Copyright (c) B. Lofi Dewanto
05: * Company: University of Muenster
06: * @author B. Lofi Dewanto
07: * @version 1.0
08: */package org.openuss.presentation.layoutformatter;
09:
10: import java.lang.reflect.*;
11:
12: /**
13: * The interface for layout formatter factory.
14: *
15: * @author B. Lofi Dewanto
16: * @version 1.0
17: */
18: public class LayoutFormatterFactory {
19: /**
20: * Gets the layout formatter.
21: *
22: * @return the layout formatter implementation.
23: */
24: public static LayoutFormatter getLayoutFormatter(
25: Object stateObject, String fullClassNameLayout)
26: throws Exception {
27: // Depends on the stateObject create the layout formatter
28: Class objectClass = Class.forName(fullClassNameLayout);
29:
30: // Get the constructor
31: Class myOwner = Class.forName("java.lang.Object");
32: Class[] parameterTypes = new Class[1];
33: parameterTypes[0] = myOwner;
34:
35: Constructor objectConstructor = objectClass
36: .getConstructor(parameterTypes);
37:
38: // Create the object with the constructor
39: Object[] initArgs = new Object[1];
40: initArgs[0] = stateObject;
41:
42: LayoutFormatter layoutFormatter = (LayoutFormatter) objectConstructor
43: .newInstance(initArgs);
44:
45: return layoutFormatter;
46: }
47: }
|