Top Description Inners Fields Constructors Methods
org.aspectj.weaver.patterns

public Class DeclareAnnotation

extends Declare
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .Iterator, .List, .Map, org.aspectj.bridge.MessageUtil, org.aspectj.weaver.AjAttribute.WeaverVersionInfo, .AnnotationAJ, .CompressingDataOutputStream, .ISourceContext, .ResolvedMember, .ResolvedType, .UnresolvedType, .VersionedDataInputStream, .WeaverMessages, .World

Represents a declare annotation statement, one of atField, atMethod, atConstructor or atType.
Author
Andy Clement

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
DeclareAnnotation.Kind

Captures type of declare annotation (method/type/field/constructor)

Field Summary

Modifier and TypeField and Description
private static final String
private AnnotationAJ
private int
private List<String>
private int
private List<String>
private ResolvedType
public static final DeclareAnnotation.Kind
public static final DeclareAnnotation.Kind
public static final DeclareAnnotation.Kind
public static final DeclareAnnotation.Kind
public static final DeclareAnnotation.Kind
private ResolvedType
pack-priv boolean
private DeclareAnnotation.Kind
private ISignaturePattern
private TypePattern
Inherited from org.aspectj.weaver.patterns.Declare:
ANNOTATIONDOMINATESERROR_OR_WARNINGPARENTSPARENTSMIXINSOFTTYPE_ERROR_OR_WARNING

Constructor Summary

AccessConstructor and Description
public
DeclareAnnotation(DeclareAnnotation.Kind kind, TypePattern typePattern)

Constructor for declare atType.

public
DeclareAnnotation(DeclareAnnotation.Kind kind, ISignaturePattern sigPattern)

Constructor for declare atMethod/atField/atConstructor.

Method Summary

Modifier and TypeMethod and Description
public Object
public void
public boolean
couldEverMatch(ResolvedType type)

Return true if this declare annotation could ever match something in the specified type - only really able to make intelligent decision if a type was specified in the sig/type pattern signature.

private void
ensureAnnotationDiscovered()

The annotation specified in the declare @type is stored against a simple method of the form "ajc$declare_<nn>", this method finds that method and retrieves the annotation.

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public AnnotationAJ

Returns:

declared annotation; can be null for annotations with SOURCE retention, which of course are not present in the byte code
getAnnotation
()

public String
public int
public int
public String
getAnnotationString()

Returns the string, useful before the real annotation has been resolved

public ResolvedType

Returns:

the type of the annotation; can be null for annotations with SOURCE retention, which of course are not present in the byte code
getAnnotationType
()

public UnresolvedType
public DeclareAnnotation.Kind
public String
getNameSuffix()

Implements abstract org.aspectj.weaver.patterns.Declare.getNameSuffix.

Provide a name suffix so that we can tell the different declare annotations forms apart in the AjProblemReporter
public String
public ISignaturePattern
public TypePattern
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
private void
init()

public boolean
isAdviceLike()

Implements abstract org.aspectj.weaver.patterns.Declare.isAdviceLike.

Indicates if this declare should be treated like advice.
public boolean

Returns:

true if the annotation specified is allowed on a field
isAnnotationAllowedOnField
()

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
matches(ResolvedMember resolvedmember, World world)

For declare atConstructor, atMethod, atField

public boolean
matches(ResolvedType type)

For declare atType.

public Declare
parameterizeWith(Map<String, UnresolvedType> typeVariableBindingMap, World w)

Implements abstract org.aspectj.weaver.patterns.Declare.parameterizeWith.

Returns a version of this declare element in which all references to type variables are replaced with their bindings given in the map.
public static Declare
public void
resolve(IScope scope)

Implements abstract org.aspectj.weaver.patterns.Declare.resolve.

Returns this declare mutated
public void
setAnnotationLocation(int start, int end)

public void
public void
setAnnotationString(String annotationString)

public void
public void
setRemover(boolean b)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public Object
public void
Inherited from org.aspectj.weaver.patterns.Declare:
getDeclaringTypesetDeclaringType

Field Detail

AJC_DECLARE_ANNOTATIONback to summary
private static final String AJC_DECLARE_ANNOTATION
annotationback to summary
private AnnotationAJ annotation
annotationEndback to summary
private int annotationEnd
annotationMethodsback to summary
private List<String> annotationMethods
annotationStartback to summary
private int annotationStart
annotationStringsback to summary
private List<String> annotationStrings
annotationTypeback to summary
private ResolvedType annotationType
AT_CONSTRUCTORback to summary
public static final DeclareAnnotation.Kind AT_CONSTRUCTOR
AT_FIELDback to summary
public static final DeclareAnnotation.Kind AT_FIELD
AT_METHODback to summary
public static final DeclareAnnotation.Kind AT_METHOD
AT_REMOVE_FROM_FIELDback to summary
public static final DeclareAnnotation.Kind AT_REMOVE_FROM_FIELD
AT_TYPEback to summary
public static final DeclareAnnotation.Kind AT_TYPE
containingAspectback to summary
private ResolvedType containingAspect
isRemoverback to summary
pack-priv boolean isRemover
kindback to summary
private DeclareAnnotation.Kind kind
signaturePatternback to summary
private ISignaturePattern signaturePattern
typePatternback to summary
private TypePattern typePattern

Constructor Detail

DeclareAnnotationback to summary
public DeclareAnnotation(DeclareAnnotation.Kind kind, TypePattern typePattern)

Constructor for declare atType.

DeclareAnnotationback to summary
public DeclareAnnotation(DeclareAnnotation.Kind kind, ISignaturePattern sigPattern)

