01: /*
02: * Created on Jun 2, 2004
03: *
04: * TODO To change the template for this generated file go to
05: * Window - Preferences - Java - Code Style - Code Templates
06: */
07: package org.xdev.base.core.compiler.instruction;
08:
09: import java.lang.reflect.Constructor;
10: import java.util.HashMap;
11:
12: import org.xdev.base.log.LoggerWriter;
13: import org.xdev.base.core.BASE;
14:
15: import org.apache.log4j.Level;
16:
17: import org.xdev.base.core.compiler.type.AbstractType;
18:
19: /**
20: * @author AYegorov
21: *
22: * TODO To change the template for this generated type comment go to
23: * Window - Preferences - Java - Code Style - Code Templates
24: */
25: public abstract class AbstractDynamicInstruction extends
26: AbstractInstruction {
27:
28: /**
29: * @param id
30: * @param properties
31: */
32: public AbstractDynamicInstruction(String id, HashMap properties) {
33: super (id, properties);
34: }
35:
36: protected AbstractType matchType(Object elm, Class[] validators)
37: throws Exception {
38: Constructor c = this .matchClass(elm)
39: .getConstructor(
40: new Class[] { Class.class, String.class,
41: Class[].class });
42:
43: Class cls = null;
44:
45: try {
46: cls = this .getType(elm);
47: } catch (Throwable ex) {
48: LoggerWriter.log(BASE.getValueFromObject(ex),
49: Level.DEBUG_INT, this .getClass());
50: }
51:
52: return (AbstractType) c.newInstance(new Object[] { cls,
53: this .getComponentName(elm), validators });
54: }
55:
56: protected abstract Class matchClass(Object elm) throws Exception;
57:
58: protected abstract Class getType(Object elm);
59: }
|