/** * Check if path starts with prefix. * * @param path Path. * @param prefix Prefix. * @return {@code true} if path starts with prefix, {@code false} if not. */ private static boolean startsWith(GridGgfsPath path, GridGgfsPath prefix) { List<String> p1Comps = path.components(); List<String> p2Comps = prefix.components(); if (p2Comps.size() > p1Comps.size()) return false; for (int i = 0; i < p1Comps.size(); i++) { if (i >= p2Comps.size() || p2Comps.get(i) == null) // All prefix components already matched. return true; if (!p1Comps.get(i).equals(p2Comps.get(i))) return false; } // Path and prefix components had same length and all of them matched. return true; } }
/** * Check if path starts with prefix. * * @param path Path. * @param prefix Prefix. * @return {@code true} if path starts with prefix, {@code false} if not. */ private static boolean startsWith(GridGgfsPath path, GridGgfsPath prefix) { List<String> p1Comps = path.components(); List<String> p2Comps = prefix.components(); if (p2Comps.size() > p1Comps.size()) return false; for (int i = 0; i < p1Comps.size(); i++) { if (i >= p2Comps.size() || p2Comps.get(i) == null) // All prefix components already matched. return true; if (!p1Comps.get(i).equals(p2Comps.get(i))) return false; } // Path and prefix components had same length and all of them matched. return true; } }
/** * Update ID with the given index. * * @param newParentPath New parent path. * @param newParentInfo New parent info. */ private void updateParent(GridGgfsPath newParentPath, GridGgfsFileInfo newParentInfo) { assert newParentPath != null; assert newParentInfo != null; assert path.isSubDirectoryOf(newParentPath); parentPath = newParentPath; parentInfo = newParentInfo; ids.set(newParentPath.components().size(), newParentInfo.id()); }
/** * Update ID with the given index. * * @param newParentPath New parent path. * @param newParentInfo New parent info. */ private void updateParent(GridGgfsPath newParentPath, GridGgfsFileInfo newParentInfo) { assert newParentPath != null; assert newParentInfo != null; assert path.isSubDirectoryOf(newParentPath); parentPath = newParentPath; parentInfo = newParentInfo; ids.set(newParentPath.components().size(), newParentInfo.id()); }
/** * Gets all file IDs for components of specified path possibly skipping existing transaction. Result cannot * be empty - there is at least root element. But each element (except the first) can be {@code null} if such * files don't exist. * * @param path Path. * @param skipTx Whether to skip existing transaction. * @return Collection of file IDs for components of specified path. * @throws GridException If failed. */ private List<GridUuid> fileIds(GridGgfsPath path, boolean skipTx) throws GridException { assert path != null; // Path components. Collection<String> components = path.components(); // Collection of file IDs for components of specified path. List<GridUuid> ids = new ArrayList<>(components.size() + 1); ids.add(ROOT_ID); // Always add root ID. GridUuid fileId = ROOT_ID; for (String s : components) { assert !s.isEmpty(); if (fileId != null) fileId = fileId(fileId, s, skipTx); ids.add(fileId); } return ids; }
/** * Gets all file IDs for components of specified path possibly skipping existing transaction. Result cannot * be empty - there is at least root element. But each element (except the first) can be {@code null} if such * files don't exist. * * @param path Path. * @param skipTx Whether to skip existing transaction. * @return Collection of file IDs for components of specified path. * @throws GridException If failed. */ private List<GridUuid> fileIds(GridGgfsPath path, boolean skipTx) throws GridException { assert path != null; // Path components. Collection<String> components = path.components(); // Collection of file IDs for components of specified path. List<GridUuid> ids = new ArrayList<>(components.size() + 1); ids.add(ROOT_ID); // Always add root ID. GridUuid fileId = ROOT_ID; for (String s : components) { assert !s.isEmpty(); if (fileId != null) fileId = fileId(fileId, s, skipTx); ids.add(fileId); } return ids; }
List<String> components = endPath.components(); for (int i = startPath.components().size(); i < components.size(); i++) { curPath = new GridGgfsPath(curPath, components.get(i));
List<String> components = endPath.components(); for (int i = startPath.components().size(); i < components.size(); i++) { curPath = new GridGgfsPath(curPath, components.get(i));
List<String> components = path.components();
List<String> components = path.components();