Esempio n. 1
0
 public int compareTo(Object o) {
   if (o instanceof Path) {
     return file.compareTo(((Path) o).file);
   } else {
     return file.compareTo((File) o);
   }
 }
    /*
     * dirNames is an array of string integers derived from usual directory
     * structure data/subdirN/subdirXY/subdirM ... If dirName array is
     * non-null, we only check the child at the children[dirNames[idx]].
     * This avoids iterating over children in common case. If directory
     * structure changes in later versions, we need to revisit this.
     */
    private boolean clearPath(File f, String[] dirNames, int idx) {
      if ((dirNames == null || idx == dirNames.length) && dir.compareTo(f) == 0) {
        numBlocks--;
        return true;
      }

      if (dirNames != null) {
        // guess the child index from the directory name
        if (idx > (dirNames.length - 1) || children == null) {
          return false;
        }
        int childIdx;
        try {
          childIdx = Integer.parseInt(dirNames[idx]);
        } catch (NumberFormatException ignored) {
          // layout changed? we could print a warning.
          return false;
        }
        return (childIdx >= 0 && childIdx < children.length)
            ? children[childIdx].clearPath(f, dirNames, idx + 1)
            : false;
      }

      // guesses failed. back to blind iteration.
      if (children != null) {
        for (int i = 0; i < children.length; i++) {
          if (children[i].clearPath(f, null, -1)) {
            return true;
          }
        }
      }
      return false;
    }
Esempio n. 3
0
 public static Configuration getConfig() {
   File currentConfigFile = getConfigFile();
   if (config == null || configFile.compareTo(currentConfigFile) != 0) {
     configFile = currentConfigFile;
     config = new Configuration(configFile);
     config.load();
   }
   return config;
 }
Esempio n. 4
0
 public int compare(File o1, File o2) {
   if (o1.isDirectory() && !o2.isDirectory()) {
     return -1;
   } else if (!o1.isDirectory() && o2.isDirectory()) {
     return 1;
   } else {
     return o1.compareTo(o2);
   }
 }
Esempio n. 5
0
 private void resetPlayingFile() {
   File lastFile = null;
   if (dir != null) {
     File[] filenames = dir.listFiles();
     for (File tmpf : filenames) {
       if (lastFile == null || tmpf.compareTo(lastFile) > 0) lastFile = tmpf;
     }
   }
   setPlayingFile(lastFile);
 }
 /** Sorts earlier EntryFile instances before later ones. */
 public final int compareTo(EntryFile o) {
   if (timestampMillis < o.timestampMillis) return -1;
   if (timestampMillis > o.timestampMillis) return 1;
   if (file != null && o.file != null) return file.compareTo(o.file);
   if (o.file != null) return -1;
   if (file != null) return 1;
   if (this == o) return 0;
   if (hashCode() < o.hashCode()) return -1;
   if (hashCode() > o.hashCode()) return 1;
   return 0;
 }
 @Override
 public int compare(File file, File file2) {
   if (file.isDirectory()) {
     if (!file2.isDirectory()) {
       return -1;
     }
   } else if (file2.isDirectory()) {
     return 1;
   }
   return file.compareTo(file2);
 }
 /**
  * Limit list of possible file to import.
  *
  * @param toFilter set of files to import
  * @param fileName optional file name
  * @return the filtered file array
  */
 private File[] filterFiles(final File[] toFilter, final String fileName) {
   if (fileName != null && toFilter != null) {
     final File fileAsFilter = new File(fileName);
     for (File file : toFilter) {
       if (file.compareTo(fileAsFilter) == 0) {
         return new File[] {fileAsFilter};
       }
     }
     return new File[0];
   }
   return toFilter;
 }
Esempio n. 9
0
  public int compareTo(FileWrapper aOther) {
    if (aOther != null) {
      // Who says ternary is hard to follow
      if (isEnabled() == aOther.isEnabled()) {
        return (typeIndex == aOther.typeIndex)
            ? file.compareTo(aOther.file)
            : ((typeIndex < aOther.typeIndex) ? -1 : 1);
      } else {
        return isEnabled() ? -1 : 1;
      }
    }

    return -1;
  }
