Class CrawlableDatasetUtils


  • public class CrawlableDatasetUtils
    extends Object
    • Constructor Detail

      • CrawlableDatasetUtils

        public CrawlableDatasetUtils()
    • Method Detail

      • getPathSegments

        public static String[] getPathSegments​(String path)
        Split a path into segments, handles null as empty string.

        Results: Path [] splits into 1 segments: [] Path [a] splits into 1 segments: [a] Path [a/] splits into 1 segments: [a] Path [a/b] splits into 2 segments: [a][b] Path [a/b/c] splits into 3 segments: [a][b][c] Path [/] splits into 0 segments: Path [/a] splits into 2 segments: [][a] Path [/a/b] splits into 3 segments: [][a][b] Path [/a/b/c] splits into 4 segments: [][a][b][c]

        So, absolute paths are valid if length is >1 and first segment is "". Relative paths are valid if length is >0 and first segment is not "".

        Parameters:
        path - the path to split.
        Returns:
        String[] containing path segments, as per String.split("/").
      • getPath

        public static String getPath​(String[] pathSegments)
      • isValidAbsolutePath

        public static boolean isValidAbsolutePath​(String[] pathSegments)
      • isValidRelativePath

        public static boolean isValidRelativePath​(String[] pathSegments)
      • stepDownRelativePath

        public static String stepDownRelativePath​(String[] pathSegments)
        Given a relative path as an array of path segments (see getPathSegments(String), return the path relative to the first path segment. I.e., drop the first segmentRejoin the given path segments after dropping the first path segment.
        Parameters:
        pathSegments - a string array of a relative path as returned by getPathSegments()
        Returns:
        the path relative to the first path segment.
      • toStringForPathSegments

        public static String toStringForPathSegments​(String[] pathSegments)
      • toStringForPathSegments

        public static String toStringForPathSegments​(String path)