Source Code Cross Referenced for SymbolStructureElement.java in  » Testing » jacareto » jacareto » struct » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » jacareto » jacareto.struct 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jacareto Copyright (c) 2002-2005
003:         * Applied Computer Science Research Group, Darmstadt University of
004:         * Technology, Institute of Mathematics & Computer Science,
005:         * Ludwigsburg University of Education, and Computer Based
006:         * Learning Research Group, Aachen University. All rights reserved.
007:         *
008:         * Jacareto is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2 of the License, or (at your option) any later version.
012:         *
013:         * Jacareto is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         * General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public
019:         * License along with Jacareto; if not, write to the Free
020:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         *
022:         */
023:
024:        package jacareto.struct;
025:
026:        import jacareto.parse.RecordTokenizer;
027:        import jacareto.system.Environment;
028:
029:        import java.lang.reflect.Constructor;
030:        import java.lang.reflect.InvocationTargetException;
031:
032:        /**
033:         * A help structure for importing structures from xml files.
034:         *
035:         * @author <a href="mailto:amrkus.bois@web.de">Markus Bois</a>
036:         * @version 1.0
037:         */
038:        public class SymbolStructureElement extends StructureElement {
039:            /** The name of the class that this represents */
040:            private String className;
041:
042:            /**
043:             * Creates a new help structure element.
044:             *
045:             * @param env the environment
046:             * @param children the child structure elements
047:             */
048:            public SymbolStructureElement(Environment env,
049:                    StructureElement[] children) {
050:                this (env, children, "");
051:            }
052:
053:            /**
054:             * Creates a new help structure element.
055:             *
056:             * @param env the environment
057:             * @param children the child structure elements
058:             * @param className the name of the represented class
059:             */
060:            public SymbolStructureElement(Environment env,
061:                    StructureElement[] children, String className) {
062:                super (env, children);
063:                this .className = className;
064:            }
065:
066:            /**
067:             * Create the correct structure element of the base of itself. It creates the new class for the
068:             * stored class name and the added children. The children will replaced if they are a {@link
069:             * jacareto.record.PositionRecordable} with the correct recordable;
070:             *
071:             * @param classLoader the array of the recordables
072:             *
073:             * @return the corret structure element
074:             */
075:            public StructureElement createRealElement(ClassLoader classLoader) {
076:                StructureElement result = null;
077:
078:                try {
079:                    if (classLoader == null) {
080:                        classLoader = ClassLoader.getSystemClassLoader();
081:                    }
082:
083:                    Class structureClass = Class.forName(className, true,
084:                            classLoader);
085:                    Class[] parameterTypes = new Class[2];
086:                    parameterTypes[0] = Class.forName(
087:                            "jacareto.system.Environment", true, classLoader);
088:                    parameterTypes[1] = Class.forName(
089:                            "[Ljacareto.struct.StructureElement;", true,
090:                            classLoader);
091:
092:                    Object[] parameters = new Object[2];
093:                    parameters[0] = env;
094:                    parameters[1] = getChildren();
095:
096:                    try {
097:                        Class concreteStructureClass = Class.forName(className,
098:                                true, classLoader);
099:                        Constructor structureConstructor = concreteStructureClass
100:                                .getConstructor(parameterTypes);
101:
102:                        if (structureClass
103:                                .isAssignableFrom(concreteStructureClass)) {
104:                            try {
105:                                logger
106:                                        .debug(language
107:                                                .getString("Structures.SymbolStructureElement.Msg.Construction")
108:                                                + " " + className);
109:                                result = (StructureElement) structureConstructor
110:                                        .newInstance(parameters);
111:                            } catch (InstantiationException inst) {
112:                                logger
113:                                        .error(
114:                                                language
115:                                                        .getString("Structures.SymbolStructureElement.Error.Construction"),
116:                                                inst);
117:                                inst.printStackTrace();
118:                            } catch (IllegalAccessException ill) {
119:                                logger
120:                                        .error(
121:                                                language
122:                                                        .getString("Structures.SymbolStructureElement.Error.Construction"),
123:                                                ill);
124:                                ill.printStackTrace();
125:                            } catch (IllegalArgumentException ila) {
126:                                logger
127:                                        .error(
128:                                                language
129:                                                        .getString("Structures.SymbolStructureElement.Error.Construction"),
130:                                                ila);
131:                                ila.printStackTrace();
132:                            } catch (InvocationTargetException inv) {
133:                                logger
134:                                        .error(
135:                                                language
136:                                                        .getString("Structures.SymbolStructureElement.Error.Construction"),
137:                                                inv);
138:                                inv.printStackTrace();
139:                            }
140:                        } else {
141:                            logger
142:                                    .warn(language
143:                                            .getString("Structures.SymbolStructureElement.Msg.NotSubclass")
144:                                            + ": " + className);
145:                        }
146:                    } catch (ClassNotFoundException c) {
147:                        logger
148:                                .error(
149:                                        language
150:                                                .getString("Structures.SymbolStructureElement.Error.MissingClass")
151:                                                + ": " + className, c);
152:                    } catch (NoSuchMethodException n) {
153:                        logger
154:                                .error(
155:                                        "Class: "
156:                                                + className
157:                                                + " - Parameters: "
158:                                                + parameterTypes
159:                                                + language
160:                                                        .getString("Structures.SymbolStructureElement.Error.MissingConstructor"),
161:                                        n);
162:                    }
163:                } catch (ClassNotFoundException c) {
164:                    logger
165:                            .error(
166:                                    language
167:                                            .getString("Structures.SymbolStructureElement.Error.MissingClass"),
168:                                    c);
169:                }
170:
171:                return result;
172:            }
173:
174:            /**
175:             * Parses a record which is tokenized by the given record tokenizer.
176:             *
177:             * @param env DOCUMENT ME!
178:             * @param recordTokenizer the record tokenizer
179:             *
180:             * @return a structure element, or <code>null</code> if this class cannot parse the record at
181:             *         the current position
182:             */
183:            public static StructureElement parse(Environment env,
184:                    RecordTokenizer recordTokenizer) {
185:                return null;
186:            }
187:
188:            /**
189:             * Returns the name of the help structure
190:             *
191:             * @return the name
192:             */
193:            public String getElementName() {
194:                return getLanguage().getString(
195:                        "Structures.SymbolStructureElement.Name");
196:            }
197:
198:            /**
199:             * Returns a description of the help structure.
200:             *
201:             * @return the description
202:             */
203:            public String getElementDescription() {
204:                return getLanguage().getString(
205:                        "Structures.SymbolStructureElement.Description");
206:            }
207:
208:            /**
209:             * Returns a String which describes the content of the sturcture shortly.
210:             *
211:             * @return a string with a short description of the object
212:             */
213:            public String toShortString() {
214:                return getElementName() + " for " + className;
215:            }
216:
217:            /**
218:             * Clones the element.
219:             *
220:             * @return DOCUMENT ME!
221:             */
222:            public Object clone() {
223:                StructureElement[] clonedChildren = getClonedChildren();
224:
225:                return new SymbolStructureElement(env, clonedChildren,
226:                        className);
227:            }
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.