Value of a field for an IAnnotation with K_QUALIFIED_NAME pair value [message #258197] |
Tue, 20 January 2009 12:49 |
Eclipse User |
|
|
|
Hi,
I have the following scenarion
public class MyClass {
public static final String NAME ="constant name";
@MyAnnotation(name =NAME)
private void method() {
}
}
I am parsing this code using IAnnotation.
What I have is an instance of IAnnotaiton and array of IMemberValuePair.
The valuePair contains one pair with
getMemberName() = MyAnnotation
getValueKind() = K_QUALIFIED_NAME
getValue() = "MyClass.NAME"
for (IMemberValuePair pair : pairs) {
if (pair.getMemberName().equals("name")) { //$NON-NLS-1$
if (pair.getValueKind() == IMemberValuePair.K_STRING) {
result = pair.getValue().toString();
} else if (pair.getValueKind() == IMemberValuePair.K_QUALIFIED_NAME)
{
// TODO: do something with this result. Resolve the value.
}
break;
}
}
If the annotation is @MyAnnotation(name = "constant name") I can get the
value "constant name".
But does anyone know how can I get the value "constant name" if the
annotatio is @MyAnnotation(name = NAME)? How could I determine the value of
NAME and property handle K_QUALIFIED_NAME?
Thank you in advance.
Best Regards,
Kiril
|
|
|
Powered by
FUDForum. Page generated in 0.02520 seconds