private void commandClear(StringTokenizer t) throws NoSessionException {
    if (!t.hasMoreTokens()) {
      // Print set breakpoints
      listEventRequests();
      return;
    }
    // ### need 'clear all'
    BreakpointSpec bpSpec = parseBreakpointSpec(t.nextToken());
    if (bpSpec != null) {
      List<EventRequestSpec> specs = runtime.eventRequestSpecs();

      if (specs.isEmpty()) {
        env.notice("No breakpoints set.");
      } else {
        List<EventRequestSpec> toDelete = new ArrayList<EventRequestSpec>();
        for (EventRequestSpec spec : specs) {
          if (spec.equals(bpSpec)) {
            toDelete.add(spec);
          }
        }
        // The request used for matching should be found
        if (toDelete.size() <= 1) {
          env.notice("No matching breakpoint set.");
        }
        for (EventRequestSpec spec : toDelete) {
          runtime.delete(spec);
        }
      }
    } else {
      env.error("Ill-formed breakpoint specification.");
    }
  }
 private ThreadReference[] threads() throws NoSessionException {
   if (threads == null) {
     ThreadIterator ti = new ThreadIterator(getDefaultThreadGroup());
     List<ThreadReference> tlist = new ArrayList<ThreadReference>();
     while (ti.hasNext()) {
       tlist.add(ti.nextThread());
     }
     threads = tlist.toArray(new ThreadReference[tlist.size()]);
   }
   return threads;
 }
 private BreakpointSpec parseBreakpointSpec(String bptSpec) {
   StringTokenizer t = new StringTokenizer(bptSpec);
   BreakpointSpec bpSpec = null;
   //        try {
   String token = t.nextToken("@:( \t\n\r");
   // We can't use hasMoreTokens here because it will cause any leading
   // paren to be lost.
   String rest;
   try {
     rest = t.nextToken("").trim();
   } catch (NoSuchElementException e) {
     rest = null;
   }
   if ((rest != null) && rest.startsWith("@")) {
     t = new StringTokenizer(rest.substring(1));
     String sourceName = token;
     String lineToken = t.nextToken();
     int lineNumber = Integer.valueOf(lineToken).intValue();
     if (t.hasMoreTokens()) {
       return null;
     }
     bpSpec = runtime.createSourceLineBreakpoint(sourceName, lineNumber);
   } else if ((rest != null) && rest.startsWith(":")) {
     t = new StringTokenizer(rest.substring(1));
     String classId = token;
     String lineToken = t.nextToken();
     int lineNumber = Integer.valueOf(lineToken).intValue();
     if (t.hasMoreTokens()) {
       return null;
     }
     bpSpec = runtime.createClassLineBreakpoint(classId, lineNumber);
   } else {
     // Try stripping method from class.method token.
     int idot = token.lastIndexOf(".");
     if ((idot <= 0) || /* No dot or dot in first char */ (idot >= token.length() - 1)) {
       /* dot in last char */
       return null;
     }
     String methodName = token.substring(idot + 1);
     String classId = token.substring(0, idot);
     List<String> argumentList = null;
     if (rest != null) {
       if (!rest.startsWith("(") || !rest.endsWith(")")) {
         // ### Should throw exception with error message
         // out.println("Invalid method specification: "
         //            + methodName + rest);
         return null;
       }
       // Trim the parens
       // ### What about spaces in arglist?
       rest = rest.substring(1, rest.length() - 1);
       argumentList = new ArrayList<String>();
       t = new StringTokenizer(rest, ",");
       while (t.hasMoreTokens()) {
         argumentList.add(t.nextToken());
       }
     }
     bpSpec = runtime.createMethodBreakpoint(classId, methodName, argumentList);
   }
   //        } catch (Exception e) {
   //            env.error("Exception attempting to create breakpoint: " + e);
   //            return null;
   //        }
   return bpSpec;
 }