コード例 #1
0
  // remove non-word characters and everything after ":::" from the
  // program point name, leaving PackageName.ClassName.MethodName
  private static String cleanup_pptname(String pptname) {
    int index;
    if ((index = pptname.indexOf("(")) > 0) {
      pptname = pptname.substring(0, index);
    }

    if (pptname.endsWith(".")) pptname = pptname.substring(0, pptname.length() - 2);

    Matcher m = non_word_pattern.matcher(pptname);
    return m.replaceAll(".");
  }
コード例 #2
0
 /**
  * Replaces instances of Java reserved words that could not appear in a valid Java condition or
  * Java variable name that are being used as variable names in string.
  *
  * @param string the string in which the Java reserved words should be replaced.
  * @return string with the Java reserved words replaced with a substitute names.
  */
 private static String replaceReservedWords(String string) {
   // cheap hack so that pattern never need to look for a key word at
   // the beginning or end of string.  That way one may simplify the pattern
   // to looking for a reserved word that is not prefixed or suffix with a
   // letter or number.
   string = "(" + string + ")";
   for (int i = 0; i < reservedWords.length; i++) {
     String reservedWord = reservedWords[i];
     Pattern p = Pattern.compile("([\\W])(" + reservedWord + ")([\\W])");
     Matcher m = p.matcher(string);
     while (m.find()) {
       string = m.replaceFirst(m.group(1) + "daikon" + reservedWord + m.group(3));
       m = p.matcher(string);
     }
   }
   return string.substring(1, string.length() - 1);
 }
コード例 #3
0
 private static boolean contains_exactly_one(String string, Pattern pattern) {
   Matcher m = pattern.matcher(string);
   // return true if first call returns true and second returns false
   return (m.find() && !m.find());
 }