Package thredds.crawlabledataset
Class CrawlableDatasetUtils
- java.lang.Object
-
- thredds.crawlabledataset.CrawlableDatasetUtils
-
public class CrawlableDatasetUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description CrawlableDatasetUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetPath(String[] pathSegments)static String[]getPathSegments(String path)Split a path into segments, handles null as empty string.static booleanisValidAbsolutePath(String[] pathSegments)static booleanisValidRelativePath(String[] pathSegments)static StringstepDownRelativePath(String[] pathSegments)Given a relative path as an array of path segments (seegetPathSegments(String), return the path relative to the first path segment.static StringtoStringForPathSegments(String path)static StringtoStringForPathSegments(String[] pathSegments)
-
-
-
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("/").
-
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 (seegetPathSegments(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.
-
-