classfilewriter 1.0.0.Final

org.jboss.classfilewriter
Class ClassFile

java.lang.Object
  extended by org.jboss.classfilewriter.ClassFile
All Implemented Interfaces:
WritableEntry

public class ClassFile
extends Object
implements WritableEntry

Author:
Stuart Douglas

Constructor Summary
ClassFile(String name, String superclass, String... interfaces)
           
 
Method Summary
 ClassMethod addConstructor(Constructor<?> method)
          Adds a constructor with the same signiture as the given constrcutor, including exception types
 ClassField addField(Field field)
           
 ClassField addField(int accessFlags, String name, Class<?> type)
           
 ClassField addField(int accessFlags, String name, Class<?> type, String genericSignature)
           
 ClassField addField(int accessFlags, String name, String descriptor)
          Adds a field with the given name and descriptor.
 ClassField addField(int accessFlags, String name, String descriptor, String signature)
           
 void addInterface(String iface)
           
 ClassMethod addMethod(int accessFlags, String name, String returnType, String... parameters)
           
 ClassMethod addMethod(Method method)
          Adds a method with the same signiture as the given method, including exception types
 Class<?> define(ClassLoader loader)
           
 Class<?> define(ClassLoader loader, ProtectionDomain domain)
          Definines the class using the given ClassLoader and ProtectionDomain
 ConstPool getConstPool()
           
 String getDescriptor()
          returns the type descriptor for the class
 Set<ClassField> getFields()
           
 List<String> getInterfaces()
           
 Set<ClassMethod> getMethods()
           
 String getName()
          Returns the generated class name
 AnnotationsAttribute getRuntimeVisibleAnnotationsAttribute()
           
 String getSuperclass()
           
 byte[] toBytecode()
           
 void write(ByteArrayDataOutputStream stream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFile

public ClassFile(String name,
                 String superclass,
                 String... interfaces)
Method Detail

addInterface

public void addInterface(String iface)

addField

public ClassField addField(int accessFlags,
                           String name,
                           String descriptor)
Adds a field with the given name and descriptor.


addField

public ClassField addField(int accessFlags,
                           String name,
                           String descriptor,
                           String signature)

addField

public ClassField addField(int accessFlags,
                           String name,
                           Class<?> type)

addField

public ClassField addField(int accessFlags,
                           String name,
                           Class<?> type,
                           String genericSignature)

addField

public ClassField addField(Field field)

addMethod

public ClassMethod addMethod(int accessFlags,
                             String name,
                             String returnType,
                             String... parameters)

addMethod

public ClassMethod addMethod(Method method)
Adds a method with the same signiture as the given method, including exception types

The new method will have the same modifier as the original method, except that the abstract and native flags will be stripped.

TODO: annotations and signiture attribute


addConstructor

public ClassMethod addConstructor(Constructor<?> method)
Adds a constructor with the same signiture as the given constrcutor, including exception types

TODO: annotations and signiture attribute


write

public void write(ByteArrayDataOutputStream stream)
           throws IOException
Specified by:
write in interface WritableEntry
Throws:
IOException

define

public Class<?> define(ClassLoader loader)

define

public Class<?> define(ClassLoader loader,
                       ProtectionDomain domain)
Definines the class using the given ClassLoader and ProtectionDomain


toBytecode

public byte[] toBytecode()

getConstPool

public ConstPool getConstPool()

getDescriptor

public String getDescriptor()
returns the type descriptor for the class

Returns:

getRuntimeVisibleAnnotationsAttribute

public AnnotationsAttribute getRuntimeVisibleAnnotationsAttribute()

getName

public String getName()
Returns the generated class name

Returns:
The generated class name

getSuperclass

public String getSuperclass()
Returns:
The generated superclass name

getInterfaces

public List<String> getInterfaces()
Returns:
The interfaces implemented by this class

getFields

public Set<ClassField> getFields()
Returns:
This class's fields

getMethods

public Set<ClassMethod> getMethods()
Returns:
This classes methods

classfilewriter 1.0.0.Final

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.