Java Doc for CtNewConstructor.java in  » Byte-Code » Javassist » javassist » 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 » Byte Code » Javassist » javassist 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javassist.CtNewConstructor

CtNewConstructor
public class CtNewConstructor (Code)
A collection of static methods for creating a CtConstructor. An instance of this class does not make any sense.

A class initializer (static constructor) cannot be created by the methods in this class. Call makeClassInitializer() in CtClass and append code snippet to the body of the class initializer obtained by makeClassInitializer().
See Also:   CtClass.addConstructor(CtConstructor)
See Also:   CtClass.makeClassInitializer



Field Summary
final public static  intPASS_ARRAY
     Specifies that parameters are converted into an array of Object and passed to a super-class' constructor.
final public static  intPASS_NONE
     Specifies that no parameters are passed to a super-class' constructor.
final public static  intPASS_PARAMS
     Specifies that parameters are passed as is to a super-class' constructor.


Method Summary
public static  CtConstructorcopy(CtConstructor c, CtClass declaring, ClassMap map)
     Creats a copy of a constructor.
public static  CtConstructordefaultConstructor(CtClass declaring)
     Creates a default (public) constructor.

The created constructor takes no parameter.

public static  CtConstructormake(String src, CtClass declaring)
     Compiles the given source code and creates a constructor. The source code must include not only the constructor body but the whole declaration.
Parameters:
  src - the source text.
public static  CtConstructormake(CtClass[] parameters, CtClass[] exceptions, String body, CtClass declaring)
     Creates a public constructor.
public static  CtConstructormake(CtClass[] parameters, CtClass[] exceptions, CtClass declaring)
     Creates a public constructor that only calls a constructor in the super class.
public static  CtConstructormake(CtClass[] parameters, CtClass[] exceptions, int howto, CtMethod body, ConstParameter cparam, CtClass declaring)
     Creates a public constructor.

If howto is PASS_PARAMS, the created constructor calls the super's constructor with the same signature.

public static  CtConstructorskeleton(CtClass[] parameters, CtClass[] exceptions, CtClass declaring)
     Creates a public constructor that only calls a constructor in the super class.

Field Detail
PASS_ARRAY
final public static int PASS_ARRAY(Code)
Specifies that parameters are converted into an array of Object and passed to a super-class' constructor.



PASS_NONE
final public static int PASS_NONE(Code)
Specifies that no parameters are passed to a super-class' constructor. That is, the default constructor is invoked.



PASS_PARAMS
final public static int PASS_PARAMS(Code)
Specifies that parameters are passed as is to a super-class' constructor. The signature of that constructor must be the same as that of the created constructor.





Method Detail
copy
public static CtConstructor copy(CtConstructor c, CtClass declaring, ClassMap map) throws CannotCompileException(Code)
Creats a copy of a constructor.
Parameters:
  c - the copied constructor.
Parameters:
  declaring - the class to which the created method is added.
Parameters:
  map - the hashtable associating original class nameswith substituted names.It can be null.
See Also:   CtConstructor.CtConstructor(CtConstructorCtClassClassMap)



defaultConstructor
public static CtConstructor defaultConstructor(CtClass declaring) throws CannotCompileException(Code)
Creates a default (public) constructor.

The created constructor takes no parameter. It calls super().




make
public static CtConstructor make(String src, CtClass declaring) throws CannotCompileException(Code)
Compiles the given source code and creates a constructor. The source code must include not only the constructor body but the whole declaration.
Parameters:
  src - the source text.
Parameters:
  declaring - the class to which the created constructor is added.



make
public static CtConstructor make(CtClass[] parameters, CtClass[] exceptions, String body, CtClass declaring) throws CannotCompileException(Code)
Creates a public constructor.
Parameters:
  parameters - a list of the parameter types.
Parameters:
  exceptions - a list of the exception types.
Parameters:
  body - the source text of the constructor body.It must be a block surrounded by {}.If it is null, the substitutedconstructor body does nothing except callingsuper().
