Java Doc for CtBehavior.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.CtMember
      javassist.CtBehavior

All known Subclasses:   javassist.CtConstructor,  javassist.CtMethod,
CtBehavior
abstract public class CtBehavior extends CtMember (Code)
CtBehavior represents a method, a constructor, or a static constructor (class initializer). It is the abstract super class of CtMethod and CtConstructor.


Field Summary
protected  MethodInfomethodInfo
    

Constructor Summary
protected  CtBehavior(CtClass clazz, MethodInfo minfo)
    

Method Summary
public  voidaddCatch(String src, CtClass exceptionType)
     Adds a catch clause that handles an exception thrown in the body.
public  voidaddCatch(String src, CtClass exceptionType, String exceptionName)
     Adds a catch clause that handles an exception thrown in the body.
public  voidaddLocalVariable(String name, CtClass type)
     Declares a new local variable.
 voidcopy(CtBehavior src, boolean isCons, ClassMap map)
    
protected  voidextendToString(StringBuffer buffer)
    
public  Object[]getAnnotations()
     Returns the annotations associated with this method or constructor.
public  byte[]getAttribute(String name)
     Obtains an attribute with the given name. If that attribute is not found in the class file, this method returns null.

Note that an attribute is a data block specified by the class file format.

public  Object[]getAvailableAnnotations()
     Returns the annotations associated with this method or constructor.
public  Object[][]getAvailableParameterAnnotations()
     Returns the parameter annotations associated with this method or constructor. If any annotations are not on the classpath, they are not included in the returned array. an array of annotation-type objects.
public  CtClass[]getExceptionTypes()
     Obtains exceptions that this method/constructor may throw.
public  MethodInfogetMethodInfo()
     Returns the MethodInfo representing this method/constructor in the class file.
public  MethodInfogetMethodInfo2()
     Returns the MethodInfo representing the method/constructor in the class file (read only). Normal applications do not need calling this method.
public  intgetModifiers()
     Obtains the modifiers of the method/constructor.
public  Object[][]getParameterAnnotations()
     Returns the parameter annotations associated with this method or constructor. an array of annotation-type objects.
 Object[][]getParameterAnnotations(boolean ignoreNotFound)
    
public  CtClass[]getParameterTypes()
     Obtains parameter types of this method/constructor.
 CtClassgetReturnType0()
     Obtains the type of the returned value.
public  StringgetSignature()
     Returns the method signature (the parameter types and the return type).
 intgetStartPosOfBody(CodeAttribute ca)
    
public  voidinsertAfter(String src)
     Inserts bytecode at the end of the body.
public  voidinsertAfter(String src, boolean asFinally)
     Inserts bytecode at the end of the body.
public  intinsertAt(int lineNum, String src)
     Inserts bytecode at the specified line in the body. It is equivalent to:
insertAt(lineNum, true, src)
See this method as well.
Parameters:
  lineNum - the line number.
public  intinsertAt(int lineNum, boolean modify, String src)
     Inserts bytecode at the specified line in the body.

If there is not a statement at the specified line, the bytecode might be inserted at the line including the first statement after that line specified. For example, if there is only a closing brace at that line, the bytecode would be inserted at another line below. To know exactly where the bytecode will be inserted, call with modify set to false.

public  voidinsertBefore(String src)
     Inserts bytecode at the beginning of the body.

If this object represents a constructor, the bytecode is inserted before a constructor in the super class or this class is called. Therefore, the inserted bytecode is subject to constraints described in Section 4.8.2 of The Java Virtual Machine Specification (2nd ed). For example, it cannot access instance fields or methods although it may assign a value to an instance field directly declared in this class.

public  voidinstrument(CodeConverter converter)
     Modifies the method/constructor body.
public  voidinstrument(ExprEditor editor)
     Modifies the method/constructor body.
abstract public  booleanisEmpty()
     Returns true if the body is empty.
public  voidsetAttribute(String name, byte[] data)
     Adds an attribute.
public  voidsetBody(String src)
     Sets a method/constructor body.
public  voidsetBody(String src, String delegateObj, String delegateMethod)
     Sets a method/constructor body.
static  voidsetBody0(CtClass srcClass, MethodInfo srcInfo, CtClass destClass, MethodInfo destInfo, ClassMap map)
    
