Class AScene
- All Implemented Interfaces:
Cloneable
AScene
(annotated scene) represents the annotations on a set of Java classes and
packages along with the definitions of some or all of the annotation types used.
Each client of the annotation library may wish to use its own representation for certain kinds of annotations instead of a simple name-value map; thus, a layer of abstraction in the storage of annotations was introduced.
AScene
s and many AElement
s can contain other AElement
s. When these
objects are created, their collections of subelements are empty. In order to associate an
annotation with a particular Java element in an AScene
, one must first ensure that an
appropriate AElement
exists in the AScene
. To this end, the maps of subelements
have a vivify
method. Calling vivify
to access a particular subelement will
return the subelement if it already exists; otherwise it will create and then return the
subelement. (Compare to vivification in Perl.) For example, the following code will obtain an
AMethod
representing Foo.bar
in the AScene
s
, creating it if it
did not already exist:
AMethod<A> m = s.classes.getVivify("Foo").methods.getVivify("bar");
Then one can add an annotation to the method:
m.annotationsHere.add(new Annotation( new AnnotationDef(taintedDef, RetentionPolicy.RUNTIME, true), new Annotation(taintedDef, Collections.emptyMap()) ));
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal VivifyingMap
<String, AClass> This scene's annotated classes; map key is class name.Contains for each annotation type a set of imports to be added to the source if the annotation is inserted with the "abbreviate" option on.
Key: fully-qualified name of an annotation.final VivifyingMap
<String, AElement> This scene's annotated packages; map key is package name. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkClone
(AScene s0, AScene s1) Checks that the arguments are clones of one another.static <K,
V extends AElement>
voidcheckCloneMap
(VivifyingMap<K, V> m0, VivifyingMap<K, V> m1) Throw exception if m0 == m1 or !m0.equals(m1).clone()
boolean
Returns true if thisAScene
equalso
; the commentary and the cautionary remarks onAElement.equals(Object)
also apply toequals(Object)
.boolean
Returns true if thisAScene
equalso
; a slightly faster variant ofequals(Object)
for when the argument is statically known to be another nonnullAScene
.Fetch the classes in this scene, represented as AClass objects.int
hashCode()
boolean
isEmpty()
Returns true if thisAScene
is empty.static void
Temporary main for easy testing on JAIFs.void
prune()
Removes empty subelements of thisAScene
depth-first.toString()
unparse()
Returns a string representation.
-
Field Details
-
packages
This scene's annotated packages; map key is package name. -
imports
Contains for each annotation type a set of imports to be added to the source if the annotation is inserted with the "abbreviate" option on.
Key: fully-qualified name of an annotation. e.g. for@com.foo.Bar(x)
, the fully-qualified name iscom.foo.Bar
Value: names of packages this annotation needs -
classes
This scene's annotated classes; map key is class name.
-
-
Constructor Details
-
Method Details
-
clone
-
equals
Returns true if thisAScene
equalso
; the commentary and the cautionary remarks onAElement.equals(Object)
also apply toequals(Object)
. -
equals
Returns true if thisAScene
equalso
; a slightly faster variant ofequals(Object)
for when the argument is statically known to be another nonnullAScene
. -
hashCode
public int hashCode() -
getClasses
Fetch the classes in this scene, represented as AClass objects.- Returns:
- an immutable map from binary names to AClass objects
-
isEmpty
public boolean isEmpty()Returns true if thisAScene
is empty. -
prune
public void prune()Removes empty subelements of thisAScene
depth-first. -
unparse
Returns a string representation. -
toString
-
checkClone
Checks that the arguments are clones of one another.Throws an exception if the arguments 1) are the same reference; 2) are not equal() in both directions; or 3) contain corresponding elements that meet either of the preceding two conditions.
- Parameters:
s0
- the first AScene to compares1
- the second Ascene to compare
-
checkCloneMap
public static <K,V extends AElement> void checkCloneMap(VivifyingMap<K, V> m0, VivifyingMap<K, V> m1) Throw exception if m0 == m1 or !m0.equals(m1). (SeecheckClone(AScene, AScene)
for explanation.)- Type Parameters:
K
- the type of map keysV
- the type of map values- Parameters:
m0
- the first map to comparem1
- the second map to compare
-
main
Temporary main for easy testing on JAIFs.- Parameters:
args
- command-line arguments
-