net.sf.daileon.notsupported
Class AbstractAnnotationsReplacerBase

java.lang.Object
  extended by org.objectweb.asm.ClassAdapter
      extended by net.sf.daileon.notsupported.AbstractAnnotationsReplacerBase
All Implemented Interfaces:
org.objectweb.asm.ClassVisitor
Direct Known Subclasses:
AbstractAnnotationsReplacer

abstract class AbstractAnnotationsReplacerBase
extends org.objectweb.asm.ClassAdapter

The AbstractAnnotationsReplacerBase class is responsible for organizing the elements and their annotations, as well as their domain annotations.

Version:
1.0 01/01/2010
Author:
Roberto Perillo

Field Summary
private  Map<ElementRoot,Set<String>> domainAnnotations
          Keeps the elements and their domain annotations
private  Map<ElementRoot,org.objectweb.asm.attrs.RuntimeVisibleAnnotations> elementsMap
          Keeps the elements and their annotations
 
Fields inherited from class org.objectweb.asm.ClassAdapter
cv
 
Constructor Summary
AbstractAnnotationsReplacerBase(org.objectweb.asm.ClassVisitor visitor)
          Class constructor.
 
Method Summary
(package private)  void addDomainAnnotation(ElementRoot element, String annotation)
          Associates the name of a domain annotation to a particular element.
(package private)  void addElementAnnotations(ElementRoot element, org.objectweb.asm.attrs.RuntimeVisibleAnnotations annotations)
          Associates annotations to a particular element.
(package private)  void handleElement(ElementRoot element)
          Organizes the elements and their annotations.
protected abstract  boolean keepDomainAnnotations()
          Informs whether the domain annotations should be either kept or not in the final bytecode.
 
Methods inherited from class org.objectweb.asm.ClassAdapter
visit, visitAttribute, visitEnd, visitField, visitInnerClass, visitMethod
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

elementsMap

private Map<ElementRoot,org.objectweb.asm.attrs.RuntimeVisibleAnnotations> elementsMap
Keeps the elements and their annotations


domainAnnotations

private Map<ElementRoot,Set<String>> domainAnnotations
Keeps the elements and their domain annotations

Constructor Detail

AbstractAnnotationsReplacerBase

AbstractAnnotationsReplacerBase(org.objectweb.asm.ClassVisitor visitor)
Class constructor.

Parameters:
visitor - The ClassVisitor object, provided by the ClassTransformer.transform(String, String) method.
Method Detail

keepDomainAnnotations

protected abstract boolean keepDomainAnnotations()
Informs whether the domain annotations should be either kept or not in the final bytecode.

Returns:
A boolean value that can be:
  • true if the domain annotations should be kept in the final bytecode;
  • false if the domain annotations should not be kept in the final bytecode.

addDomainAnnotation

void addDomainAnnotation(ElementRoot element,
                         String annotation)
Associates the name of a domain annotation to a particular element.

Parameters:
element - The element which the domain annotation is associated to.
annotation - The name of the domain annotation.

addElementAnnotations

void addElementAnnotations(ElementRoot element,
                           org.objectweb.asm.attrs.RuntimeVisibleAnnotations annotations)
Associates annotations to a particular element.

Parameters:
element - The element which the annotations are associated to.
annotations - The RuntimeVisibleAnnotations object, containing the annotations to be associated with the element.

handleElement

void handleElement(ElementRoot element)
             throws DuplicateAnnotationException
Organizes the elements and their annotations. Essentially, it first verifies if the domain annotations should be kept in the code; if they should not be kept, then the domain annotations that annotate the element in the bytecode are removed from the Map that associates elements with domain annotations. After that, it verifies if two or more domain annotations evaluate to the same annotation. If so, a DuplicateAnnotationException is thrown.

Parameters:
element - The element to have its annotations organized.
Throws:
DuplicateAnnotationException - If two or more domain annotations evaluate to the same annotation.