Example usage for org.apache.commons.bcel6.classfile AnnotationEntry getElementValuePairs

List of usage examples for org.apache.commons.bcel6.classfile AnnotationEntry getElementValuePairs

Introduction

In this page you can find the example usage for org.apache.commons.bcel6.classfile AnnotationEntry getElementValuePairs.

Prototype

public ElementValuePair[] getElementValuePairs() 

Source Link

Usage

From source file:ru.objective.jni.utils.Utils.java

public static String getFieldExportName(Field field) {
    if (!field.isPublic() || field.isSynthetic())
        return null;

    AnnotationEntry[] entries = field.getAnnotationEntries();

    for (AnnotationEntry annotationEntry : entries) {
        String translated = Signature.translate(annotationEntry.getAnnotationType());

        if (translated.equals(OJNIExclude.class.getName()))
            return null;

        if (translated.equals(OJNIExportName.class.getName())) {

            ElementValuePair[] elementValuePairs = annotationEntry.getElementValuePairs();

            AnnotationType annotationType = AnnotationType.getInstance(OJNIExportName.class);

            for (ElementValuePair elementValuePair : elementValuePairs) {

                if (annotationType.memberTypes().get(elementValuePair.getNameString()) != null) {
                    return elementValuePair.getValue().stringifyValue();
                }/*from   w ww  .  j a  va2 s.  c  o  m*/
            }
        }
    }

    return field.getName();
}

From source file:ru.objective.jni.utils.Utils.java

public static MethodExportInfo getMethodExportInfo(Method method) {
    MethodExportInfo result = new MethodExportInfo();

    if (!method.isPublic() || method.isAnnotation() || method.isSynthetic())
        return result;

    String name = method.getName();

    AnnotationEntry[] entries = method.getAnnotationEntries();

    for (AnnotationEntry annotationEntry : entries) {
        String translated = Signature.translate(annotationEntry.getAnnotationType());

        if (translated.equals(OJNIExclude.class.getName()))
            return result;

        if (translated.equals(OJNIExportName.class.getName())) {
            result.isCustom = true;//from   w w w  .j  a  v  a2  s  .co  m

            ElementValuePair[] elementValuePairs = annotationEntry.getElementValuePairs();

            AnnotationType annotationType = AnnotationType.getInstance(OJNIExportName.class);

            for (ElementValuePair elementValuePair : elementValuePairs) {

                if (annotationType.memberTypes().get(elementValuePair.getNameString()) != null) {
                    name = elementValuePair.getValue().stringifyValue();
                }
            }
        }
    }

    result.name = name;

    return result;
}