Example usage for java.nio.file Path toString

List of usage examples for java.nio.file Path toString

Introduction

In this page you can find the example usage for java.nio.file Path toString.

Prototype

String toString();

Source Link

Document

Returns the string representation of this path.

Usage

From source file:gov.nasa.jpl.memex.pooledtimeseries.PoT.java

public static void evaluateSimilarity(ArrayList<Path> files, int save_mode) {
      // PoT level set
      ArrayList<double[]> tws = getTemporalWindows(4);

      // computing feature vectors
      ArrayList<FeatureVector> fv_list = new ArrayList<FeatureVector>();

      for (int k = 0; k < files.size(); k++) {
          try {//from www  . jav  a2s . co  m
              LOG.fine(files.get(k).toString());

              ArrayList<double[][]> multi_series = new ArrayList<double[][]>();
              Path file = files.get(k);

              // optical flow descriptors
              String series_name1 = file.toString();
              if ((!series_name1.endsWith(".of.txt")) && (!series_name1.endsWith(".hog.txt"))) {
                  series_name1 += ".of.txt";
              }
              Path series_path1 = Paths.get(series_name1);
              double[][] series1;

              if (save_mode == 0) {
                  series1 = getOpticalTimeSeries(file, 5, 5, 8);
                  saveVectors(series1, series_path1);

              } else {
                  series1 = loadTimeSeries(series_path1);
              }

              multi_series.add(series1);

              // gradients descriptors
              String series_name2 = file.toString();
              if ((!series_name2.endsWith(".hog.txt")) && (!series_name2.endsWith(".of.txt"))) {
                  series_name2 += ".hog.txt";
              }
              Path series_path2 = Paths.get(series_name2);
              double[][] series2;

              if (save_mode == 0) {
                  series2 = getGradientTimeSeries(file, 5, 5, 8);
                  saveVectors(series2, series_path2);
              } else {
                  series2 = loadTimeSeries(series_path2);
              }

              multi_series.add(series2);

              // computing features from series of descriptors
              FeatureVector fv = new FeatureVector();

              for (int i = 0; i < multi_series.size(); i++) {
                  fv.feature.add(computeFeaturesFromSeries(multi_series.get(i), tws, 1));
                  fv.feature.add(computeFeaturesFromSeries(multi_series.get(i), tws, 2));
                  fv.feature.add(computeFeaturesFromSeries(multi_series.get(i), tws, 5));
              }
              LOG.info((k + 1) + "/" + files.size() + " files done. " + "Finished processing file: "
                      + file.getFileName());
              fv_list.add(fv);

          } catch (PoTException e) {
              LOG.severe("PoTException occurred: " + e.message + ": Skipping file " + files.get(k));
              continue;
          }
      }
      double[][] similarities = calculateSimilarities(fv_list);
      writeSimilarityOutput(files, similarities);
  }

From source file:misc.FileHandler.java

/**
 * Returns whether the given file name is a valid file name indeed. In order
 * to be a valid file name, the file can be in an arbitrary level
 * sub-directory of the current folder. The file can also be in the current
 * directory. The name must not contain navigation elements like '..'.
 * /*from   ww w  .j a v a  2  s.c om*/
 * @param fileName
 *            the file name to check.
 * @return <code>true</code>, if the file name is valid. Otherwise,
 *         <code>false</code> is returned.
 */
public static boolean isFileName(Path fileName) {
    if ((fileName == null) || FILE_NAME_BLACKLIST_PATTERN.matcher(fileName.toString()).matches()) {
        return false;
    }

    Path relativePath = Paths.get("./").resolve(fileName).normalize();
    return (relativePath.getNameCount() >= 2) || !"".equals(relativePath.toString().trim());
}

From source file:misc.FileHandler.java

/**
 * Returns whether the given path is a folder name suitable for server
 * storage. A folder name is suitable for server storage, if it consists of
 * only lower-case alphanumeric characters, starts with a letter and has a
 * maximum length of 10. Moreover, the folder name must not match
 * <code>ServerConnectionHandler.PRIVATE_FOLDER</code>.
 * //ww w  .jav a 2 s. c  o m
 * @param folderName
 *            the folder name to check.
 * @return <code>true</code>, if the folder name is a folder name suitable
 *         for server storage. Otherwise, <code>false</code> is returned.
 */
