当前位置: 首页>>代码示例>>Java>>正文


Java XMethod.getName方法代码示例

本文整理汇总了Java中edu.umd.cs.findbugs.ba.XMethod.getName方法的典型用法代码示例。如果您正苦于以下问题:Java XMethod.getName方法的具体用法?Java XMethod.getName怎么用?Java XMethod.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.umd.cs.findbugs.ba.XMethod的用法示例。


在下文中一共展示了XMethod.getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parameterMustBeNonNull

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
public boolean parameterMustBeNonNull(XMethod m, int param) {
    if (DEBUG) {
        System.out.print("Checking " + m + " param " + param + " for @Nonnull...");
    }
    TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(m, param,
            nonnullTypeQualifierValue);

    if (tqa == null && param == 0) {
        String name = m.getName();
        String signature = m.getSignature();
        if (name.equals("main") && signature.equals("([Ljava/lang/String;)V") && m.isStatic() && m.isPublic())
            return true;
        else if (NullnessAnnotationDatabase.assertsFirstParameterIsNonnull(m))
            return true;
        else if (name.equals("compareTo") && signature.substring(signature.indexOf(";") + 1).equals(")Z") && !m.isStatic())
            return true;
    }
    boolean answer = (tqa != null) && tqa.when == When.ALWAYS;

    if (DEBUG) {
        System.out.println(answer ? "yes" : "no");
    }

    return answer;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:26,代码来源:TypeQualifierNullnessAnnotationDatabase.java

示例2: parameterMustBeNonNull

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
public boolean parameterMustBeNonNull(XMethod m, int param) {
    if (DEBUG) {
        System.out.print("Checking " + m + " param " + param + " for @Nonnull...");
    }
    TypeQualifierAnnotation tqa = TypeQualifierApplications.getEffectiveTypeQualifierAnnotation(m, param,
            nonnullTypeQualifierValue);

    if (tqa == null && param == 0) {
        String name = m.getName();
        String signature = m.getSignature();
        if (name.equals("main") && signature.equals("([Ljava/lang/String;)V") && m.isStatic() && m.isPublic())
            return true;
        else if (assertsFirstParameterIsNonnull(m))
            return true;
        else if (name.equals("compareTo") && signature.substring(signature.indexOf(";") + 1).equals(")Z") && !m.isStatic())
            return true;
    }
    boolean answer = (tqa != null) && tqa.when == When.ALWAYS;

    if (DEBUG) {
        System.out.println(answer ? "yes" : "no");
    }

    return answer;
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:26,代码来源:TypeQualifierNullnessAnnotationDatabase.java

示例3: badUseOfCompareResult

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
private boolean badUseOfCompareResult(Item left, Item right) {
    XMethod m = left.getReturnValueOf();

    if (m == null)
        return false;
    String name = m.getName();
    
    if (!name.startsWith("compare"))
        return false;
   
    Object value = right.getConstant();
    if (!(value instanceof Integer) || ((Integer) value).intValue() == 0)
        return false;
    if (!m.isPublic() && m.isResolved())
        return false;
    
    
    if (m.isStatic() || !m.isResolved()) {
        if (name.equals("compare") && m.getClassName().startsWith("com.google.common.primitives."))
            return true;
    }
    if (!m.isStatic() || !m.isResolved()) {
        if (name.equals("compareTo") && m.getSignature().equals("(Ljava/lang/Object;)I"))
            return true;
        if (name.equals("compare") && m.getSignature().equals("(Ljava/lang/Object;Ljava/lang/Object;)I"))
            return true;
    }

    return false;

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:32,代码来源:MethodReturnCheck.java

示例4: addObligations

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
/**
 * @param xmethod
 */
public void addObligations(XMethod xmethod) {
    // See what obligation parameters there are
    Obligation[] paramObligationTypes = database.getFactory().getParameterObligationTypes(xmethod);

    //
    // Check for @WillCloseWhenClosed, @WillClose, @WillNotClose, or
    // other
    // indications of how obligation parameters are handled.
    //

    boolean methodHasCloseInName = false;
    if (INFER_CLOSE_METHODS) {
        SplitCamelCaseIdentifier splitter = new SplitCamelCaseIdentifier(xmethod.getName());
        methodHasCloseInName = splitter.split().contains("close");
    }

    for (int i = 0; i < xmethod.getNumParams(); i++)
        if (paramObligationTypes[i] != null) {
            if (xmethod.getParameterAnnotation(i, willCloseWhenClosed) != null) {
                //
                // Calling this method deletes a parameter obligation
                // and
                // creates a new obligation for the object returned by
                // the method.
                //
                handleWillCloseWhenClosed(xmethod, paramObligationTypes[i]);
            } else if (xmethod.getParameterAnnotation(i, willClose) != null) {
                if (paramObligationTypes[i] == null) {
                    // Hmm...
                    if (DEBUG_ANNOTATIONS) {
                        System.out.println("Method " + xmethod.toString() + " has param " + i + " annotated @WillClose, "
                                + "but its type is not an obligation type");
                    }
                } else {
                    addParameterDeletesObligationDatabaseEntry(xmethod, paramObligationTypes[i],
                            ObligationPolicyDatabaseEntryType.STRONG);
                }
                sawAnnotationsInApplicationCode = true;
            } else if (xmethod.getParameterAnnotation(i, willNotClose) != null) {
                // No database entry needs to be added
                sawAnnotationsInApplicationCode = true;
            } else if (INFER_CLOSE_METHODS && methodHasCloseInName) {
                // Method has "close" in its name.
                // Assume that it deletes the obligation.
                addParameterDeletesObligationDatabaseEntry(xmethod, paramObligationTypes[i],
                        ObligationPolicyDatabaseEntryType.STRONG);
            } else {
                /*
                 * // Interesting case: we have a parameter which is // an
                 * Obligation type, but no annotation or other indication //
                 * what is done by the method with the obligation. // We'll
                 * create a "weak" database entry deleting the //
                 * obligation. If strict checking is performed, // weak
                 * entries are ignored.
                 */
                if (xmethod.getName().equals("<init>") || xmethod.isStatic()
                        || xmethod.getName().toLowerCase().indexOf("close") >= 0
                        || xmethod.getSignature().toLowerCase().indexOf("Closeable") >= 0)
                    addParameterDeletesObligationDatabaseEntry(xmethod, paramObligationTypes[i],
                            ObligationPolicyDatabaseEntryType.WEAK);
            }
        }

        
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:69,代码来源:BuildObligationPolicyDatabase.java

示例5: addObligations

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
/**
 * @param xmethod
 */
public void addObligations(XMethod xmethod) {
    // See what obligation parameters there are
    Obligation[] paramObligationTypes = database.getFactory().getParameterObligationTypes(xmethod);

    //
    // Check for @WillCloseWhenClosed, @WillClose, @WillNotClose, or
    // other
    // indications of how obligation parameters are handled.
    //

    boolean methodHasCloseInName = false;
    if (INFER_CLOSE_METHODS) {
        SplitCamelCaseIdentifier splitter = new SplitCamelCaseIdentifier(xmethod.getName());
        methodHasCloseInName = splitter.split().contains("close");
    }

    for (int i = 0; i < xmethod.getNumParams(); i++) {
        Obligation obligationType = paramObligationTypes[i];
        if (obligationType != null) {
            if (xmethod.getParameterAnnotation(i, willCloseWhenClosed) != null) {
                //
                // Calling this method deletes a parameter obligation
                // and
                // creates a new obligation for the object returned by
                // the method.
                //
                handleWillCloseWhenClosed(xmethod, obligationType);
            } else if (xmethod.getParameterAnnotation(i, willClose) != null) {
                addParameterDeletesObligationDatabaseEntry(xmethod, obligationType,
                        ObligationPolicyDatabaseEntryType.STRONG);
                sawAnnotationsInApplicationCode = true;
            } else if (xmethod.getParameterAnnotation(i, willNotClose) != null) {
                // No database entry needs to be added
                sawAnnotationsInApplicationCode = true;
            } else if (INFER_CLOSE_METHODS && methodHasCloseInName) {
                // Method has "close" in its name.
                // Assume that it deletes the obligation.
                addParameterDeletesObligationDatabaseEntry(xmethod, obligationType,
                        ObligationPolicyDatabaseEntryType.STRONG);
            } else {
                /*
                 * // Interesting case: we have a parameter which is // an
                 * Obligation type, but no annotation or other indication //
                 * what is done by the method with the obligation. // We'll
                 * create a "weak" database entry deleting the //
                 * obligation. If strict checking is performed, // weak
                 * entries are ignored.
                 */
                if (xmethod.getName().equals("<init>") || xmethod.isStatic()
                        || xmethod.getName().toLowerCase().indexOf("close") >= 0
                        || xmethod.getSignature().toLowerCase().indexOf("Closeable") >= 0)
                    addParameterDeletesObligationDatabaseEntry(xmethod, obligationType,
                            ObligationPolicyDatabaseEntryType.WEAK);
            }
        }
    }


}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:63,代码来源:BuildObligationPolicyDatabase.java

示例6: MatchMethodEntry

import edu.umd.cs.findbugs.ba.XMethod; //导入方法依赖的package包/类
/**
 * Constructor. Creates an entry which matches the given XMethod.
 * 
 * @param xmethod
 *            an XMethod
 * @param action
 *            ActionType (ADD or DEL, depending on whether obligation is
 *            added or deleted)
 * @param entryType
 *            entry type
 * @param obligations
 *            Obligation to be added or deleted
 */
public MatchMethodEntry(XMethod xmethod, ObligationPolicyDatabaseActionType action,
        ObligationPolicyDatabaseEntryType entryType, Obligation... obligations) {
    this(new SubtypeTypeMatcher(xmethod.getClassDescriptor()), new ExactStringMatcher(xmethod.getName()),
            new ExactStringMatcher(xmethod.getSignature()), xmethod.isStatic(), action, entryType, obligations);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:19,代码来源:MatchMethodEntry.java


注:本文中的edu.umd.cs.findbugs.ba.XMethod.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。