Java Doc for ClassFactory.java in  » Test-Coverage » Quilt » org » quilt » cl » 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 » Test Coverage » Quilt » org.quilt.cl 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.quilt.cl.ClassFactory

ClassFactory
public class ClassFactory (Code)
Class synthesizer. Currently intended for debugging Quilt development and limited to instantiating classes with a no-argument constructor and a single method whose bytecode depends upon the base name of the class. By default classes whose name begins with test.data.Test will be synthesized. This can be set to a different string by a QuiltClassLoader method.
See Also:    QuiltClassLoader.
author:
   David Dixon-Peugh
author:
   Jim Dixon -- major
author:
   changes to the original code.




Method Summary
public static  ClassFactorygetInstance()
     Use this method to get to the ClassFactory singleton.
public  InputStreamgetResourceAsStream(String resName)
     Get the bytecode for a synthesized class.
public  ClassGenmakeClass(String className, String fileName)
     Generate a class with a single no-arg constructor and a runTest method.
public  MethodGenmakeConstructor(ClassGen clazz)
     Creates the constructor for the synthesized class.
public  MethodGenmakeMethod(ClassGen clazz)
     Creates a method with bytecode determined by the name of the class. If we have class test.data.TestBogus, then we strip off the "test.data.Test" prefix and call mgBogus() to get an instruction list. In the current version, if there is an underscore in the class name, then the underscore and everything following it will be ignored.
public  MethodGenmgDefault(ClassGen clazz)
     Generates bytecode for a method which simply returns 2.
public  MethodGenmgIfThen(ClassGen clazz)
     Generates instructions for a method consisting of a single if-then clause.
public  MethodGenmgNPENoCatch(ClassGen clazz)
     Creates bytecode which will throw a NullPointerException without a catch block.
public  MethodGenmgNPEWithCatch(ClassGen clazz)
     Returns bytecode which will throw a NullPointerException, but it will catch the NPE.
public  MethodGenmgSelect(ClassGen clazz)
    
public  MethodGenmgWhile(ClassGen clazz)
     Generates code for a while loop.



Method Detail
getInstance
public static ClassFactory getInstance()(Code)
Use this method to get to the ClassFactory singleton.

XXX Is there any benefit to this being a singleton?




getResourceAsStream
public InputStream getResourceAsStream(String resName)(Code)
Get the bytecode for a synthesized class. The name passed looks like "test/data/TestMyStuff.class". This is converted to "test.data.TestMyStuff". The "test.data.Test" prefix will later be stripped off and the base name, "MyStuff" in this case, used to determine which version of the runTest method to generate.
Parameters:
  resName - Name of the class to be synthesized.



makeClass
public ClassGen makeClass(String className, String fileName)(Code)
Generate a class with a single no-arg constructor and a runTest method. By convention, if there is an underscore (_) in the class name, the underscore and everything after it are ignored in choosing method code. For example, if the class name is testWhile_1, then the method code comes from mgWhile

Methods available at this time are:

  • mgDefault
  • mgIfThen
  • mgNPENoCatch
  • mgNPEWithCatch
  • mgSelect
  • mgWhile

Parameters:
  className - Name of the class to be constructed.
Parameters:
  fileName - Associated file name (??? XXX)



makeConstructor
public MethodGen makeConstructor(ClassGen clazz)(Code)
Creates the constructor for the synthesized class. It is a no-arg constructor that calls super.
Parameters:
  clazz - Template for the class being synthesized. Method template for the constructor.



makeMethod
public MethodGen makeMethod(ClassGen clazz)(Code)
Creates a method with bytecode determined by the name of the class. If we have class test.data.TestBogus, then we strip off the "test.data.Test" prefix and call mgBogus() to get an instruction list. In the current version, if there is an underscore in the class name, then the underscore and everything following it will be ignored. So test.data.TestBogus_27 would result in a call to mgBogus(), not mgBogus_27(). If the method (mgBogus in this case) doesn't exist, then we call mgDefault() to generate the bytecode.
Parameters:
  clazz - Template for the class being produced. Template method with bytecode.



mgDefault
public MethodGen mgDefault(ClassGen clazz)(Code)
Generates bytecode for a method which simply returns 2. This is the method used if the class name is test.data.TestDefault. This method is also used if ClassFactory doesn't recognize the name; for example, if the class name is test.data.TestBogus, because there is no mgBogus method, this default method is used to generate the bytecode.
 public int runTest( int x ) {
 return 2;
 }
 



mgIfThen
public MethodGen mgIfThen(ClassGen clazz)(Code)
Generates instructions for a method consisting of a single if-then clause.
 public int runTest( int x ) {
 if (x > 0) {
 return 3;
 } else {
 return 5;
 }
 }
 



mgNPENoCatch
public MethodGen mgNPENoCatch(ClassGen clazz)(Code)
Creates bytecode which will throw a NullPointerException without a catch block.
 public int runTest(int x) {
 null.runTest( 0 );
 return 0;
 }
 



mgNPEWithCatch
public MethodGen mgNPEWithCatch(ClassGen clazz)(Code)
Returns bytecode which will throw a NullPointerException, but it will catch the NPE.
 try {
 null.runTest( 0 );
 return -1;
 } catch (NullPointerException npe) {
 return 3;
 }
 



mgSelect
public MethodGen mgSelect(ClassGen clazz)(Code)
Generates bytecode for a switch statement:
 int runTest (int x) {
 switch (x) {
 case 1:  return 1;
 case 2:  return 3;
 case 3:  return 5;
 default: return 2;
 }
 }
 



mgWhile
public MethodGen mgWhile(ClassGen clazz)(Code)
Generates code for a while loop. The while loop returns 0 if the parameter x is greater than or equal to zero, but x otherwise.
 int runTest(int x) {
 while (x > 0) {
 x --;
 }
 return x;
 }
 

The actual bytecode produced is:

LabelInstruction Stack
ILOAD _ -> I
if: DUP I -> II
IFLE (ret) II -> I
loop:ICONST_1 I -> II
ISUB II -> I
GOTO (if) I -> I
ret: IRETURN I -> _



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.