org.codehaus.aspectwerkz.attribdef.definition.attribute.bcel
Class BcelAttributeEnhancer

java.lang.Object
  extended byorg.codehaus.aspectwerkz.attribdef.definition.attribute.bcel.BcelAttributeEnhancer
All Implemented Interfaces:
AttributeEnhancer

public class BcelAttributeEnhancer
extends java.lang.Object
implements AttributeEnhancer

Enhances classes with attributes.

Implementation based on BCEL. Based on code from the Attrib4j project by Mark Pollack and Ted Neward (http://attrib4j.sourceforge.net/).

Author:
Jonas Bonér

Constructor Summary
BcelAttributeEnhancer()
           
 
Method Summary
 java.lang.String[] getNearestInterfacesInHierarchy(java.lang.String innerClassName)
          Return the first interfaces implemented by a level in the class hierarchy (bottom top)
 boolean initialize(java.lang.String className, java.lang.String classPath)
          Initializes the attribute enhancer.
 void insertClassAttribute(java.lang.Object attribute)
          Inserts an attribute on class level.
 void insertFieldAttribute(com.thoughtworks.qdox.model.JavaField field, java.lang.Object attribute)
          Inserts an attribute on field level.
 void insertMethodAttribute(com.thoughtworks.qdox.model.JavaMethod method, java.lang.Object attribute)
          Inserts an attribute on method level.
static byte[] serialize(java.lang.Object attribute)
          Serializes the attribute to byte array.
 void write(java.lang.String destDir)
          Writes the enhanced class to file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BcelAttributeEnhancer

public BcelAttributeEnhancer()
Method Detail

initialize

public boolean initialize(java.lang.String className,
                          java.lang.String classPath)
Initializes the attribute enhancer. Must always be called before use.

Specified by:
initialize in interface AttributeEnhancer
Parameters:
className - the class name
classPath - the class path
Returns:
true if the class was succefully loaded, false otherwise

insertClassAttribute

public void insertClassAttribute(java.lang.Object attribute)
Inserts an attribute on class level.

Specified by:
insertClassAttribute in interface AttributeEnhancer
Parameters:
attribute - the attribute

insertFieldAttribute

public void insertFieldAttribute(com.thoughtworks.qdox.model.JavaField field,
                                 java.lang.Object attribute)
Inserts an attribute on field level.

Specified by:
insertFieldAttribute in interface AttributeEnhancer
Parameters:
field - the QDox java field
attribute - the attribute

insertMethodAttribute

public void insertMethodAttribute(com.thoughtworks.qdox.model.JavaMethod method,
                                  java.lang.Object attribute)
Inserts an attribute on method level.

Specified by:
insertMethodAttribute in interface AttributeEnhancer
Parameters:
method - the QDox java method
attribute - the attribute

write

public void write(java.lang.String destDir)
Writes the enhanced class to file.

Specified by:
write in interface AttributeEnhancer
Parameters:
destDir - the destination directory

serialize

public static byte[] serialize(java.lang.Object attribute)
Serializes the attribute to byte array.

Parameters:
attribute - the attribute
Returns:
the attribute as a byte array

getNearestInterfacesInHierarchy

public java.lang.String[] getNearestInterfacesInHierarchy(java.lang.String innerClassName)
Return the first interfaces implemented by a level in the class hierarchy (bottom top)

Specified by:
getNearestInterfacesInHierarchy in interface AttributeEnhancer
Returns:
nearest superclass (including itself) ' implemented interfaces


Copyright (c) 2002-2004 The AspectWerkz Team. All Rights Reserved.