本文整理汇总了Java中edu.umd.cs.findbugs.util.SubtypeTypeMatcher类的典型用法代码示例。如果您正苦于以下问题:Java SubtypeTypeMatcher类的具体用法?Java SubtypeTypeMatcher怎么用?Java SubtypeTypeMatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubtypeTypeMatcher类属于edu.umd.cs.findbugs.util包,在下文中一共展示了SubtypeTypeMatcher类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFileStreamEntries
import edu.umd.cs.findbugs.util.SubtypeTypeMatcher; //导入依赖的package包/类
/**
* General method for adding entries for File
* InputStream/OutputStream/Reader/Writer classes.
*/
private void addFileStreamEntries(String kind) {
Obligation obligation = database.getFactory().addObligation("java.io." + kind);
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.io.File" + kind)),
new ExactStringMatcher("<init>"), new RegexStringMatcher(".*"), false, ObligationPolicyDatabaseActionType.ADD,
ObligationPolicyDatabaseEntryType.STRONG, obligation));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.io." + kind)),
new ExactStringMatcher("close"), new ExactStringMatcher("()V"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, obligation));
}
示例2: addBuiltInPolicies
import edu.umd.cs.findbugs.util.SubtypeTypeMatcher; //导入依赖的package包/类
private void addBuiltInPolicies() {
// Add the database entries describing methods that add and delete
// file stream/reader obligations.
addFileStreamEntries("InputStream");
addFileStreamEntries("OutputStream");
addFileStreamEntries("Reader");
addFileStreamEntries("Writer");
Obligation javaIoInputStreamObligation = database.getFactory().getObligationByName("java.io.InputStream");
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.lang.Class")),
new ExactStringMatcher("getResourceAsStream"),
new ExactStringMatcher("(Ljava/lang/String;)Ljava/io/InputStream;"), false,
ObligationPolicyDatabaseActionType.ADD, ObligationPolicyDatabaseEntryType.STRONG, javaIoInputStreamObligation));
Obligation javaIoOutputStreamObligation = database.getFactory().getObligationByName("java.io.OutputStream");
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil
.getObjectTypeInstance("java.util.logging.StreamHandler")), new ExactStringMatcher("setOutputStream"),
new ExactStringMatcher("(Ljava/io/OutputStream;)V"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, javaIoOutputStreamObligation));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil
.getObjectTypeInstance("java.io.FileOutputStream")), new ExactStringMatcher("getChannel"),
new ExactStringMatcher("()Ljava/nio/channels/FileChannel;"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, javaIoOutputStreamObligation));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil
.getObjectTypeInstance("java.io.FileInputStream")), new ExactStringMatcher("getChannel"),
new ExactStringMatcher("()Ljava/nio/channels/FileChannel;"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, javaIoInputStreamObligation));
// Database obligation types
Obligation connection = database.getFactory().addObligation("java.sql.Connection");
Obligation statement = database.getFactory().addObligation("java.sql.Statement");
Obligation resultSet = database.getFactory().addObligation("java.sql.ResultSet");
// Add factory method entries for database obligation types
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.DriverManager")),
new ExactStringMatcher("getConnection"), new RegexStringMatcher("^.*\\)Ljava/sql/Connection;$"), false,
ObligationPolicyDatabaseActionType.ADD, ObligationPolicyDatabaseEntryType.STRONG, connection));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.Connection")),
new ExactStringMatcher("createStatement"), new RegexStringMatcher("^.*\\)Ljava/sql/Statement;$"), false,
ObligationPolicyDatabaseActionType.ADD, ObligationPolicyDatabaseEntryType.STRONG, statement));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.Connection")),
new ExactStringMatcher("prepareStatement"), new RegexStringMatcher("^.*\\)Ljava/sql/PreparedStatement;$"), false,
ObligationPolicyDatabaseActionType.ADD, ObligationPolicyDatabaseEntryType.STRONG, statement));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.Statement")),
new ExactStringMatcher("executeQuery"), new RegexStringMatcher("^.*\\)Ljava/sql/ResultSet;$"), false,
ObligationPolicyDatabaseActionType.ADD, ObligationPolicyDatabaseEntryType.STRONG, resultSet));
// Add close method entries for database obligation types
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.Connection")),
new ExactStringMatcher("close"), new ExactStringMatcher("()V"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, connection));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.Statement")),
new ExactStringMatcher("close"), new ExactStringMatcher("()V"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, statement, resultSet));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.ResultSet")),
new ExactStringMatcher("close"), new ExactStringMatcher("()V"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, resultSet));
}
示例3: MatchMethodEntry
import edu.umd.cs.findbugs.util.SubtypeTypeMatcher; //导入依赖的package包/类
public MatchMethodEntry(MethodDescriptor method, ObligationPolicyDatabaseActionType action,
ObligationPolicyDatabaseEntryType entryType, Obligation... obligations) {
this(new SubtypeTypeMatcher(method.getClassDescriptor()), new ExactStringMatcher(method.getName()),
new ExactStringMatcher(method.getSignature()), method.isStatic(), action, entryType, obligations);
}
示例4: addBuiltInPolicies
import edu.umd.cs.findbugs.util.SubtypeTypeMatcher; //导入依赖的package包/类
private void addBuiltInPolicies() {
// Add the database entries describing methods that add and delete
// file stream/reader obligations.
addFileStreamEntries("InputStream");
addFileStreamEntries("OutputStream");
addFileStreamEntries("Reader");
addFileStreamEntries("Writer");
Obligation javaIoInputStreamObligation = database.getFactory().getObligationByName("java.io.InputStream");
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.lang.Class")),
new ExactStringMatcher("getResourceAsStream"),
new ExactStringMatcher("(Ljava/lang/String;)Ljava/io/InputStream;"), false,
ObligationPolicyDatabaseActionType.ADD, ObligationPolicyDatabaseEntryType.STRONG, javaIoInputStreamObligation));
Obligation javaIoOutputStreamObligation = database.getFactory().getObligationByName("java.io.OutputStream");
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil
.getObjectTypeInstance("java.util.logging.StreamHandler")), new ExactStringMatcher("setOutputStream"),
new ExactStringMatcher("(Ljava/io/OutputStream;)V"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, javaIoOutputStreamObligation));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil
.getObjectTypeInstance("java.io.FileOutputStream")), new ExactStringMatcher("getChannel"),
new ExactStringMatcher("()Ljava/nio/channels/FileChannel;"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, javaIoOutputStreamObligation));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil
.getObjectTypeInstance("java.io.FileInputStream")), new ExactStringMatcher("getChannel"),
new ExactStringMatcher("()Ljava/nio/channels/FileChannel;"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, javaIoInputStreamObligation));
// Database obligation types
Obligation connection = database.getFactory().addObligation("java.sql.Connection");
Obligation statement = database.getFactory().addObligation("java.sql.Statement");
Obligation resultSet = database.getFactory().addObligation("java.sql.ResultSet");
// Add factory method entries for database obligation types
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.DriverManager")),
new ExactStringMatcher("getConnection"), new RegexStringMatcher("^.*\\)Ljava/sql/Connection;$"), false,
ObligationPolicyDatabaseActionType.ADD, ObligationPolicyDatabaseEntryType.STRONG, connection));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.Connection")),
new ExactStringMatcher("createStatement"), new RegexStringMatcher("^.*\\)Ljava/sql/Statement;$"), false,
ObligationPolicyDatabaseActionType.ADD, ObligationPolicyDatabaseEntryType.STRONG, statement));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.Connection")),
new ExactStringMatcher("prepareStatement"), new RegexStringMatcher("^.*\\)Ljava/sql/PreparedStatement;$"), false,
ObligationPolicyDatabaseActionType.ADD, ObligationPolicyDatabaseEntryType.STRONG, statement));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.Statement")),
new ExactStringMatcher("executeQuery"), new RegexStringMatcher("^.*\\)Ljava/sql/ResultSet;$"), false,
ObligationPolicyDatabaseActionType.ADD, ObligationPolicyDatabaseEntryType.STRONG, resultSet));
// Add close method entries for database obligation types
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.Connection")),
new ExactStringMatcher("close"), new ExactStringMatcher("()V"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, connection));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.Statement")),
new ExactStringMatcher("close"), new ExactStringMatcher("()V"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, statement, resultSet));
database.addEntry(new MatchMethodEntry(new SubtypeTypeMatcher(BCELUtil.getObjectTypeInstance("java.sql.ResultSet")),
new ExactStringMatcher("close"), new ExactStringMatcher("()V"), false, ObligationPolicyDatabaseActionType.DEL,
ObligationPolicyDatabaseEntryType.STRONG, resultSet));
}