*/\r
\r
/**\r
+ * Thrown an application fails to launch in initialization.\r
+ * This error causes invalid deployment. \r
*\r
* @author Haruaki TAMADA\r
* @version $Revision$ $Date$\r
import java.util.Iterator;
/**
- * This interface represents the birthmark.
+ * This interface represents a birthmark.
+ * The birthmark is native characteristics of a program.
*
* @author Haruaki TAMADA
* @version $Revision$ $Date$
*/\r
\r
/**\r
+ * Thrown to indicate failed to compare two birthmarks. \r
* \r
* @author Haruaki Tamada\r
* @version $Revision$ $Date$\r
import java.util.Map;\r
\r
/**\r
- * Runtime properties.\r
+ * Birthmark runtime context.\r
* \r
* @author Haruaki Tamada\r
* @version $Revision$ $Date$\r
/**
* element of birthmark.
+ *
* @author Haruaki TAMADA
* @version $Revision$ $Date$
*/
import java.util.List;\r
\r
/**\r
+ * Thrown if extracting birthmark is failed to find a class definition.\r
+ * \r
* @author Haruaki TAMADA\r
* @version $Revision$ $Date$\r
*/\r
BirthmarkExtractionFailedException {\r
private static final long serialVersionUID = 3256723476854L;\r
\r
+ /**\r
+ * class name list, which names are failed to load.\r
+ */\r
private List<String> classnames = new ArrayList<String>();\r
\r
+ /**\r
+ * \r
+ */\r
public void addClassName(String name){\r
classnames.add(name);\r
}\r
return super.isFailed() || classnames.size() > 0;\r
}\r
\r
+ /**\r
+ * returns an array of class names which are failed loading.\r
+ */\r
public synchronized String[] getClassNames(){\r
return classnames.toArray(new String[classnames.size()]);\r
}\r
\r
+ @Override\r
public String getMessage(){\r
StringBuffer sb = new StringBuffer();\r
boolean first = true;\r
for(String value: classnames){\r
- if(!first){\r
- sb.append(", ");\r
- }\r
- sb.append(value);\r
+ if(!first){\r
+ sb.append(", ");\r
+ }\r
+ sb.append(value);\r
}\r
return new String(sb);\r
}\r
import jp.naist.se.stigmata.result.RoundRobinComparisonResultSet;\r
\r
/**\r
- * This class is birthmarking engine. \r
- * This class extracts birthmarks from given Java class files, compares results of extractions, and filters results of comparisons.\r
+ * core engine for extracting/comparing/filtering birthmarks.\r
* \r
* This class is not thread safe.\r
* \r
import java.util.List;\r
\r
/**\r
+ * \r
* @author Haruaki TAMADA\r
* @version $Revision$ $Date$\r
*/\r
import java.util.Map;\r
\r
/**\r
- * This class manages a set of birthmarks which extracted from a Java class file.\r
+ * This class manages a set of birthmarks which extracted from a target.\r
*\r
* @author Haruaki TAMADA\r
* @version $Revision$ $Date$\r
*/\r
public class BirthmarkSet implements Iterable<Birthmark>{\r
/**\r
- * class name.\r
+ * this object name.\r
*/\r
private String name;\r
\r
/**\r
- * location of class file is loaded from.\r
+ * location of target is loaded from.\r
*/\r
private URL location;\r
\r
}\r
\r
/**\r
- * return the class name.\r
+ * return the name.\r
*/\r
public String getName(){\r
return name;\r
\r
/**\r
* add given birthmark to this instance.\r
+ * @throws NullPointerException given birthmark is null.\r
*/\r
public void addBirthmark(Birthmark birthmark){\r
+ if(birthmark == null){\r
+ throw new NullPointerException("given birthmark is null");\r
+ }\r
birthmarks.put(birthmark.getType(), birthmark);\r
}\r
\r
return birthmarks.get(type);\r
}\r
\r
+ /**\r
+ * does this object have the given birthmark type.\r
+ */\r
public boolean hasBirthmark(String type){\r
return birthmarks.get(type) != null;\r
}\r
\r
/**\r
- * return the all birthmarks this instance managed.\r
+ * returns an array containing all of the birthmarks in this object.\r
*/\r
public Birthmark[] getBirthmarks(){\r
Birthmark[] b = new Birthmark[getBirthmarksCount()];\r
return b;\r
}\r
\r
+ /**\r
+ * returns an iterator over the birthmarks in this birthmark-set.\r
+ */\r
public Iterator<Birthmark> iterator(){\r
return birthmarks.values().iterator();\r
}\r
\r
/**\r
- * return types of birthmarks.\r
+ * returns an iterator over the birthmark types.\r
*/\r
public Iterator<String> birthmarkTypes(){\r
return birthmarks.keySet().iterator();\r
}\r
\r
/**\r
- * return types of birthmarks.\r
+ * returns an array of birthmark types.\r
*/\r
public synchronized String[] getBirthmarkTypes(){\r
return birthmarks.keySet().toArray(new String[birthmarks.size()]);\r
}\r
\r
public boolean equals(Object o){\r
- return o == this;\r
+ String className = null;\r
+ if(o != null){\r
+ className = o.getClass().getName();\r
+ }\r
+ return o != null && className.equals(getClass().getName());\r
}\r
}
\ No newline at end of file
*/\r
public enum BirthmarkStoreTarget{\r
MEMORY,\r
+// DERBY,\r
// FILE,\r
// MYSQL, \r
// POSTGRESQL,\r
\r
/**\r
* This class represents comparison pair.\r
+ * \r
* @author Haruaki TAMADA\r
* @version $Revision$ $Date$\r
*/\r
}\r
\r
/**\r
- * calculate similarity between target1 and target2.\r
+ * calculates similarity between target1 and target2.\r
*/\r
public double calculateSimilarity(){\r
double similarity = 0d;\r
}\r
\r
/**\r
- * Return the number of birthmarks contained a target.\r
+ * Returns a number of birthmarks contained a target.\r
* Note that other target must have same birthmarks.\r
*/\r
public int getBirthmarksCount(){\r
}\r
\r
/**\r
- * return the iterator for comparing each birthmarks.\r
+ * returns an iterator for comparing each birthmarks.\r
*/\r
public synchronized Iterator<ComparisonPairElement> iterator(){\r
List<ComparisonPairElement> list = new ArrayList<ComparisonPairElement>();\r
return compareCount;\r
}\r
\r
+ /**\r
+ * returns a type of birthmarks.\r
+ */\r
public String getType(){\r
return birthmark1.getType();\r
}\r
\r
/**\r
- * @return similarity\r
+ * returns similarity between two birthmarks.\r
*/\r
public double getSimilarity(){\r
return similarity;\r
return flag;\r
}\r
\r
+ /**\r
+ * returns a flag that all filters must be matched.\r
+ */\r
public boolean isMatchAll(){\r
return matchall;\r
}\r
\r
+ /**\r
+ * returns a flag that any filters must be matched.\r
+ */\r
public boolean isMatchAny(){\r
return !isMatchAll();\r
}\r
package jp.naist.se.stigmata.result;\r
\r
+/*\r
+ * $Id$\r
+ */\r
+\r
import java.lang.reflect.Constructor;\r
import java.lang.reflect.InvocationTargetException;\r
import java.util.HashMap;\r
import jp.naist.se.stigmata.BirthmarkStoreTarget;\r
import jp.naist.se.stigmata.ExtractionResultSet;\r
\r
+/**\r
+ * \r
+ * @author Haruaki Tamada\r
+ * @version $Revision$ $Date$\r
+ */\r
public class ExtractionResultSetFactory{\r
private static ExtractionResultSetFactory instance = new ExtractionResultSetFactory();\r
private Map<String, Class<? extends ExtractionResultSet>> map = new HashMap<String, Class<? extends ExtractionResultSet>>();\r