public  voidsetExceptionTypes(CtClass[] types)
     Sets exceptions that this method/constructor may throw.
public  voidsetModifiers(int mod)
     Sets the encoded modifiers of the method/constructor.
public  voiduseCflow(String name)
     Declares to use $cflow for this method/constructor. If $cflow is used, the class files modified with Javassist requires a support class javassist.runtime.Cflow at runtime (other Javassist classes are not required at runtime).

Every $cflow variable is given a unique name. For example, if the given name is "Point.paint", then the variable is indicated by $cflow(Point.paint).
Parameters:
  name - $cflow name.


Field Detail
methodInfo
protected MethodInfo methodInfo(Code)




Constructor Detail
CtBehavior
protected CtBehavior(CtClass clazz, MethodInfo minfo)(Code)




Method Detail
addCatch
public void addCatch(String src, CtClass exceptionType) throws CannotCompileException(Code)
Adds a catch clause that handles an exception thrown in the body. The catch clause must end with a return or throw statement.
Parameters:
  src - the source code representing the catch clause.It must be a single statement or block.
Parameters:
  exceptionType - the type of the exception handled by thecatch clause.



addCatch
public void addCatch(String src, CtClass exceptionType, String exceptionName) throws CannotCompileException(Code)
Adds a catch clause that handles an exception thrown in the body. The catch clause must end with a return or throw statement.
Parameters:
  src - the source code representing the catch clause.It must be a single statement or block.
Parameters:
  exceptionType - the type of the exception handled by thecatch clause.
Parameters:
  exceptionName - the name of the variable containing thecaught exception, for example,$e.



addLocalVariable
public void addLocalVariable(String name, CtClass type) throws CannotCompileException(Code)
Declares a new local variable. The scope of this variable is the whole method body. The initial value of that variable is not set. The declared variable can be accessed in the code snippet inserted by insertBefore(), insertAfter(), etc.

If the second parameter asFinally to insertAfter() is true, the declared local variable is not visible from the code inserted by insertAfter().
Parameters:
  name - the name of the variable
Parameters:
  type - the type of the variable
See Also:   CtBehavior.insertBefore(String)
See Also:   CtBehavior.insertAfter(String)




copy
void copy(CtBehavior src, boolean isCons, ClassMap map) throws CannotCompileException(Code)

Parameters:
  isCons - true if this is a constructor.



extendToString
protected void extendToString(StringBuffer buffer)(Code)



getAnnotations
public Object[] getAnnotations() throws ClassNotFoundException(Code)
Returns the annotations associated with this method or constructor. an array of annotation-type objects.
See Also:   CtBehavior.getAvailableAnnotations()
since:
   3.1



getAttribute
public byte[] getAttribute(String name)(Code)
Obtains an attribute with the given name. If that attribute is not found in the class file, this method returns null.

Note that an attribute is a data block specified by the class file format. It is not an annotation. See javassist.bytecode.AttributeInfo .
Parameters:
  name - attribute name




getAvailableAnnotations
public Object[] getAvailableAnnotations()(Code)
Returns the annotations associated with this method or constructor. If any annotations are not on the classpath, they are not included in the returned array. an array of annotation-type objects.
See Also:   CtBehavior.getAnnotations()
since:
   3.3



getAvailableParameterAnnotations
public Object[][] getAvailableParameterAnnotations()(Code)
Returns the parameter annotations associated with this method or constructor. If any annotations are not on the classpath, they are not included in the returned array. an array of annotation-type objects. The length of the returned array isequal to the number of the formal parameters. If each parameter has noannotation, the elements of the returned array are empty arrays.
See Also:   CtBehavior.getParameterAnnotations()
See Also:   CtBehavior.getAvailableAnnotations()
since:
   3.3



getExceptionTypes
public CtClass[] getExceptionTypes() throws NotFoundException(Code)
Obtains exceptions that this method/constructor may throw. a zero-length array if there is no throws clause.



getMethodInfo
public MethodInfo getMethodInfo()(Code)
Returns the MethodInfo representing this method/constructor in the class file.



getMethodInfo2
public MethodInfo getMethodInfo2()(Code)
Returns the MethodInfo representing the method/constructor in the class file (read only). Normal applications do not need calling this method. Use getMethodInfo().

