Пример #1
1
    @Override
    public void run() {
      while (true) {
        if (istWindows()) aktuell = holeLaufwerkeWindows();
        else aktuell = holeLaufwerkeUnix();

        if (initial.size() != aktuell.size()) {
          if (!initial.containsAll(aktuell)) {
            neuesLaufwerk = holePathVonNeuemLaufwerk(initial, aktuell);
            textArea.append("Neues Laufwerk endeckt:  " + neuesLaufwerk + System.lineSeparator());
            this.initial = (ArrayList<Path>) aktuell.clone();
            neuesLaufwerkDialog();

          } else {
            this.initial = (ArrayList<Path>) aktuell.clone();
            textArea.append("Laufwerk wurde entfernt" + System.lineSeparator());
          }
        }

        try {
          Thread.sleep(5000);
        } catch (InterruptedException e) {
          System.out.println("Laufwerksprüfung wird abgebrochen");
        }
      }
    }
Пример #2
1
 private Path holePathVonNeuemLaufwerk(ArrayList<Path> initial, ArrayList<Path> aktuell) {
   ArrayList<Path> test, test1;
   test = (ArrayList<Path>) aktuell.clone();
   test1 = (ArrayList<Path>) initial.clone();
   test.removeAll(test1);
   return test.get(test.size() - 1);
 }
  public DependentLoaderImplementation cloneLoader(
      DependentLoader loader, String aditionalDependency) {
    DependentLoaderImplementation otherAsImplementation = (DependentLoaderImplementation) loader;

    DependentLoaderImplementation newLoader =
        new DependentLoaderImplementation(
            otherAsImplementation.artifact,
            loader.getURLs(),
            exposed,
            otherAsImplementation.parent);
    newLoader.dependencies = otherAsImplementation.dependencies;

    if (!"".equals(aditionalDependency)) {
      DependentLoaderImplementation dependency =
          enshureDependencyJarLoaded(otherAsImplementation.artifact, aditionalDependency);
      ArrayList<DependentLoaderImplementation> depList =
          new ArrayList<DependentLoaderImplementation>();
      for (DependentLoaderImplementation dependentLoaderImplementation : newLoader.dependencies) {
        depList.add(dependentLoaderImplementation);
      }
      depList.add(dependency);
      newLoader.setDependencies(depList.toArray(new DependentLoaderImplementation[depList.size()]));
    }
    visitLoader(newLoader);
    return newLoader;
  }
Пример #4
0
 private boolean startLauncher(File dir) {
   try {
     Runtime rt = Runtime.getRuntime();
     ArrayList<String> command = new ArrayList<String>();
     command.add("java");
     command.add("-jar");
     command.add("Launcher.jar");
     String[] cmdarray = command.toArray(new String[command.size()]);
     Process proc = rt.exec(cmdarray, null, dir);
     return true;
   } catch (Exception ex) {
     System.err.println("Unable to start the Launcher program.\n" + ex.getMessage());
     return false;
   }
 }
  public DependentLoaderImplementation[] getLoaded(String filter) {
    DefaultArtifact asArtifact = new DefaultArtifact(filter);
    DependentLoaderImplementation theLoader = findOverride(asArtifact);
    if (theLoader != null) {
      DependentLoaderImplementation[] retVal = {theLoader};
      return retVal;
    }

    if (loaderMap.containsKey(filter)) {
      DependentLoaderImplementation[] retVal = {loaderMap.get(filter)};
      return retVal;
    }

    ArrayList<DependentLoaderImplementation> result = new ArrayList();
    for (String key : loaderMap.keySet()) {
      if (key.startsWith(filter)) {
        result.add(loaderMap.get(key));
      }
    }
    ;
    return Arrays.copyOf(result.toArray(), result.size(), DependentLoaderImplementation[].class);
  }
Пример #6
0
  public PalindromeTest() {
    ArrayList<String> words = new ArrayList<String>();
    ArrayList<String> palis;

    try {
      for (String line : Files.readAllLines(Paths.get("com/jsanders/web2"))) {
        words.add(line);
      }
    } catch (IOException ex) {
      System.out.println("IO error");
      System.exit(1);
    }

    palis = Palindrome.palindromes(words);
    assertEquals(palis.size(), 161, 0.01);

    int shortest = Word.shortestLength(words);
    assertEquals(shortest, 1, 0.01);

    int longest = Word.longestLength(words);
    assertEquals(longest, 24, 0.01);

    ArrayList<String> shortestWords = Word.shortestWords(words);
    assertEquals(shortestWords.size(), 52, 0.01);

    ArrayList<String> longestWords = Word.longestWords(words);
    assertEquals(longestWords.size(), 5, 0.01);

    int totalWords = Word.totalWords(words);
    double avgLen = Word.averageLength(words);

    assertEquals(totalWords, 235886, 0.01);
    assertEquals(avgLen, 9.56, 0.01);

    ArrayList<Double> letterFreq = Word.letterFrequency(words);
    assertEquals(letterFreq.get(0), 0.087, 0.01);

    double properFreq = Word.properFrequency(words);
    assertEquals(properFreq, 0.106, 0.01);

    ArrayList<Integer> startFreq = Word.startFrequency(words);
    assertEquals(startFreq.get(0), 17096, 0.01);

    ArrayList<String> sameStartEnd = Word.startEndWords(words);
    assertEquals(sameStartEnd.size(), 11505, 0.01);

    try {
      PrintWriter f = new PrintWriter("short.txt");
      for (String w : shortestWords) f.println(w);
      f.close();

      f = new PrintWriter("long.txt");
      for (String w : longestWords) f.println(w);
      f.close();

      f = new PrintWriter("same.txt");
      for (String w : sameStartEnd) f.println(w);
      f.close();

      f = new PrintWriter("statistics.txt");
      f.println("avg word len: " + avgLen);
      f.println("freq of letters: " + letterFreq);
      f.println("freq of proper nouns/names: " + properFreq);
      f.println("words that start with each letter:: " + startFreq);

      f.close();
    } catch (IOException ex) {
      System.out.println("IO error");
      System.exit(1);
    }
  }