public class PathUtil extends Object
Modifier and Type | Field and Description |
---|---|
static Pattern |
invalidChars
Invalid characters in module/file path names.
|
Modifier and Type | Method and Description |
---|---|
static URI |
appendToPath(URI uri,
String append) |
static String |
getExtension(String path)
Returns the file extension part of the specified path
|
static String |
getModuleName(URI uri)
Returns the module name for the specified URI.
|
static String[] |
normalizePaths(String ref,
String[] paths)
This method normalizes an array of paths so that they do not start with
or contain any ".." path segments.
|
static URI |
stripJsExtension(URI value) |
static URI |
url2uri(URL url)
Convenience method to convert a URL to a URI that doesn't throw a
URISyntaxException if the path component for the URL contains
spaces (like
URL.toURI() does). |
public static final Pattern invalidChars
public static String[] normalizePaths(String ref, String[] paths) throws IllegalArgumentException
ref
. In the returned array,
the strings in the paths
array have been replaced with the
normalized path. Any paths that do not resolve relative to ref
(for example, paths that begin with '/' or try to navigate out of the
top level path component specified by ref
using '../' path
components) will result in an IllegalArgumentException
.ref
- The reference location for relative paths. May be a file or
directory.paths
- The array of paths that are to be normalized. The paths are
normalized in-place (i.e. each array element is replaced by
the normalized path)IllegalArgumentException
public static String getModuleName(URI uri)
uri
- the uri to return the name forpublic static URI url2uri(URL url) throws URISyntaxException
URL.toURI()
does).url
- The input URLURISyntaxException
public static URI stripJsExtension(URI value) throws URISyntaxException
URISyntaxException
public static URI appendToPath(URI uri, String append) throws URISyntaxException
URISyntaxException
Copyright © 2011-2015 IBM. All Rights Reserved.