Update of /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29511/src/com/mebigfatguy/fbcontrib/detect
Modified Files:
ArrayBasedCollections.java
Log Message:
javadoc, etc
Index: ArrayBasedCollections.java
===================================================================
RCS file: /cvsroot/fb-contrib/fb-contrib/src/com/mebigfatguy/fbcontrib/detect/ArrayBasedCollections.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ArrayBasedCollections.java 21 Dec 2005 05:13:39 -0000 1.2
+++ ArrayBasedCollections.java 22 Dec 2005 19:12:47 -0000 1.3
@@ -31,6 +31,12 @@
import edu.umd.cs.findbugs.StatelessDetector;
import edu.umd.cs.findbugs.ba.ClassContext;
+/**
+ * Looks for methods that use arrays for items in the keyset of a map, or as
+ * an element of a set, or in a list when using the contains method. Since arrays
+ * do not, and cannot define an equals method, reference equality is used for these
+ * collections, which is probably not desired.
+ */
public class ArrayBasedCollections extends BytecodeScanningDetector implements StatelessDetector
{
private BugReporter bugReporter;
@@ -40,15 +46,30 @@
private boolean hasMapComparator;
private boolean hasSetComparator;
+ /**
+ * constructs a ABC detector given the reporter to report bugs on
+
+ * @param bugReporter the sync of bug reports
+ */
public ArrayBasedCollections(BugReporter bugReporter) {
this.bugReporter = bugReporter;
}
+ /**
+ * clone this detector so that it can be a StatelessDetector
+ *
+ * @return a clone of this object
+ */
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
+ /**
+ * implement the visitor to report bugs if no Tree comparators were found
+ *
+ * @param classContext the context object for the class currently being parsed
+ */
@Override
public void visitClassContext(ClassContext classContext) {
mapBugs.clear();
@@ -69,12 +90,22 @@
}
}
+ /**
+ * implements the visitor to reset the stack of opcodes
+ *
+ * @param obj the context object for the currently parsed code block
+ */
@Override
public void visitCode(Code obj) {
stack.resetForMethodEntry(this);
super.visitCode(obj);
}
+ /**
+ * implements the visitor to find accesses to maps, sets and lists using arrays
+ *
+ * @param seen the currently visitor opcode
+ */
@Override
public void sawOpcode(int seen) {
try {
|