Constructor for declare atMethod/atField/atConstructor.

Method Detail

acceptback to summary
public Object accept(PatternNodeVisitor visitor, Object data)

Implements abstract org.aspectj.weaver.patterns.PatternNode.accept.

Annotations
@Override
copyAnnotationToback to summary
public void copyAnnotationTo(ResolvedType onType)
couldEverMatchback to summary
public boolean couldEverMatch(ResolvedType type)

Return true if this declare annotation could ever match something in the specified type - only really able to make intelligent decision if a type was specified in the sig/type pattern signature.

ensureAnnotationDiscoveredback to summary
private void ensureAnnotationDiscovered()

The annotation specified in the declare @type is stored against a simple method of the form "ajc$declare_", this method finds that method and retrieves the annotation.

Caveat: Nothing will be found for annotations with SOURCE retention, which of course are not present in the byte code.

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getAnnotationback to summary
public AnnotationAJ getAnnotation()
Returns:AnnotationAJ

declared annotation; can be null for annotations with SOURCE retention, which of course are not present in the byte code

getAnnotationMethodback to summary
public String getAnnotationMethod()
getAnnotationSourceEndback to summary
public int getAnnotationSourceEnd()
getAnnotationSourceStartback to summary
public int getAnnotationSourceStart()
getAnnotationStringback to summary
public String getAnnotationString()

Returns the string, useful before the real annotation has been resolved

getAnnotationTypeback to summary
public ResolvedType getAnnotationType()
Returns:ResolvedType

the type of the annotation; can be null for annotations with SOURCE retention, which of course are not present in the byte code

getAspectback to summary
public UnresolvedType getAspect()
getKindback to summary
public DeclareAnnotation.Kind getKind()
getNameSuffixback to summary
public String getNameSuffix()

Implements abstract org.aspectj.weaver.patterns.Declare.getNameSuffix.

Provide a name suffix so that we can tell the different declare annotations forms apart in the AjProblemReporter

Annotations
@Override
getPatternAsStringback to summary
public String getPatternAsString()
getSignaturePatternback to summary
public ISignaturePattern getSignaturePattern()
getTypePatternback to summary
public TypePattern getTypePattern()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
initback to summary
private void init()
isAdviceLikeback to summary
public boolean isAdviceLike()

Implements abstract org.aspectj.weaver.patterns.Declare.isAdviceLike.

Doc from org.aspectj.weaver.patterns.Declare.isAdviceLike.

Indicates if this declare should be treated like advice. If true, the declare will have no effect in an abstract aspect. It will be inherited by any concrete aspects and will have an effect for each concrete aspect it is ultimately inherited by.

Annotations
@Override
isAnnotationAllowedOnFieldback to summary
public boolean isAnnotationAllowedOnField()
Returns:boolean

true if the annotation specified is allowed on a field

isDeclareAtConstuctorback to summary
public boolean isDeclareAtConstuctor()
isDeclareAtFieldback to summary
public boolean isDeclareAtField()
isDeclareAtMethodback to summary
public boolean isDeclareAtMethod()
isDeclareAtTypeback to summary
public boolean isDeclareAtType()
isExactPatternback to summary
public boolean isExactPattern()
isRemoverback to summary
public boolean isRemover()
isStarredAnnotationPatternback to summary
public boolean isStarredAnnotationPattern()
matchesback to summary
public boolean matches(ResolvedMember resolvedmember, World world)

For declare atConstructor, atMethod, atField

matchesback to summary
public boolean matches(ResolvedType type)

For declare atType.

parameterizeWithback to summary
public Declare parameterizeWith(Map<String, UnresolvedType> typeVariableBindingMap, World w)

Implements abstract org.aspectj.weaver.patterns.Declare.parameterizeWith.

Doc from org.aspectj.weaver.patterns.Declare.parameterizeWith.

Returns a version of this declare element in which all references to type variables are replaced with their bindings given in the map.

Annotations
@Override
readback to summary
public static Declare read(VersionedDataInputStream s, ISourceContext context) throws IOException

Hides org.aspectj.weaver.patterns.Declare.read.

resolveback to summary
public void resolve(IScope scope)

Implements abstract org.aspectj.weaver.patterns.Declare.resolve.

Doc from org.aspectj.weaver.patterns.Declare.resolve.

Returns this declare mutated

Annotations
@Override
setAnnotationLocationback to summary
public void setAnnotationLocation(int start, int end)
setAnnotationMethodback to summary
public void setAnnotationMethod(String methodName)
setAnnotationStringback to summary
public void setAnnotationString(String annotationString)
setAspectback to summary
public void setAspect(ResolvedType typeX)
setRemoverback to summary
public void setRemover(boolean b)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
traverseback to summary
public Object traverse(PatternNodeVisitor visitor, Object data)

Overrides org.aspectj.weaver.patterns.PatternNode.traverse.

writeback to summary
public void write(CompressingDataOutputStream s) throws IOException

Implements abstract org.aspectj.weaver.patterns.PatternNode.write.

Annotations
@Override
org.aspectj.weaver.patterns back to summary

public Class DeclareAnnotation.Kind

extends Object
Class Inheritance

Captures type of declare annotation (method/type/field/constructor)

Field Summary

Modifier and TypeField and Description
private final int
private String
s

Constructor Summary

AccessConstructor and Description
private
Kind(int n, String name)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

idback to summary
private final int id
sback to summary
private String s

Constructor Detail

Kindback to summary
private Kind(int n, String name)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override