Parameters:
  declaring - the class to which the created method is added.



make
public static CtConstructor make(CtClass[] parameters, CtClass[] exceptions, CtClass declaring) throws CannotCompileException(Code)
Creates a public constructor that only calls a constructor in the super class. The created constructor receives parameters specified by parameters and calls the super's constructor with those parameters.
Parameters:
  parameters - parameter types
Parameters:
  exceptions - exception types
Parameters:
  declaring - the class to which the created constructoris added.



make
public static CtConstructor make(CtClass[] parameters, CtClass[] exceptions, int howto, CtMethod body, ConstParameter cparam, CtClass declaring) throws CannotCompileException(Code)
Creates a public constructor.

If howto is PASS_PARAMS, the created constructor calls the super's constructor with the same signature. The superclass must contain a constructor taking the same set of parameters as the created one.

If howto is PASS_NONE, the created constructor calls the super's default constructor. The superclass must contain a constructor taking no parameters.

If howto is PASS_ARRAY, the created constructor calls the super's constructor with the given parameters in the form of an array of Object. The signature of the super's constructor must be:

    constructor(Object[] params, <type> cvalue)

Here, cvalue is the constant value specified by cparam.

If cparam is null, the signature must be:

    constructor(Object[] params)

If body is not null, a copy of that method is embedded in the body of the created constructor. The embedded method is executed after the super's constructor is called and the values of fields are initialized. Note that body must not be a constructor but a method.

Since the embedded method is wrapped in parameter-conversion code as in CtNewMethod.wrapped(), the constructor parameters are passed in the form of an array of Object. The method specified by body must have the signature shown below:

    Object method(Object[] params, <type> cvalue)

If cparam is null, the signature must be:

    Object method(Object[] params)

Although the type of the returned value is Object, the value must be always null.

Example:

    ClassPool pool = ... ;
     CtClass xclass = pool.makeClass("X");
     CtMethod method = pool.getMethod("Sample", "m");
     xclass.setSuperclass(pool.get("Y"));
     CtClass[] argTypes = { CtClass.intType };
     ConstParameter cparam = ConstParameter.string("test");
     CtConstructor c = CtNewConstructor.make(argTypes, null,
     PASS_PARAMS, method, cparam, xclass);
     xclass.addConstructor(c);

where the class Sample is as follows:

    public class Sample {
     public Object m(Object[] args, String msg) {
     System.out.println(msg);
     return null;
     }
     }

This program produces the following class:

    public class X extends Y {
     public X(int p0) {
     super(p0);
     String msg = "test";
     Object[] args = new Object[] { p0 };
     // begin of copied body
     System.out.println(msg);
     Object result = null;
     // end
     }
     }

Parameters:
  parameters - a list of the parameter types
Parameters:
  exceptions - a list of the exceptions
Parameters:
  howto - how to pass parameters to the super-class'constructor (PASS_NONE,PASS_ARRAY,or PASS_PARAMS)
Parameters:
  body - appended body (may be null).It must be not a constructor but a method.
Parameters:
  cparam - constant parameter (may be null.)
Parameters:
  declaring - the class to which the created constructoris added.
See Also:   CtNewMethod.wrapped(CtClassStringCtClass[]CtClass[]CtMethodCtMethod.ConstParameterCtClass)



skeleton
public static CtConstructor skeleton(CtClass[] parameters, CtClass[] exceptions, CtClass declaring) throws CannotCompileException(Code)
Creates a public constructor that only calls a constructor in the super class. The created constructor receives parameters specified by parameters but calls the super's constructor without those parameters (that is, it calls the default constructor).

The parameters passed to the created constructor should be used for field initialization. CtField.Initializer objects implicitly insert initialization code in constructor bodies.
Parameters:
  parameters - parameter types
Parameters:
  exceptions - exception types
Parameters:
  declaring - the class to which the created constructoris added.
See Also:   CtField.Initializer.byParameter(int)




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.