⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 methodnamedeclaration.java

📁 检查Java程序漏洞
💻 JAVA
字号:
/** * BSD-style license; for more info see http://pmd.sourceforge.net/license.html*/package net.sourceforge.pmd.symboltable;import net.sourceforge.pmd.ast.ASTFormalParameter;import net.sourceforge.pmd.ast.ASTFormalParameters;import net.sourceforge.pmd.ast.ASTMethodDeclarator;import net.sourceforge.pmd.ast.SimpleNode;public class MethodNameDeclaration extends AbstractNameDeclaration implements NameDeclaration {    public MethodNameDeclaration(ASTMethodDeclarator node) {        super(node);    }    public boolean equals(Object o) {        MethodNameDeclaration otherMethodDecl = (MethodNameDeclaration) o;        // compare method name        if (!otherMethodDecl.node.getImage().equals(node.getImage())) {            return false;        }        // compare parameter count - this catches the case where there are no params, too        if (((ASTMethodDeclarator) (otherMethodDecl.node)).getParameterCount() != ((ASTMethodDeclarator) node).getParameterCount()) {            return false;        }        // compare parameter types        ASTFormalParameters myParams = (ASTFormalParameters) node.jjtGetChild(0);        ASTFormalParameters otherParams = (ASTFormalParameters) otherMethodDecl.node.jjtGetChild(0);        for (int i = 0; i < ((ASTMethodDeclarator) node).getParameterCount(); i++) {            ASTFormalParameter myParam = (ASTFormalParameter) myParams.jjtGetChild(i);            ASTFormalParameter otherParam = (ASTFormalParameter) otherParams.jjtGetChild(i);            SimpleNode myTypeNode = (SimpleNode) myParam.jjtGetChild(0).jjtGetChild(0);            SimpleNode otherTypeNode = (SimpleNode) otherParam.jjtGetChild(0).jjtGetChild(0);            // simple comparison of type images            // this can be fooled by one method using "String"            // and the other method using "java.lang.String"            // once we get real types in here that should get fixed            if (!myTypeNode.getImage().equals(otherTypeNode.getImage())) {                return false;            }            // if type is ASTPrimitiveType and is an array, make sure the other one is also        }        return true;    }    public int hashCode() {        return node.getImage().hashCode() + ((ASTMethodDeclarator) node).getParameterCount();    }    public String toString() {        return "Method " + node.getImage() + ":" + node.getBeginLine();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -