001: /*
002: * Created on May 13, 2004
003: *
004: * To change the template for this generated file go to
005: * Window>Preferences>Java>Code Generation>Code and Comments
006: */
007: package org.xdev.base.core.compiler.type;
008:
009: import java.lang.reflect.Constructor;
010: import java.util.HashMap;
011: import java.util.List;
012:
013: import org.apache.log4j.Level;
014: import org.jdom.Element;
015: import org.jdom.Text;
016: import org.xdev.base.core.IPage;
017: import org.xdev.base.core.compiler.AXCompiler;
018: import org.xdev.base.log.LoggerWriter;
019: import org.xdev.base.util.Tools;
020: import org.xdev.base.xssl.XSSLAction;
021: import org.xdev.base.xssl.XSSLComponent;
022:
023: /**
024: * @author AYegorov
025: *
026: * Company: xDev Group.org
027: *
028: * URL: <a>http://activexml.dev.java.net</a>
029: *
030: * File name: Type.java
031: *
032: * <p>Is bound: true | false</p>
033: *
034: * <table>
035: * <tr>
036: * <td>Description:</td>
037: * <td>
038: * <!--Your description here-->
039: * </td>
040: * </tr>
041: * </table>
042: * <table>
043: * <tr>
044: * <td colspan="3">
045: * Properties
046: * </td>
047: * </tr>
048: * <tr>
049: * <td>Name</td>
050: * <td>Value</td>
051: * <td>Description</td>
052: * </tr>
053: * <tr>
054: * <td></td>
055: * <td></td>
056: * <td></td>
057: * </tr>
058: * </table>
059: */
060: public class Type extends AbstractType {
061:
062: private AXCompiler compiler = null;
063:
064: /**
065: * @param type
066: * @param typeName
067: */
068: public Type(Class type, String typeName) {
069: super (type, typeName);
070: // XXX Auto-generated constructor stub
071: }
072:
073: /**
074: * @param type
075: * @param typeName
076: * @param validators
077: */
078: public Type(Class type, String typeName, Class[] validators) {
079: super (type, typeName, validators);
080: // XXX Auto-generated constructor stub
081: }
082:
083: public Type(AbstractType type, Class[] validators) {
084: super (type, validators);
085: // TODO Auto-generated constructor stub
086: }
087:
088: /* (non-Javadoc)
089: * @see org.xdev.base.core.AbstractType#loadComponent()
090: */
091: public XSSLComponent loadComponent(String id, HashMap properties,
092: Object elm, IPage page, XSSLAction template,
093: XSSLComponent parent, String path) throws Exception {
094:
095: Element element = (Element) elm;
096:
097: if (this .compiler == null) {
098: this .compiler = AXCompiler.getInstance();
099: }
100:
101: LoggerWriter.log("Associating XML Element with type: "
102: + this .getType(), Level.DEBUG_INT, Type.class);
103:
104: Class cls = this .getType();
105:
106: LoggerWriter.log("Associated type class found: " + cls,
107: Level.DEBUG_INT, Type.class);
108:
109: Constructor constr = cls.getConstructor(new Class[] {
110: String.class, HashMap.class });
111:
112: LoggerWriter.log("Associated type class constructor found: "
113: + constr, Level.DEBUG_INT, Type.class);
114:
115: XSSLComponent component = (XSSLComponent) constr
116: .newInstance(new Object[] { id, properties });
117:
118: String compiledName = "";
119:
120: if (template == null) {
121: template = (XSSLAction) component;
122:
123: compiledName = Tools.replaceString(path.substring(1), "/",
124: ".")
125: + ".";
126: }
127:
128: compiledName += (parent != null && !parent.equals(component) ? parent
129: .getCompiledName()
130: + "."
131: : "")
132: + this.getTypeName();
133:
134: component.setCompiledName(compiledName);
135:
136: component.setTagName(this.getTypeName());
137:
138: return component;
139: }
140:
141: }
|