The MethodInfo object obtained by this method is read only. Changes to this object might not be reflected on a class file generated by toBytecode(), toClass(), etc in CtClass.

This method is available even if the CtClass containing this method is frozen. However, if the class is frozen, the MethodInfo might be also pruned.
See Also:   CtBehavior.getMethodInfo()
See Also:   CtClass.isFrozen
See Also:   CtClass.prune




getModifiers
public int getModifiers()(Code)
Obtains the modifiers of the method/constructor. modifiers encoded withjavassist.Modifier.
See Also:   Modifier



getParameterAnnotations
public Object[][] getParameterAnnotations() throws ClassNotFoundException(Code)
Returns the parameter annotations associated with this method or constructor. an array of annotation-type objects. The length of the returned array isequal to the number of the formal parameters. If each parameter has noannotation, the elements of the returned array are empty arrays.
See Also:   CtBehavior.getAvailableParameterAnnotations()
See Also:   CtBehavior.getAnnotations()
since:
   3.1



getParameterAnnotations
Object[][] getParameterAnnotations(boolean ignoreNotFound) throws ClassNotFoundException(Code)



getParameterTypes
public CtClass[] getParameterTypes() throws NotFoundException(Code)
Obtains parameter types of this method/constructor.



getReturnType0
CtClass getReturnType0() throws NotFoundException(Code)
Obtains the type of the returned value.



getSignature
public String getSignature()(Code)
Returns the method signature (the parameter types and the return type). The method signature is represented by a character string called method descriptor, which is defined in the JVM specification. If two methods/constructors have the same parameter types and the return type, getSignature() returns the same string (the return type of constructors is void).
See Also:   javassist.bytecode.Descriptor



getStartPosOfBody
int getStartPosOfBody(CodeAttribute ca) throws CannotCompileException(Code)



insertAfter
public void insertAfter(String src) throws CannotCompileException(Code)
Inserts bytecode at the end of the body. The bytecode is inserted just before every return insturction. It is not executed when an exception is thrown.
Parameters:
  src - the source code representing the inserted bytecode.It must be a single statement or block.



insertAfter
public void insertAfter(String src, boolean asFinally) throws CannotCompileException(Code)
Inserts bytecode at the end of the body. The bytecode is inserted just before every return insturction.
Parameters:
  src - the source code representing the inserted bytecode.It must be a single statement or block.
Parameters:
  asFinally - true if the inserted bytecode is executednot only when the control normally returnsbut also when an exception is thrown.If this parameter is true, the inserted code cannotaccess local variables.



insertAt
public int insertAt(int lineNum, String src) throws CannotCompileException(Code)
Inserts bytecode at the specified line in the body. It is equivalent to:
insertAt(lineNum, true, src)
See this method as well.
Parameters:
  lineNum - the line number. The bytecode is inserted at thebeginning of the code at the line specified by thisline number.
Parameters:
  src - the source code representing the inserted bytecode.It must be a single statement or block. the line number at which the bytecode has been inserted.
See Also:   CtBehavior.insertAt(intbooleanString)



insertAt
public int insertAt(int lineNum, boolean modify, String src) throws CannotCompileException(Code)
Inserts bytecode at the specified line in the body.

If there is not a statement at the specified line, the bytecode might be inserted at the line including the first statement after that line specified. For example, if there is only a closing brace at that line, the bytecode would be inserted at another line below. To know exactly where the bytecode will be inserted, call with modify set to false.
Parameters:
  lineNum - the line number. The bytecode is inserted at thebeginning of the code at the line specified by thisline number.
Parameters:
  modify - if false, this method does not insert the bytecode.It instead only returns the line number at whichthe bytecode would be inserted.
Parameters:
  src - the source code representing the inserted bytecode.It must be a single statement or block.If modify is false, the value of src can be null. the line number at which the bytecode has been inserted.




insertBefore
public void insertBefore(String src) throws CannotCompileException(Code)
Inserts bytecode at the beginning of the body.