public static boolean isSharedFolderName(Path folderName) {
    return isFolderName(folderName) && !ServerConnectionHandler.PRIVATE_FOLDER.equals(folderName.toString())
            && FOLDER_PATTERN.matcher(folderName.toString()).matches();
}

From source file:com.arcbees.gwtpolymer.ComponentPathUtilsImpl.java

@Override
public String getFullPackage(Path componentTargetDirectory) {
    return componentTargetDirectory.toString().replace(defaultPackagePath + File.separator, "")
            .replace(File.separator, ".");
}

From source file:misc.FileHandler.java

/**
 * Returns whether the given path is a folder name. The current path
 * <code>.</code> is considered a folder name.
 * //from   w w w.j a v  a2s . c o  m
 * @param folderName
 *            the folder name to check.
 * @return <code>true</code>, if the folder name is a folder name.
 *         Otherwise, <code>false</code> is returned.
 */
public static boolean isFolderName(Path folderName) {
    if (folderName == null) {
        return false;
    }
    Path relativePath = ROOT_PATH.resolve(folderName).normalize();
    return ROOT_PATH.equals(folderName)
            || (!"".equals(relativePath.toString()) && (relativePath.getNameCount() == 1));
}

From source file:gov.nasa.jpl.memex.pooledtimeseries.PoT.java

static ArrayList<double[][][]> getGradientHistograms(Path filename, int w_d, int h_d, int o_d)
          throws PoTException {
      ArrayList<double[][][]> histograms = new ArrayList<double[][][]>();

      VideoCapture capture = new VideoCapture(filename.toString());

      if (!capture.isOpened()) {
          LOG.warning("video file not opened.");

          double[][][] hist = new double[w_d][h_d][o_d];
          histograms.add(hist);//from w ww . j  a  v  a2  s. c  o m
      } else {
          // variables for processing images
          Mat original_frame = new Mat();
          Mat resized = new Mat();
          Mat resized_gray = new Mat();

          // initializing a list of histogram of gradients (i.e. a list of s*s*9
          // arrays)
          for (int i = 0;; i++) {
              // capturing the video images
              capture.read(original_frame);
              if (original_frame.empty()) {

                  if (original_frame.empty()) {
                      if (i == 0) {
                          throw new PoTException("Could not read the video file");
                      } else
                          break;
                  }

              }

              double[][][] hist = new double[w_d][h_d][o_d];

              Imgproc.resize(original_frame, resized, new Size(frame_width, frame_height));
              Imgproc.cvtColor(resized, resized_gray, Imgproc.COLOR_BGR2GRAY);

              ArrayList<double[][]> gradients = computeGradients(resized_gray, o_d);
              updateGradientHistogram(hist, gradients);

              histograms.add(hist);
          }

          capture.release();
      }

      return histograms;
  }

From source file:edu.chalmers.dat076.moviefinder.service.ListeningPathDatabaseHandlerImpl.java

public ListeningPath addPath(Path p) throws DataIntegrityViolationException {
    return repository.save(new ListeningPath(p.toString()));
}

From source file:com.zergiu.tvman.controllers.FSBrowseController.java

/**
 * @param children// w  ww.ja va 2 s. co  m
 */
private void addRootPaths(Map<String, String> children) {
    log.debug("reading root files ");
    Iterable<Path> roots = FileSystems.getDefault().getRootDirectories();
    for (Path f : roots) {
        children.put(f.toString(), f.toString());
    }
}

From source file:edu.chalmers.dat076.moviefinder.service.ListeningPathDatabaseHandlerImpl.java

public void removePath(Path p) throws NullPointerException {
    ListeningPath l = repository.findByListeningPath(p.toString());
    if (l != null) {
        repository.delete(l);//from  w  w w . j a va  2s.  c o  m
    } else {
        throw new NullPointerException();
    }
}

From source file:org.opentestsystem.ap.irs.task.ItemCleanupTask.java

/**
 * If the paths are not equal then true is returned.
 *
 * @param pathToCompare The path to compare.
 * @return True if the two paths are not equal.
 *///from w  w  w. ja v  a 2 s. c  om
private Predicate<Path> isPathNotEqual(final Path pathToCompare) {
    return path -> !StringUtils.equals(pathToCompare.toString(), path.toString());
}