當前位置: 首頁>>代碼示例>>Java>>正文


Java AnnotatedObject類代碼示例

本文整理匯總了Java中edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject的典型用法代碼示例。如果您正苦於以下問題:Java AnnotatedObject類的具體用法?Java AnnotatedObject怎麽用?Java AnnotatedObject使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AnnotatedObject類屬於edu.umd.cs.findbugs.classfile.analysis包,在下文中一共展示了AnnotatedObject類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getDirectAnnotation

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
/**
 * Get the direct annotations (if any) on given AnnotatedObject.
 *
 * @param m
 *            an AnnotatedObject
 * @return Collection of AnnotationValues representing annotations directly
 *         applied to this AnnotatedObject
 */
private static Collection<AnnotationValue> getDirectAnnotation(AnnotatedObject m) {
    Collection<AnnotationValue> result = getDirectObjectAnnotations().get(m);
    if (result != null)
        return result;
    if (m.getAnnotationDescriptors().isEmpty())
        return Collections.<AnnotationValue> emptyList();
    result = TypeQualifierResolver.resolveTypeQualifiers(m.getAnnotations());
    if (result.size() == 0)
        result = Collections.<AnnotationValue> emptyList();
    getDirectObjectAnnotations().put(m, result);
    return result;
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:21,代碼來源:TypeQualifierApplications.java

示例2: getEffectiveTypeQualifierAnnotation

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
/**
 * Get the effective TypeQualifierAnnotation on given AnnotatedObject. Takes
 * into account inherited and default (outer scope) annotations. Also takes
 * exclusive qualifiers into account.
 *
 * @param o
 *            an AnnotatedObject
 * @param typeQualifierValue
 *            a TypeQualifierValue specifying kind of annotation we want to
 *            look up
 * @return the effective TypeQualifierAnnotation, or null if there is no
 *         effective TypeQualifierAnnotation on this AnnotatedObject
 */
public static TypeQualifierAnnotation getEffectiveTypeQualifierAnnotation(AnnotatedObject o,
        TypeQualifierValue typeQualifierValue) {
    if (o instanceof XMethod) {
        XMethod m = (XMethod) o;
        if (m.getName().startsWith("access$")) {
            InnerClassAccessMap icam = AnalysisContext.currentAnalysisContext().getInnerClassAccessMap();
            try {
                InnerClassAccess ica = icam.getInnerClassAccess(m.getClassName(), m.getName());
                if (ica != null && ica.isLoad()) {
                    o = ica.getField();
                }
            } catch (ClassNotFoundException e) {
                AnalysisContext.reportMissingClass(e);
                return null;
            }

        }
    }
    TypeQualifierAnnotation tqa = computeEffectiveTypeQualifierAnnotation(typeQualifierValue, o);
    final AnnotatedObject o2 = o;
    if (CHECK_EXCLUSIVE && tqa == null && typeQualifierValue.isExclusiveQualifier()) {
        tqa = computeExclusiveQualifier(typeQualifierValue, new ComputeEffectiveTypeQualifierAnnotation() {
            public TypeQualifierAnnotation compute(TypeQualifierValue tqv) {
                return computeEffectiveTypeQualifierAnnotation(tqv, o2);
            }

            @Override
            public String toString() {
                return o2.toString();
            }
        });
    }

    return tqa;
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:49,代碼來源:TypeQualifierApplications.java

示例3: getDirectTypeQualifierAnnotation

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
/**
 * Get a directly-applied TypeQualifierAnnotation on given AnnotatedObject.
 *
 * @param o
 *            an AnnotatedObject
 * @param typeQualifierValue
 *            the kind of TypeQualifierValue we are looking for
 * @return directly-applied TypeQualifierAnnotation, or null if there is no
 *         such annotation on the AnnotatedObject
 */
private static TypeQualifierAnnotation getDirectTypeQualifierAnnotation(AnnotatedObject o,
        TypeQualifierValue typeQualifierValue) {
    TypeQualifierAnnotation result;

    Set<TypeQualifierAnnotation> applications = new HashSet<TypeQualifierAnnotation>();
    getDirectApplications(applications, o, o.getElementType());

    result = findMatchingTypeQualifierAnnotation(applications, typeQualifierValue);

    return result;
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:22,代碼來源:TypeQualifierApplications.java

示例4: getDefaultTypeQualifierAnnotation

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
/**
 * Get the default (outer scope) annotation applicable to given
 * AnnotatedObject.
 *
 * @param o
 *            an AnnotatedObject
 * @param typeQualifierValue
 *            the kind of TypeQualifierValue we are looking for
 * @return the applicable default TypeQualifierAnnotation, or null if there
 *         is no default TypeQualifierAnnotation
 */
private static TypeQualifierAnnotation getDefaultTypeQualifierAnnotation(AnnotatedObject o,
        TypeQualifierValue typeQualifierValue, boolean stopAtClassScope) {

    if (o.isSynthetic())
        return null; // synthetic objects don't get default annotations

    ElementType elementType = o.getElementType();
    while (true) {
        o = o.getContainingScope();
        if (o == null)
            return null;
        if (stopAtClassScope && o instanceof XClass)
            return null;
        TypeQualifierAnnotation result;

        // Check direct applications of the type qualifier
        Set<TypeQualifierAnnotation> applications = new HashSet<TypeQualifierAnnotation>();
        getDirectApplications(applications, o, elementType);
        result = findMatchingTypeQualifierAnnotation(applications, typeQualifierValue);
        if (result != null) {
            // Great - found an outer scope with a relevant annotation
            assert false : "I don't think we should be looking here";
            return result;
        }

        // Check default annotations
        result = getDefaultAnnotation(o, typeQualifierValue, elementType);
        if (result != null) {
            return result;
        }
    }
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:44,代碼來源:TypeQualifierApplications.java

示例5: getResolvedAnnotation

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
public NullnessAnnotation getResolvedAnnotation(Object o, boolean getMinimal) {
    Profiler profiler = Global.getAnalysisCache().getProfiler();
    profiler.start(this.getClass());
    try {

        if (DEBUG) {
            System.out.println("getResolvedAnnotation: o=" + o + "...");
        }

        TypeQualifierAnnotation tqa = null;

        if (o instanceof XMethodParameter) {
            XMethodParameter param = (XMethodParameter) o;

            tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(param.getMethod(),
                    param.getParameterNumber(), nonnullTypeQualifierValue);
        } else if (o instanceof XMethod || o instanceof XField) {
            tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation((AnnotatedObject) o,
                    nonnullTypeQualifierValue);
        }

        NullnessAnnotation result = toNullnessAnnotation(tqa);
        if (DEBUG) {
            if (result == null)
                System.out.println("   ===> not found");
            else
                System.out.println("   ===> " + tqa + "/" + result.toString() );
        }
        return result;
    } finally {
        profiler.end(this.getClass());
    }
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:34,代碼來源:TypeQualifierNullnessAnnotationDatabase.java

示例6: getContainingScope

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
public @CheckForNull
AnnotatedObject getContainingScope() {
    try {
        return Global.getAnalysisCache().getClassAnalysis(XClass.class, getClassDescriptor());
    } catch (CheckedAnalysisException e) {
        return null;
    }
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:9,代碼來源:UnresolvedXMethod.java

示例7: analysisContextContained

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
private boolean analysisContextContained(XClass xclass) {
    AnnotatedObject ao = xclass;
    do {
        if (ao.getAnnotation(AnalysisContextContainedAnnotation) != null)
            return true;
        ao = ao.getContainingScope();

    } while (ao != null);
    return false;

}
 
開發者ID:OpenNTF,項目名稱:FindBug-for-Domino-Designer,代碼行數:12,代碼來源:CheckAnalysisContextContainedAnnotation.java

示例8: getEffectiveTypeQualifierAnnotation

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
/**
 * Get the effective TypeQualifierAnnotation on given AnnotatedObject. Takes
 * into account inherited and default (outer scope) annotations. Also takes
 * exclusive qualifiers into account.
 *
 * @param o
 *            an AnnotatedObject
 * @param typeQualifierValue
 *            a TypeQualifierValue specifying kind of annotation we want to
 *            look up
 * @return the effective TypeQualifierAnnotation, or null if there is no
 *         effective TypeQualifierAnnotation on this AnnotatedObject
 */
public static TypeQualifierAnnotation getEffectiveTypeQualifierAnnotation(AnnotatedObject o,
        TypeQualifierValue<?> typeQualifierValue) {
    if (o instanceof XMethod) {
        XMethod m = (XMethod) o;
        if (m.getName().startsWith("access$")) {
            InnerClassAccessMap icam = AnalysisContext.currentAnalysisContext().getInnerClassAccessMap();
            try {
                InnerClassAccess ica = icam.getInnerClassAccess(m.getClassName(), m.getName());
                if (ica != null && ica.isLoad()) {
                    o = ica.getField();
                }
            } catch (ClassNotFoundException e) {
                AnalysisContext.reportMissingClass(e);
                return null;
            }

        }
    }
    TypeQualifierAnnotation tqa = computeEffectiveTypeQualifierAnnotation(typeQualifierValue, o);
    final AnnotatedObject o2 = o;
    if (CHECK_EXCLUSIVE && tqa == null && typeQualifierValue.isExclusiveQualifier()) {
        tqa = computeExclusiveQualifier(typeQualifierValue, new ComputeEffectiveTypeQualifierAnnotation() {
            public TypeQualifierAnnotation compute(TypeQualifierValue<?> tqv) {
                return computeEffectiveTypeQualifierAnnotation(tqv, o2);
            }

            @Override
            public String toString() {
                return o2.toString();
            }
        });
    }

    return tqa;
}
 
開發者ID:OpenNTF,項目名稱:FindBug-for-Domino-Designer,代碼行數:49,代碼來源:TypeQualifierApplications.java

示例9: getDirectTypeQualifierAnnotation

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
/**
 * Get a directly-applied TypeQualifierAnnotation on given AnnotatedObject.
 *
 * @param o
 *            an AnnotatedObject
 * @param typeQualifierValue
 *            the kind of TypeQualifierValue we are looking for
 * @return directly-applied TypeQualifierAnnotation, or null if there is no
 *         such annotation on the AnnotatedObject
 */
private static TypeQualifierAnnotation getDirectTypeQualifierAnnotation(AnnotatedObject o,
        TypeQualifierValue<?> typeQualifierValue) {
    TypeQualifierAnnotation result;

    Set<TypeQualifierAnnotation> applications = new HashSet<TypeQualifierAnnotation>();
    getDirectApplications(applications, o, o.getElementType());

    result = findMatchingTypeQualifierAnnotation(applications, typeQualifierValue);

    return result;
}
 
開發者ID:OpenNTF,項目名稱:FindBug-for-Domino-Designer,代碼行數:22,代碼來源:TypeQualifierApplications.java

示例10: getDefaultTypeQualifierAnnotation

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
/**
 * Get the default (outer scope) annotation applicable to given
 * AnnotatedObject.
 *
 * @param o
 *            an AnnotatedObject
 * @param typeQualifierValue
 *            the kind of TypeQualifierValue we are looking for
 * @return the applicable default TypeQualifierAnnotation, or null if there
 *         is no default TypeQualifierAnnotation
 */
private static TypeQualifierAnnotation getDefaultTypeQualifierAnnotation(AnnotatedObject o,
        TypeQualifierValue<?> typeQualifierValue, boolean stopAtClassScope) {

    if (o.isSynthetic())
        return null; // synthetic objects don't get default annotations

    ElementType elementType = o.getElementType();
    while (true) {
        o = o.getContainingScope();
        if (o == null)
            return null;
        if (stopAtClassScope && o instanceof XClass)
            return null;
        TypeQualifierAnnotation result;

        // Check direct applications of the type qualifier
        Set<TypeQualifierAnnotation> applications = new HashSet<TypeQualifierAnnotation>();
        getDirectApplications(applications, o, elementType);
        result = findMatchingTypeQualifierAnnotation(applications, typeQualifierValue);
        if (result != null) {
            // Great - found an outer scope with a relevant annotation
            assert false : "I don't think we should be looking here";
            return result;
        }

        // Check default annotations
        result = getDefaultAnnotation(o, typeQualifierValue, elementType);
        if (result != null) {
            return result;
        }
    }
}
 
開發者ID:OpenNTF,項目名稱:FindBug-for-Domino-Designer,代碼行數:44,代碼來源:TypeQualifierApplications.java

示例11: getDirectAnnotation

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
public @CheckForNull NullnessAnnotation getDirectAnnotation(Object o) {
    Profiler profiler = Global.getAnalysisCache().getProfiler();
    profiler.start(this.getClass());
    try {

        if (DEBUG) {
            System.out.println("getDirectAnnotation: o=" + o + "...");
        }

        TypeQualifierAnnotation tqa = null;

        if (o instanceof XMethodParameter) {
            XMethodParameter param = (XMethodParameter) o;
            tqa = TypeQualifierApplications.getDirectTypeQualifierAnnotation(param.getMethod(),
                    param.getParameterNumber(), nonnullTypeQualifierValue);
        } else if (o instanceof XMethod || o instanceof XField) {
            tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation((AnnotatedObject) o,
                    nonnullTypeQualifierValue);
        }

        NullnessAnnotation result = toNullnessAnnotation(tqa);
        if (DEBUG) {
            if (result == null)
                System.out.println("   ===> not found");
            else
                System.out.println("   ===> " + tqa + "/" + result.toString() );
        }
        return result;
    } finally {
        profiler.end(this.getClass());
    }
}
 
開發者ID:OpenNTF,項目名稱:FindBug-for-Domino-Designer,代碼行數:33,代碼來源:TypeQualifierNullnessAnnotationDatabase.java

示例12: getEffectiveObjectAnnotations

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
private static Map<TypeQualifierValue, Map<AnnotatedObject, TypeQualifierAnnotation>> getEffectiveObjectAnnotations() {
    return instance.get().effectiveObjectAnnotations;
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:4,代碼來源:TypeQualifierApplications.java

示例13: getDirectObjectAnnotations

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
private static Map<AnnotatedObject, Collection<AnnotationValue>> getDirectObjectAnnotations() {
    return instance.get().directObjectAnnotations;
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:4,代碼來源:TypeQualifierApplications.java

示例14: updateAnnotations

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
public static void updateAnnotations(AnnotatedObject object) {
    // TODO: Be smarter. Can we do something other than clear everything?
    clearInstance();
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:5,代碼來源:TypeQualifierApplications.java

示例15: getDefaultAnnotation

import edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject; //導入依賴的package包/類
/**
 * Look for a default type qualifier annotation.
 *
 * @param o
 *            an AnnotatedObject
 * @param typeQualifierValue
 *            a TypeQualifierValue
 * @param elementType
 *            type of element for which we're looking for a default
 *            annotation
 * @return default TypeQualifierAnnotation, or null if none
 */
private static @CheckForNull
TypeQualifierAnnotation getDefaultAnnotation(AnnotatedObject o, TypeQualifierValue typeQualifierValue, ElementType elementType) {
    //
    // Try to find a default annotation using the standard JSR-305
    // default annotation mechanism.
    //
    TypeQualifierAnnotation result;
    Collection<AnnotationValue> values = TypeQualifierResolver.resolveTypeQualifierDefaults(o.getAnnotations(), elementType);
    TypeQualifierAnnotation tqa = extractAnnotation(values, typeQualifierValue);

    if (tqa != null) {
        // System.out.println("Found default annotation of " + tqa +
        // " for element " + elementType + " in " + o);
        return tqa;
    }

    //
    // Try one of the FindBugs-specific default annotation mechanisms.
    //

    if ((result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION, o, typeQualifierValue)) != null) {
        return result;
    }

    switch (elementType) {
    case FIELD:
        result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_FIELDS, o,
                typeQualifierValue);
        break;
    case METHOD:
        result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_METHODS, o,
                typeQualifierValue);
        break;
    case PARAMETER:
        result = checkFindBugsDefaultAnnotation(FindBugsDefaultAnnotations.DEFAULT_ANNOTATION_FOR_PARAMETERS, o,
                typeQualifierValue);
        break;
    default:
        // ignore
    }

    return result;
}
 
開發者ID:ytus,項目名稱:findbugs-all-the-bugs,代碼行數:56,代碼來源:TypeQualifierApplications.java


注:本文中的edu.umd.cs.findbugs.classfile.analysis.AnnotatedObject類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。