If this object represents a constructor, the bytecode is inserted before a constructor in the super class or this class is called. Therefore, the inserted bytecode is subject to constraints described in Section 4.8.2 of The Java Virtual Machine Specification (2nd ed). For example, it cannot access instance fields or methods although it may assign a value to an instance field directly declared in this class. Accessing static fields and methods is allowed. Use insertBeforeBody() in CtConstructor.
Parameters:
  src - the source code representing the inserted bytecode.It must be a single statement or block.
See Also:   CtConstructor.insertBeforeBody(String)




instrument
public void instrument(CodeConverter converter) throws CannotCompileException(Code)
Modifies the method/constructor body.
Parameters:
  converter - specifies how to modify.



instrument
public void instrument(ExprEditor editor) throws CannotCompileException(Code)
Modifies the method/constructor body.
Parameters:
  editor - specifies how to modify.



isEmpty
abstract public boolean isEmpty()(Code)
Returns true if the body is empty.



setAttribute
public void setAttribute(String name, byte[] data)(Code)
Adds an attribute. The attribute is saved in the class file.

Note that an attribute is a data block specified by the class file format. It is not an annotation. See javassist.bytecode.AttributeInfo .
Parameters:
  name - attribute name
Parameters:
  data - attribute value




setBody
public void setBody(String src) throws CannotCompileException(Code)
Sets a method/constructor body.
Parameters:
  src - the source code representing the body.It must be a single statement or block.If it is null, the substitutedbody does nothing except returning zero or null.



setBody
public void setBody(String src, String delegateObj, String delegateMethod) throws CannotCompileException(Code)
Sets a method/constructor body.
Parameters:
  src - the source code representing the body.It must be a single statement or block.If it is null, the substitutedbody does nothing except returning zero or null.
Parameters:
  delegateObj - the source text specifying the objectthat is called on by $proceed().
Parameters:
  delegateMethod - the name of the methodthat is called by $proceed().



setBody0
static void setBody0(CtClass srcClass, MethodInfo srcInfo, CtClass destClass, MethodInfo destInfo, ClassMap map) throws CannotCompileException(Code)



setExceptionTypes
public void setExceptionTypes(CtClass[] types) throws NotFoundException(Code)
Sets exceptions that this method/constructor may throw.



setModifiers
public void setModifiers(int mod)(Code)
Sets the encoded modifiers of the method/constructor.

Changing the modifiers may cause a problem. For example, if a non-static method is changed to static, the method will be rejected by the bytecode verifier.
See Also:   Modifier




useCflow
public void useCflow(String name) throws CannotCompileException(Code)
Declares to use $cflow for this method/constructor. If $cflow is used, the class files modified with Javassist requires a support class javassist.runtime.Cflow at runtime (other Javassist classes are not required at runtime).

Every $cflow variable is given a unique name. For example, if the given name is "Point.paint", then the variable is indicated by $cflow(Point.paint).
Parameters:
  name - $cflow name. It can includealphabets, numbers, _,$, and . (dot).
See Also:   javassist.runtime.Cflow




Fields inherited from javassist.CtMember
protected CtClass declaringClass(Code)(Java Doc)
protected CtMember next(Code)(Java Doc)

Methods inherited from javassist.CtMember
static CtMember append(CtMember list, CtMember previousTail, CtMember tail)(Code)(Java Doc)
static CtMember append(CtMember list, CtMember tail)(Code)(Java Doc)
static int count(CtMember f)(Code)(Java Doc)
abstract protected void extendToString(StringBuffer buffer)(Code)(Java Doc)
abstract public Object[] getAnnotations() throws ClassNotFoundException(Code)(Java Doc)
abstract public byte[] getAttribute(String name)(Code)(Java Doc)
abstract public Object[] getAvailableAnnotations() throws ClassNotFoundException(Code)(Java Doc)
public CtClass getDeclaringClass()(Code)(Java Doc)
abstract public int getModifiers()(Code)(Java Doc)
abstract public String getName()(Code)(Java Doc)
abstract public String getSignature()(Code)(Java Doc)
static CtMember remove(CtMember list, CtMember m)(Code)(Java Doc)
abstract public void setAttribute(String name, byte[] data)(Code)(Java Doc)
abstract public void setModifiers(int mod)(Code)(Java Doc)
public String toString()(Code)(Java Doc)
public boolean visibleFrom(CtClass clazz)(Code)(Java Doc)

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.