Esempio n. 10
0
 @Override
 public int compare(File o1, File o2) {
   try {
     final String filename1 = getCanonicalPath(o1);
     final String filename2 = getCanonicalPath(o2);
     if (this.isIgnoringCase()) {
       return filename1.compareToIgnoreCase(filename2);
     } else {
       return filename1.compareTo(filename2);
     }
   } catch (IOException ex) {
     return o1.compareTo(o2);
   }
 }
  private File getWebXmlFile() throws IOException {
    File file = null;
    File baseDir = project.getBasedir().getCanonicalFile();
    File defaultWebAppSrcDir = new File(baseDir, "src/main/webapp").getCanonicalFile();
    File webAppSrcDir = new File(webAppSourceDirectory).getCanonicalFile();
    File defaultWebXml = new File(defaultWebAppSrcDir, "web.xml").getCanonicalFile();

    // If the web.xml has been changed from the default, try that
    File webXmlFile = new File(webXml).getCanonicalFile();
    if (webXmlFile.compareTo(defaultWebXml) != 0) {
      file = new File(webXml);
      return file;
    }

    // If the web app src directory has not been changed from the default, use whatever
    // is set for the web.xml location
    file = new File(webAppSrcDir, "web.xml");
    return file;
  }
Esempio n. 12
0
  private String formatFileDetail(String changeLogLocation, String editorFileLocation) {
    // Format Path. Is a full path specified, or just file name?
    IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
    String WorkspaceRoot = myWorkspaceRoot.getLocation().toOSString();
    String changeLogLocNoRoot = ""; // $NON-NLS-1$
    String editorFileLocNoRoot = ""; // $NON-NLS-1$
    if (changeLogLocation.lastIndexOf(WorkspaceRoot) >= 0) {
      changeLogLocNoRoot =
          changeLogLocation.substring(
              changeLogLocation.lastIndexOf(WorkspaceRoot) + WorkspaceRoot.length(),
              changeLogLocation.length());
    } else changeLogLocNoRoot = changeLogLocation;

    if (editorFileLocation.lastIndexOf(WorkspaceRoot) >= 0) {
      editorFileLocNoRoot =
          editorFileLocation.substring(
              editorFileLocation.lastIndexOf(WorkspaceRoot),
              editorFileLocation.lastIndexOf(WorkspaceRoot) + WorkspaceRoot.length());
    } else editorFileLocNoRoot = editorFileLocation;

    File changelogLocation = new File(changeLogLocNoRoot);
    File fileLocation = new File(editorFileLocNoRoot);
    File reversePath = fileLocation.getParentFile();
    String reversePathb = ""; // $NON-NLS-1$

    while (reversePath.getParentFile() != null) {
      if (reversePath.compareTo(changelogLocation.getParentFile()) == 0) break;
      reversePath = reversePath.getParentFile();
    }
    if (reversePath != null)
      reversePathb =
          fileLocation
              .toString()
              .substring(reversePath.toString().length() + 1, fileLocation.toString().length());
    return reversePathb;
  }
Esempio n. 13
0
 public int compareTo(PublishArtifactInfo other) {
   return file.compareTo(other.getFile());
 }
Esempio n. 14
0
 public int compare(File file1, File file2) {
   int ret = compareSimple(file1, file2);
   return ret != AMBIGUOUS ? ret : file1.compareTo(file2);
 }
Esempio n. 15
0
 public int compareTo(Path pathname) {
   return file.compareTo(pathname.file);
 }
Esempio n. 16
0
 public int compareTo(Entry other) {
   return file.compareTo(other.file);
 }
Esempio n. 17
0
 @Override
 public int compareTo(MediaFile o) {
   return file.compareTo(o.getFile());
 }